How to Hangup Everyone?


#1

I could do this now in the Dialplan using a global variable to list all the extensions to issue a softHangup to but would prefer to work on the active channels only.
With some Googling I found an interesting way to do this using awk by requesting and parsing active channels but cannot get it to work in 1.8
Here is what I have and I am using sip channels exclusively:

exten => 5555,1,Set(CHAN=${SHELL(asterisk -rx “core show channels” |awk -F’-’ -vORS=’&’ ’ /^SIP/ {print $1}’)
exten => s,n,SoftHangup(${CHAN})

The first line is trying to build a variable from the first part ( pre hyphen) of each channel row in core show channels that starts with ‘SIP’ as in sip/1234-xxxxxxx and join them together in one line - something like sip/1234&sip/2345&sip/3456 and set a variable

Does anyone have a working version of this? I can see it being useful for other global tasks too

Thanks

Bill


#2

CLI: core stop now
CLI: core restart now

What are you trying to achieve by hanging up everyone?


#3

Why do I want to hang up everybody?

In our system, certain users can Page everyone for security reasons.
For serious issues, I want to give them the ability to dump any existing calls before paging to ensure that all extensions get their page.

A soft hangup to Global variable ‘ALL’ everyone will achive this but if I can do it by detecting who is busy right now then :
a) I dont try to hang up all extensions - just those in use
b) Configuration is easier since if I add another extension, I won’t have to edit my global variable since it will show up as a channel

Bill


#4

try using the command “core show hints” this show you the state of extension: idle, inuse,unavailable. Then selec all inuse and hangup them.


#5

hints have to be declared in the dialplan before Asterisk can make the device to extension translation.


#6

That gets me right back to the same issue - how to parse a CLI command and run the result in Dialplan.
It seems just as easy ( or hard) for me to parse Core show channels as it is to parse Core show hints

Bill


#7

Using linux console is relative easy:

#asterisk -rx 'core show channels' >> canales.txt #cat canales.txt | awk '{print $1}' | grep SIP/ SIP/1401-00001077 SIP/1401-00001539 SIP/1401-00000ca9 SIP/1401-000010fb SIP/1401-000006b1 SIP/1401-000011e7

Then you can open the text file an use foreach for ‘hangup request $line’.


#8

You don’t want >>, as you will get duplicates after the first run, and file that continually grows.

The cat is redundant.

Actually the file is redundant.

#asterisk -rx ‘core show channels’ | awk ‘{print $1}’ | grep SIP/

(The grep is also redundant, as awk can do that, although the total number of characters in the command may be more.)


#9

Its only an example if you have a better example post it.