Hi, i need some help. Is there a way in scripting like in lua like using freeswitch.API() through which i can get active channels . I can get active channels in fs cli by running command "active channels".But how to do it in scripts. Thanks. Regards, Shan randhawa
Hi, Can any tell me how to access/call freeswitch client and then execute command on it. like reply = fs.command("show channels"); Thanks. Regards, Shan randhawa On Mon, Jan 25, 2016 at 10:03 PM, Shan Randhawa <randhawaay@gmail.com> wrote:
Hi,
i need some help. Is there a way in scripting like in lua like using freeswitch.API() through which i can get active channels .
I can get active channels in fs cli by running command "active channels".But how to do it in scripts.
Thanks.
Regards, Shan randhawa
Shan, If you are using Lua you can access that information by calling a Lua script from the dialplan and utilizing the API. api = freeswitch.API(); local channelCount = api:executeString("show channels"); session:consoleLog("crit", "here I am I worked," .. channelCount); This printed “[CRIT] switch_cpp.cpp:1284 here I am I worked, uuid,direction,created,created_epoch,name,state,cid_name,cid_num,ip_addr,dest,application,application_data,dialplan,context,read_codec,read_rate,read_bit_rate,write_codec,write_rate,write_bit_rate,secure,hostname,presence_id,presence_data,callstate,callee_name,callee_num,callee_direction,call_uuid,sent_callee_name,sent_callee_num,initial_cid_name,initial_cid_num,initial_ip_addr,initial_dest,initial_dialplan,initial_context 7bf61657-5dfe-4797-8c99-59e382cfb422,inbound,2016-01-25 17:59:34,1453773574,sofia/external/1000@192.168.0.10,CS_EXECUTE,1000,1000,192.168.0.10,1001,playback, ring.wav,XML,public,PCMU,8000,64000,PCMU,8000,64000,,TestMedia1,,,ACTIVE,,,,,,,1000,1000,192.168.0.10,1001,XML,public 1 total.” You will more than likely need to parse this to meet your needs. For further information on the Lua API there is a wiki doc that might help you. https://freeswitch.org/confluence/display/FREESWITCH/Lua+API+Reference#LuaAP... Thanks, Branden Jordan From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Shan Randhawa Sent: Monday, January 25, 2016 11:13 AM To: FreeSWITCH Users Help <freeswitch-users@lists.freeswitch.org>; brian@freeswitch.org; mike@jerris.com Subject: Re: [Freeswitch-users] DETECT ACTIVE CHANNELS Hi, Can any tell me how to access/call freeswitch client and then execute command on it. like reply = fs.command("show channels"); Thanks. Regards, Shan randhawa [Image removed by sender.] On Mon, Jan 25, 2016 at 10:03 PM, Shan Randhawa <randhawaay@gmail.com<mailto:randhawaay@gmail.com>> wrote: Hi, i need some help. Is there a way in scripting like in lua like using freeswitch.API() through which i can get active channels . I can get active channels in fs cli by running command "active channels".But how to do it in scripts. Thanks. Regards, Shan randhawa [Image removed by sender.]
Hi, i need some help. Basically i need a way to get info about active no of active outbound sessions in lua . Thanks. Regards, Shan randhawa On Mon, Jan 25, 2016 at 10:03 PM, Shan Randhawa <randhawaay@gmail.com> wrote:
Hi,
i need some help. Is there a way in scripting like in lua like using freeswitch.API() through which i can get active channels .
I can get active channels in fs cli by running command "active channels".But how to do it in scripts.
Thanks.
Regards, Shan randhawa
For LUA it’s (FS 1.6): api = freeswitch.API(); num_channels = api:executeString("show channels count"); digits = api:execute("regex", num_channels .. "|/([0-9]*)/|$1"); freeswitch.consoleLog("info", "num channels is: " .. digits .. "\n") to get the number of active channels. IN Dialplan it could be done like this: <action application="set" data="foo=${regex(${show channels count}|/([0-9]*)/|%1)}"/> <action application="log" data="INFO foo: ${foo}" /> Von: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] Im Auftrag von Shan Randhawa Gesendet: Montag, 25. Januar 2016 20:58 An: FreeSWITCH Users Help <freeswitch-users@lists.freeswitch.org> Betreff: Re: [Freeswitch-users] DETECT ACTIVE CHANNELS Hi, i need some help. Basically i need a way to get info about active no of active outbound sessions in lua . Thanks. Regards, Shan randhawa [https://mailtrack.io/trace/mail/b549f1756837c458a4ac23786cf74b4359f1fd023264...] On Mon, Jan 25, 2016 at 10:03 PM, Shan Randhawa <randhawaay@gmail.com<mailto:randhawaay@gmail.com>> wrote: Hi, i need some help. Is there a way in scripting like in lua like using freeswitch.API() through which i can get active channels . I can get active channels in fs cli by running command "active channels".But how to do it in scripts. Thanks. Regards, Shan randhawa [X]
PS: If you only want outbound calls you could try: Show channels like external as command, you then however must have a sip profile that is only for outbound (in this case named external). Von: Marcel Haldemann Gesendet: Dienstag, 26. Januar 2016 11:39 An: FreeSWITCH Users Help <freeswitch-users@lists.freeswitch.org> Betreff: AW: [Freeswitch-users] DETECT ACTIVE CHANNELS For LUA it’s (FS 1.6): api = freeswitch.API(); num_channels = api:executeString("show channels count"); digits = api:execute("regex", num_channels .. "|/([0-9]*)/|$1"); freeswitch.consoleLog("info", "num channels is: " .. digits .. "\n") to get the number of active channels. IN Dialplan it could be done like this: <action application="set" data="foo=${regex(${show channels count}|/([0-9]*)/|%1)}"/> <action application="log" data="INFO foo: ${foo}" /> Von: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org] Im Auftrag von Shan Randhawa Gesendet: Montag, 25. Januar 2016 20:58 An: FreeSWITCH Users Help <freeswitch-users@lists.freeswitch.org<mailto:freeswitch-users@lists.freeswitch.org>> Betreff: Re: [Freeswitch-users] DETECT ACTIVE CHANNELS Hi, i need some help. Basically i need a way to get info about active no of active outbound sessions in lua . Thanks. Regards, Shan randhawa [https://mailtrack.io/trace/mail/b549f1756837c458a4ac23786cf74b4359f1fd023264...] On Mon, Jan 25, 2016 at 10:03 PM, Shan Randhawa <randhawaay@gmail.com<mailto:randhawaay@gmail.com>> wrote: Hi, i need some help. Is there a way in scripting like in lua like using freeswitch.API() through which i can get active channels . I can get active channels in fs cli by running command "active channels".But how to do it in scripts. Thanks. Regards, Shan randhawa [X]
participants (3)
-
Branden Jordan
-
Marcel Haldemann
-
Shan Randhawa