Yehavi Bourvine +972-8-9489444
2007-Nov-27 15:33 UTC
[asterisk-users] Finding the status of an extension
Hello, I would like to check whether an extension is busy or not before calling the Dial() application to it (for example - to play a Busy if it is on conversation). How do I check it? In the trunk version there was a function DEVSTATE(SIP/123), however it does not exist on version 1.4.13... What is the equivalent of it? Thanks, __Yehavi:
Yehavi Bourvine +972-8-9489444 wrote:> Hello, > > I would like to check whether an extension is busy or not before calling the > Dial() application to it (for example - to play a Busy if it is on > conversation). > > How do I check it? In the trunk version there was a function > DEVSTATE(SIP/123), however it does not exist on version 1.4.13... What is the > equivalent of it?http://www.asterisk.org/node/48360 Btw, you can use also g flag of Dial() so, that call will continue, and you will get BUSY status instantly. Regards, Atis
Andre Courchesne - Consultant
2007-Nov-27 16:46 UTC
[asterisk-users] Finding the status of an extension
Hi, Here is a small AGI script that get you the hint status of the extension simply call AGI(script.agi,SIP/100) !/usr/bin/perl # # page.agi - Original file was allpage.agi by Rob Thomas 2005. # With parts of allcall.agi Original file by John Baker # Modified by Adam Boeglin to allow for paging sccp phones #Modified/Updated by Jeremy Betts 6/1/2006 for improved efficiency.. # We now use AGI to set the dialplan variable.. much smarter! #Modifier by Andre Courchesne 11-27-2007 (acourchesne at prival.ca) # Modified to return the hint status of a single extension # Tested with SIP extension only # # This program is free software; you can redistribute it and/or # modify it under the terms of Version 2 of the GNU General # Public License as published by the Free Software Foundation # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # # This works with both my aastra, polycom, sipura/linksys and cisco sccp phones. # It should be easily modified for other sip phones # # Documentation: # Simply returns channel variable MYSTATE # 0: Extension is busy # 1: Extension is available # # # use Asterisk::AGI; $AGI = new Asterisk::AGI; @bypass = "@ARGV"; @sips = `sudo /usr/sbin/asterisk -rx "show hints" | grep -a "$bypass[0]"`; #foreach $sipline (@sips) #{ # print "Noop $sipline\n"; #} #print "Noop -------------------\n"; #foreach $argline (@bypass) #{ # print "Noop $argline\n"; #} $mystate=0; my ($junk0, $junk1, $junk2, $exten, $state, $junk2) = split(/ +/, $sips[0],6); my ($type, $extension) = split(/\//,$chan,2); print "Noop Comparing [".$exten."] and [".$bypass[0]."] $state\n"; if($state eq "State:Idle") { $mystate=1; print "Noop Found extension $exten to be Idle\n"; }