Script to page mixed SIP / SCCP system

I've updated the AGI script to function more efficiently. It now sets the dialplan variable through AGI itself no more Telnet/AMI
much smarter! Thanks to Adam for adding the sccp functionality! We use this for a mixture of Cisco, Polycom, and Linksys phones.

Our office is running a mixed network of Sipura SPA-941's and Cisco 79XX Series phones. We chose the higher end Cisco phones for the Executives and Managers, and the cheaper Sipura's for their similarity to the Cisco Phones. The only problem was setting up paging to work phone all of the phones. I modified a Perl AGI script that I had found online to work with both protocols. This has been tested with Asterisk@Home 2.8

First Add the following to your dial plan

exten => 5555,1,Set(TIMEOUT(absolute) = 15)
exten => 5555,n,AGI(page.agi|<arg>|<arg>)
exten => 5555,n,SetCallerID("Page:${CALLERIDNAME}" <${CALLERIDNUM}>)
exten => 5555,n,Set(_ALERT_INFO="Ring Answer")
exten => 5555,n,SIPAddHeader(Call-Info:\; answer-after=0)
exten => 5555,n,Page(${PAGE_GROUP})
exten => 5555,n,Hangup

Then, create a file in your agi directory (/var/lib/asterisk/agi-bin/) called "page.agi" and add the following.
    • Be sure this file is executable by asterisk!

# 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!
# 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
# GNU General Public License for more details.
# page.agi will find all available sip & sccp phones
# it then sets the dialplan variable PAGE_GROUP to allow
# the phones to be paged with the Page cmd.
# This works with both my aastra, polycom, sipura/linksys and cisco sccp phones.
# It should be easily modified for other sip phones
# Documentation:
#  Add something similar to your dialplan,arguments are extensions to
#  to be excluded from the page. Use just the extension numbers.
#exten => *61,1,Set(TIMEOUT(absolute) = 15)
#exten => *61,n,AGI(page.agi|<arg>|<arg>)
#exten => *61,n,SetCallerID("Page:${CALLERIDNAME}" <${CALLERIDNUM}>)
#exten => *61,n,Set(_ALERT_INFO="Ring Answer")
#exten => *61,n,SIPAddHeader(Call-Info: answer-after=0)
#exten => *61,n,Page(${PAGE_GROUP})
#exten => *61,n,Hangup()
#use Asterisk::AGI;
use Asterisk::AGI;
$AGI = new Asterisk::AGI;
# set our array of phones that we will NOT be paging
@bypass = "@ARGV";
# Get our needed info for idle sip & sccp phones
@sips = grep(/^\s+\d+\s.*/, `asterisk -rx "show hints"`);
# Now check each phone to see if it's in use and also
# against our exclude list.  If it passes both, it's
# added to our array of calls to make
# Then set the dialplan variable thru AGI

foreach $sipline (@sips) {
        my ($junk0, $exten, $junk1, $chan, $state, $junk2) = split(/ +/, $sipline,6);
        my ($type, $extension) = split(/\//,$chan,2);
        unless (($state ne "State:Idle") || (grep(/$exten/i, @bypass))) {
                if ($type eq "SCCP") {
                        my $SCCP = $chan . "/aa=1wu/ringer=outside";

                } else {

$page = join("&",@mypage);

$AGI->set_variable("PAGE_GROUP", "$page");


The script will check the hints for phones that are available, and only ring into them for a one way all page.

Created by: adamb, Last modification: Fri 02 of Jun, 2006 (06:24 UTC) by specialtel
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+