[Freeswitch-users] DETECT ACTIVE CHANNELS

Marcel Haldemann marcel.haldemann at convercom.ch
Tue Jan 26 19:03:02 MSK 2016


small correction for my previous answer: 

For "outbound" only channels the command would have to be like:

Show channels count like external

What would result in:

api = freeswitch.API();
filter = " like external"; -- set this as needed or let empty for no filter
num_channels = api:executeString("show channels count" .. filter);
digits = api:execute("regex", num_channels  .. "|/([0-9]*)/|$1");
freeswitch.consoleLog("info", "num channels is: " .. digits .. "\n");

as already mentioned this would expect a profile for outbound calls "only", called external.
More info about the filter see here: 
https://freeswitch.org/confluence/display/FREESWITCH/mod_commands and search for "show channels"
This applys to FreeSwitch 1.6/1.7

-----Ursprüngliche Nachricht-----
Von: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] Im Auftrag von Marcel Haldemann
Gesendet: Dienstag, 26. Januar 2016 15:38
An: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
Betreff: Re: [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}" />


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).

_________________________________________________________________________
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



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