Skip to main content

Detect Active Channels

About

Methods to list active call sessions.

Heartbeat

>From: bkw__

Even more efficient is to subscribe to the HEARTBEAT, as it has the session count in there. This fires every few seconds.

Lua Script

>From: Marcel Haldemann
Sent: Tuesday, 26 January, 2016 09:38
To: FreeSWITCH Users Help
Subject: Re: [Freeswitch-users] DETECT ACTIVE CHANNELS

For LUA it's (FS 1.6):

Lua active channel display

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.

XML Dialplan

In the XML 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}" />

Note: If you only want outbound calls you could try:

show channels like external

as the command, you then however must have a SIP profile that is only for outbound (in this case named 'external').