<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.3">
</HEAD>
<BODY>
<BR>
On Thu, 2009-03-26 at 07:19 -0700, Vieri wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
<TT><FONT COLOR="#000000">Maybe I could simply do something like:</FONT></TT><BR>
<TT><FONT COLOR="#000000">asterisk -rx "show channels" | grep -c -i zap</FONT></TT><BR>
<TT><FONT COLOR="#000000">to get the number of zap/dahdi channels in use.</FONT></TT><BR>
</BLOCKQUOTE>
<BR>
I was actually using a command similar to that up until a few months ago.<BR>
<BR>
/usr/sbin/asterisk -rx 'show channels' | grep '^Zap/[1-9]-\|^Zap/1[0-9]-\|^Zap/2[0-3]-' | wc -l<BR>
<BR>
That command counted the number of lines that started with one of the first 23 Zap channels<BR>
<BR>
<BR>
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.<BR>
<BR>
<?php<BR>
$data1=0;<BR>
$data2=0;<BR>
<BR>
require_once('/opt/checkers/lib/asterisk/phpagi-asmanager.php');<BR>
$asm = new AGI_AsteriskManager('/opt/checkers/lib/asterisk/phpagi.conf');<BR>
<BR>
if($asm->connect()) {<BR>
$asm->events('off');<BR>
$channels = $asm->command("show channels concise");<BR>
$channels = $channels['data'];<BR>
$channelRows = explode("\n",$channels);<BR>
while($row=array_shift($channelRows)){<BR>
$rowDetails=explode('!',$row);<BR>
if(substr($rowDetails[0],0,3) == 'Zap'){<BR>
$zapChannel=substr($rowDetails[0],4,(strpos($rowDetails[0],'-')-4));<BR>
if($zapChannel<24){<BR>
if(substr($rowDetails[7],0,1) == '9') $data2++;<BR>
else $data1++;<BR>
}<BR>
}<BR>
}<BR>
$asm->disconnect();<BR>
}<BR>
echo "$data1!$data2";<BR>
?><BR>
<BR>
</BODY>
</HTML>