[asterisk-users] show pri usage
Bob Pierce
pierceb at westmancom.com
Thu Mar 26 11:43:38 CDT 2009
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
More information about the asterisk-users
mailing list