<!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 &quot;show channels&quot; | 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>
&lt;?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>
&nbsp;&nbsp; <BR>
if($asm-&gt;connect()) {<BR>
&nbsp; $asm-&gt;events('off');<BR>
&nbsp; $channels = $asm-&gt;command(&quot;show channels concise&quot;);<BR>
&nbsp; $channels = $channels['data'];<BR>
&nbsp; $channelRows = explode(&quot;\n&quot;,$channels);<BR>
&nbsp; while($row=array_shift($channelRows)){<BR>
&nbsp;&nbsp;&nbsp; $rowDetails=explode('!',$row);<BR>
&nbsp;&nbsp;&nbsp; if(substr($rowDetails[0],0,3) == 'Zap'){<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $zapChannel=substr($rowDetails[0],4,(strpos($rowDetails[0],'-')-4));<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if($zapChannel&lt;24){<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(substr($rowDetails[7],0,1) == '9') $data2++;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else $data1++;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp; }<BR>
&nbsp; }<BR>
&nbsp; $asm-&gt;disconnect();<BR>
}<BR>
echo &quot;$data1!$data2&quot;;<BR>
?&gt;<BR>
<BR>
</BODY>
</HTML>