Hi, I would like to know how to see which channels are used in my PRI E1 link from Asterisk to another locally-connected commercial PBX. If I run "dahdi show channels", I can see the used channels in the second column "extension" but only if it's an "incoming" call (ie. legacy PBX to Asterisk). If I dial from an Asterisk extension to an extension in the other PBX, "dahdi show channels" does not show me which channel it's using (there is nothing in the "extension" column). "show channels" does show SIP to ZAP usage but it's not that clear. My goal is to simply record the PRI channel usage through time (like a 10 minute cron script that polls PRI link status/usage). Maybe I could simply do something like: asterisk -rx "show channels" | grep -c -i zap to get the number of zap/dahdi channels in use. Any ideas? Thanks, Vieri
On Thu, 2009-03-26 at 07:19 -0700, Vieri wrote:> Maybe I could simply do something like: > asterisk -rx "show channels" | grep -c -i zap > to get the number of zap/dahdi channels in use.I was actually using a command similar to that up until a few months ago. /usr/sbin/asterisk -rx 'show channels' | grep '^Zap/[1-9]-\| ^Zap/1[0-9]-\|^Zap/2[0-3]-' | wc -l That command counted the number of lines that started with one of the first 23 Zap channels Now, I'm using phpagi to monitor from another server. This script polls both in and out usage on those 23 zap channels where $data1 is In and $data2 is Out. <?php $data1=0; $data2=0; require_once('/opt/checkers/lib/asterisk/phpagi-asmanager.php'); $asm = new AGI_AsteriskManager('/opt/checkers/lib/asterisk/phpagi.conf'); if($asm->connect()) { $asm->events('off'); $channels = $asm->command("show channels concise"); $channels = $channels['data']; $channelRows = explode("\n",$channels); while($row=array_shift($channelRows)){ $rowDetails=explode('!',$row); if(substr($rowDetails[0],0,3) == 'Zap'){ $zapChannel=substr($rowDetails[0],4,(strpos($rowDetails[0],'-')-4)); if($zapChannel<24){ if(substr($rowDetails[7],0,1) == '9') $data2++; else $data1++; } } } $asm->disconnect(); } echo "$data1!$data2"; ?> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090326/2820559d/attachment.htm
On Thu, 26 Mar 2009, Vieri wrote:> I would like to know how to see which channels are used in my PRI E1 > link from Asterisk to another locally-connected commercial PBX. > > My goal is to simply record the PRI channel usage through time (like a > 10 minute cron script that polls PRI link status/usage). > > Maybe I could simply do something like: asterisk -rx "show channels" | > grep -c -i zap to get the number of zap/dahdi channels in use.I do it with a shell script run every minute on each server and then I store the count and the HOSTNAME in the database. (Now that my AMI skills are a bit better, I'd probably do it in PHP and AMI...) Then I have a php script that creates a web page showing the maximum channels in use with a row for each host and a column for each hour of the day. Thanks in advance, ------------------------------------------------------------------------ Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
--- On Thu, 3/26/09, Bob Pierce <pierceb at westmancom.com> wrote:> Now, I'm using phpagi to monitor from another server. > This script polls both in and out usage on those 23 zap > channels where $data1 is In and $data2 is Out.Thanks for sharing your script. I see you're using "show channels". So does this mean that "{zap,dahdi} show channels" is "not as useful" as "show channels"? Is it intended that "zap show channels" does not show busy channels if it's an outgoing call? I'm asking this because maye my config is wrong somewhere and that's why nothing shows up in the "extension" column except for incoming calls (maybe something to do with caller id detection). If you place an outgoing call, say, from a SIP extension through the PRI, does a "zap show channels" actually show that call? Thanks again, Vieri