[Freeswitch-users] How to execute lua script on register?

Dušan Dragić dragic.dusan at gmail.com
Wed Dec 31 19:23:43 MSK 2014


I agree with Ken, there are better ways to do this.

Maybe off topic:
I noticed a bug with how the hook event subclass string (in lua.conf)
is compared to the event subclass. For example
subclass="sofia::register" matches sofia::register,
sofia::register_attempt and sofia::register_failure event subclasses.
Also something like subclass="ia::register_atte" works (matches
sofia::register_attempt)

Looks like it's searching for a substring. I should probably open a jira.

On 30 December 2014 at 16:40, Ken Rice <krice at freeswitch.org> wrote:
> Why would you do this?
>
> With any kind of registration load this is going to be horrible for CPU
> performance... Every time fire this lua script there is no job control is
> fire and forget, it spawns a new thread and if it hangs there is nothing you
> can do short of restarting freeswitch.
>
> Now, if you look at mod_sofia, you will notice that you can push all the
> internal data tables to an external database such as PostgreSQL... This
> allows you to see the state of every registered endpoint.
>
> Also if you really want a script to monitor things, simply attach to ESL and
> only subscribe to the events you want to see. This allows you to use
> whatever language you want with job control.
>
>
>
> On 12/29/14, 9:06 PM, "Jaime" <jaimecm at gmail.com> wrote:
>
>> Hi,
>  I use the following line in “autoload_configs/lua.conf.xml” to monitor
>> de
> register state of my gateways:
>    <hook event="CUSTOM"
>> subclass="sofia::gateway_state"
> script="catch-event-gateway.lua"/>
>
> And put in
>> your scripts directory the file catch-event-gateway.lua with
> the following
>> code to see what happens:
>    freeswitch.consoleLog("notice",”event ====
>> sofia::gateway_state
> =====\n")
>    freeswitch.consoleLog("notice","    event\n"
>> .. event:serialize())
>
>
>
> Also, for internal users register events, you can try
>> the same code with
> the following “subclass” events:
>   sofia::register_failure
>
>> sofia::register
>   sofia::expire
>   sofia::register_attempt
>   sofia::unregister
>
>> sofia::pre_register
>
>
>
> Regards
> JCM
>
>
> From:  Ken Rice
>> <krice at freeswitch.org>
> Reply-To:  FreeSWITCH Users Help
>> <freeswitch-users at lists.freeswitch.org>
> Date:  viernes, 26 de diciembre de
>> 2014, 11:30
> To:  FreeSWITCH Users Help
>> <freeswitch-users at lists.freeswitch.org>
> Subject:  Re: [Freeswitch-users] How
>> to execute lua script on register?
>
>
> You cant fire a script on register...
>> Your options are ESL to monitor it
> (which you can write in lua) or luarun and
>> have a lua script constantly
> running processing register events... The
>> external script would probably
>
>
> On 12/26/14 2:39 AM, "poliv78 at yahoo.co.uk"
>> <poliv78 at yahoo.co.uk> wrote:
>
>
> Здравствуйте, David.
>         Yes I know that,
>> thanks.
>         But I want to monitor all registrations. Simply put in
>> database
> fail or success.
>         I know I can use ESL for that. But lua is
>> more handy here and I
> would like to know if it's possible.
>
> Вы писали 25
>> декабря 2014 г., 23:33:41:
>
>
> You could just look at the log for failed
>> attempts.
> On Dec 25, 2014 1:21 PM, <poliv78 at yahoo.co.uk> wrote:
> Hi all
>
> Is it
>> possible to execute lua script when gateway try to register
>  to know if it
>> successfull or failed?
>
>  The same question as for internal users.
>
>> Thanks.
>
>
> --
> С уважением,
>  Poliv78
>> mailto:poliv78 at yahoo.co.uk
>
>
> _________________________________________________
>> ________________________
> Professional FreeSWITCH Consulting
>> Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Offici
>> al FreeSWITCH
>> Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cl
>> uecon.com
>
> FreeSWITCH-users mailing
>> list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman
>> /listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/opt
>> ions/freeswitch-users
> http://www.freeswitch.org
>
>
>
>
>
> --
>>
> Ken
> http://www.FreeSWITCH.org
> http://www.ClueCon.com
> http://www.OSTAG.org
> irc
>> .freenode.net #freeswitch
> Twitter:
>> @FreeSWITCH
>
>
>
>
> ______________________________________________________________
>> ___________
> Professional FreeSWITCH Consulting
>> Services:
> consulting at freeswitch.orghttp://www.freeswitchsolutions.com
>
> Officia
>> l FreeSWITCH
>> Sites
> http://www.freeswitch.orghttp://confluence.freeswitch.orghttp://www.clue
>> con
> .com
>
> FreeSWITCH-users mailing
>> list
> FreeSWITCH-users at lists.freeswitch.orghttp://lists.freeswitch.org/mailman/
>> li
> stinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/opt
>> ions/freeswitch-usershtt
> p://www.freeswitch.org
>
>
>
> ___________________________
>> ______________________________________________
> Professional FreeSWITCH
>> Consulting Services:
>>
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official
>> FreeSWITCH
>> Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cl
>> uecon.com
>
> FreeSWITCH-users mailing
>> list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman
>> /listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/opt
>> ions/freeswitch-users
> http://www.freeswitch.org
>
> --
> Ken
> http://www.FreeSWITCH.org
> http://www.ClueCon.com
> http://www.OSTAG.org
> irc.freenode.net #freeswitch
> Twitter: @FreeSWITCH
>
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org



-- 
Dušan Dragić



Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list