<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BarryODonovan.com &#187; VoIP</title>
	<atom:link href="http://www.barryodonovan.com/index.php/category/voip/feed" rel="self" type="application/rss+xml" />
	<link>http://www.barryodonovan.com</link>
	<description>Thoughts, ramblings and rants...</description>
	<lastBuildDate>Wed, 18 Jan 2012 10:31:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Asterisk with SS7 via Wanpipe, Dahdi and libss7 – with ISUP SAM support</title>
		<link>http://www.barryodonovan.com/index.php/2012/01/12/asterisk-ss7-sam-support</link>
		<comments>http://www.barryodonovan.com/index.php/2012/01/12/asterisk-ss7-sam-support#comments</comments>
		<pubDate>Thu, 12 Jan 2012 08:05:08 +0000</pubDate>
		<dc:creator>Barry O'Donovan</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[My Links]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[Recipes]]></category>
		<category><![CDATA[VoIP]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[asterisk chan_ss7]]></category>
		<category><![CDATA[chan_ss7]]></category>
		<category><![CDATA[dahdi ss7]]></category>
		<category><![CDATA[isup sam]]></category>
		<category><![CDATA[libss7]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[sam]]></category>
		<category><![CDATA[sangoma]]></category>
		<category><![CDATA[sangoma ss7]]></category>
		<category><![CDATA[ss7]]></category>
		<category><![CDATA[ss7 sam]]></category>
		<category><![CDATA[subsequent address message]]></category>
		<category><![CDATA[zaptel ss7]]></category>

		<guid isPermaLink="false">http://www.barryodonovan.com/?p=385</guid>
		<description><![CDATA[A howto on installing Asterisk with SS7 supported via libss7 on Sangoma hardware along with support for ISUP SAM messages. <a href="http://www.barryodonovan.com/index.php/2012/01/12/asterisk-ss7-sam-support">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After much head banging in bringing up an SS7 link with SAM support, I am documented what worked here.</p>
<p>Firstly, what is <em>SAM support</em>? One end of an SS7 link initialises a new call by sending an <em>Initial Address Message (IAM)</em>. All SS7 software stacks support this and usually it&#8217;s enough. One case where it&#8217;s not enough is when one wants to address a phone number with more than the E.164 standard max length of 16  (usually to pass additional information tacked on the start, end of or even replacing an A or B number). In this scenario, SS7 uses a <em>Subsequent Address Message (SAM)</em> to send the additional digits. Most / all mainstream Asterisk SS7 software stacks do not support this.</p>
<p>The platform and software used is as follows:</p>
<ul>
<li>Ubuntu 10.04 LTS standard CLI install;</li>
<li>dahdi-linux-complete-2.4.0 from the archives (<a title="dahdi-linux-complete-2.4.0" href="http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/releases/dahdi-linux-complete-2.4.0+2.4.0.tar.gz">direct link</a>);</li>
<li>a patched version of libss7 supporting SAM via SVN (see below);</li>
<li>a patched version of chan-dahdi via SVN (see below);</li>
<li>Asterisk 1.6.0.28 from the archives (<a href="http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-1.6.0.28.tar.gz">direct link</a>);</li>
<li>Asterisk Addons 1.6.0.6 from the archives (<a href="http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-addons-1.6.0.6.tar.gz">direct link</a>);</li>
<li>Sangoma Wanpipe 3.5.24 (<a href="ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-3.5.24.tgz">direct link</a>).</li>
</ul>
<p><strong>Yes, I know some of the above are obsolete. Unfortunately it&#8217;s what&#8217;s required for everything to play nicely together. And, guess what, it works!</strong></p>
<h3>Before You Start</h3>
<p>Ensure you have all the necessary packages for building the packages:</p>
<pre>apt-get install build-essential libnewt-dev subversion    \
   libsqlite3-dev libsnmp-dev bison libtool flex          \
   autoconf2.13 libmysqlclient-dev</pre>
<p>You can assume the working directory is <em>/usr/local/src</em> in the following.</p>
<h3>Installing dahdi-linux-complete</h3>
<p>Download and extract dahdi-linux-complete into /usr/local/src. Then, in the same directory, create some symbolic links:</p>
<pre>ln -s dahdi-linux-complete-2.4.0+2.4.0/linux dahdi-linux
ln -s dahdi-linux-complete-2.4.0+2.4.0/tools dahdi-tools</pre>
<p>Now build dahdi-linux:</p>
<pre>cd dahdi-linux
make
make install</pre>
<p>Now move onto dahdi-tools:</p>
<pre>cd dahdi-tools
./configure
make menuconfig # (and select tools or accept defaults)
make
make install
make config</pre>
<h3>Installing libss7</h3>
<p>There is a patched version of Digium&#8217;s libss7 referred to as <em>Attila&#8217;s libss7 </em>available via SVN. Download and install it:</p>
<pre>svn co https://observer.router.hu/repos_pub/libss7/trunk alibss7
cd alibss7
make
make install</pre>
<h3>Installing Asterisk</h3>
<p>Download and extract the Asterisk 1.6.0.28 package reference above.</p>
<pre>cd asterisk-1.6.0.28</pre>
<p>Now this next bit <strong>is very important and easy to miss</strong> - you also need a patched version of chan_dahdi.c that is compatible with the patched version of libss7. This is also available from SVN:</p>
<pre>svn co https://observer.router.hu/repos_pub/chan_dahdi/trunk achan_dahdi</pre>
<p>Then copy it to your Asterisk source:</p>
<pre>cp achan_dahdi/chan_dahdi.c asterisk-1.6.0.28/channels/chan_dahdi.c</pre>
<p>Now continue with the Asterisk installation:</p>
<pre>./configure
make menuconfig
make
make install
make samples
make config</pre>
<h3>Install Asterisk Addons (optional)</h3>
<p>Download and unpack the above referenced add ons package and build and install:</p>
<pre>cd asterisk-addons-1.6.0.6
./configure
make menuconfig
make
make install
make samples</pre>
<h3>Sangoma Wanpipe</h3>
<p>I&#8217;m using one of Sangoma&#8217;s E1 / T1 interface cards and so I need Wanpipe also. I&#8217;m using version 3.5.24 and preceed as follows after unpacking:</p>
<pre>cd wanpipe-3.5.24./Setup install</pre>
<p>During the install, follow these prompts:</p>
<ul>
<li>select option 2 =&gt; Asterisk/Dahdi Support;</li>
<li>enter path /usr/local/src/dahdi-linux (for Zaptel path prompt);</li>
<li>select defaults for everything else;</li>
<li>you DO want to install start-up scripts;</li>
<li>you DO to configure wanpipe devices for DAHDI;</li>
<li>you DO want to generate /etc/asterisk/chan_dahdi.conf and:
<ul>
<li>select E1 / T1 as appropriate;</li>
<li>select line framing and encoding;</li>
<li>choose clock source;</li>
<li>select <em>Zaptel/Dahdi &#8211; PRI CPE</em> as signalling;</li>
<li>select <em>National ISDN 2</em> as switch type;</li>
<li>do not enable hardware DTMF detection;</li>
<li>use all channels;</li>
<li>select dial plan context as appropriate;</li>
</ul>
</li>
<li>and continue for other ports as necessary;</li>
<li>finally, choose Save cfg: Stop Asterisk &amp; Wanpipe now</li>
<li>you would like wanrouter to start on system boot;</li>
<li>and you would like to execute &#8216;dahdi_cfg&#8217; each time wanrouter starts.</li>
</ul>
<h3>Configuration Steps</h3>
<p>We now need to set various options in Wanpipe, Dahdi and Asterisk for SS7 as it&#8217;s PRI/ISDN by default.</p>
<p>Edit all <em>/etc/wanpipe/wanpipeX.conf</em> files as necessary and change:</p>
<pre> TDMV_DCHAN              = 16</pre>
<p>to</p>
<pre>TDMV_DCHAN              = 0</pre>
<p>Now edit <em>/etc/dahdi/system.conf</em> and change (for example):</p>
<pre>span=1,1,0,ccs,hdb3,crc4
bchan=1-15,17-31
echocanceller=mg2,1-15,17-31
hardhdlc=16</pre>
<p>to</p>
<pre>span=1,1,0,ccs,hdb3,crc4
bchan=2-31
echocanceller=mg2,2-31
mtp2=1</pre>
<p>which of course assumes signalling is on channel 1. If you have voice only links, you might need something like:</p>
<pre>span=1,0,0,ccs,hdb3,crc4bchan=1-31
echocanceller=mg2,2-31</pre>
<p>Lastly, we need to configure Asterisk. Replace lines such as:</p>
<pre>;Sangoma A102 port 1 [slot:4 bus:5 span:1]
switchtype=national
context=from-pstn
group=0
echocancel=yes
signalling=pri_cpe
channel =&gt;1-15,17-31</pre>
<p>with an appropriate configuration. Mine follows below with some edits and <strong>some important notes at the end</strong>:</p>
<pre>;Sangoma A102 port 1 [slot:4 bus:5 span:1]
switchtype=national
context=from-pstn
group=0
echocancel=yes

signaling=ss7
ss7type=itu
ss7_called_nai=dynamic
ss7_calling_nai=dynamic
ss7_internationalprefix=00
ss7_nationalprefix=0
ss7_subscriberprefix=
ss7_unknownprefix=
linkset=1
pointcode=1
adjpointcode=2
defaultdpc=3
networkindicator=national_spare
cicbeginswith=2
channel=2-31
sigchan=1</pre>
<ul>
<li>Set <em>pointcode, adjpointcode and defaultdpc</em> as appropriate;</li>
<li>set <em>networkindicator</em> as appropriate and ensure it matches the other end (you can see what you’re being sent and what you’re sending via <em>ss7 debug</em>;</li>
<li><em>cicsbeginwith</em> is normally 1 but the telco on my end are starting at 2 – this was <em>groping in the dark</em> diagnostics and issues such as no audio, CICs not in service when both sides claim they are, etc may point to misaligned CICs;</li>
<li>make sure you have configured <em>from-pstn</em> or the appropriate context in your<em>extensions.conf</em>.</li>
</ul>
<h3>Confirming Your Link Is Up</h3>
<p>Now start wanrouter <em>(/etc/init.d/wanrouter start)</em>; dahdi <em>(/etc/init.d/dahdi start);</em> and Asterisk <em>(/etc/init.d/asterisk start)</em>. You should see your link come up via logs available with the <em>dmesg</em> command. Launch the Asterisk console and check the status of your links:</p>
<pre>ast-deg1-1*CLI&gt; ss7 show cics 1
  CIC   DPC  DAHDI        STATE   BLOCKING
    2    3      2         Idle
    3    3      3         Idle
    4    3      4         Idle
    5    3      5         Idle
    6    3      6         Idle
    7    3      7         Idle
    8    3      8         Idle
    9    3      9         Idle
   10    3     10         Idle
   11    3     11         Idle
   12    3     12         Idle
   13    3     13         Idle
   14    3     14         Idle
   15    3     15         Idle
   16    3     16         Idle
   17    3     17         Idle
   18    3     18         Idle
   19    3     19         Idle
   20    3     20         Idle
   21    3     21         Idle
   22    3     22         Idle
   23    3     23         Idle
   24    3     24         Idle
   25    3     25         Idle
   26    3     26         Idle
   27    3     27         Idle
   28    3     28         Idle
   29    3     29         Idle
   30    3     30         Idle
   31    3     31         Idle</pre>
<p>You should now be okay to make test calls.</p>
<h3>Do You Need Professional Support / Consultancy?</h3>
<p>While I will try to respond to comments and questions on this blog, I don’t have the time to provide one on one assistance pro-bono. Professional consultancy on Asterisk and SS7 is available worldwide through my company, <a href="http://www.opensolutions.ie/">Open Solutions</a> with <a href="http://www.opensolutions.ie/about-us/contact">contact details here</a>.</p>
<h3>References</h3>
<p>For posterity, I have added Domjan Attila patched libss7 and chan_dahdi to GitHub:</p>
<ul>
<li><a href="https://github.com/barryo/attila-libss7">https://github.com/barryo/attila-libss7</a></li>
<li><a href="https://github.com/barryo/attila-libss7-chan_dahdi">https://github.com/barryo/attila-libss7-chan_dahdi</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.barryodonovan.com/index.php/2012/01/12/asterisk-ss7-sam-support/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Asterisk SIP Brute Force Attacks on the Rise</title>
		<link>http://www.barryodonovan.com/index.php/2010/09/17/asterisk-sip-brute-force-attacks</link>
		<comments>http://www.barryodonovan.com/index.php/2010/09/17/asterisk-sip-brute-force-attacks#comments</comments>
		<pubDate>Fri, 17 Sep 2010 10:54:44 +0000</pubDate>
		<dc:creator>Barry O'Donovan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Recipes]]></category>
		<category><![CDATA[VoIP]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[sip attacks]]></category>

		<guid isPermaLink="false">http://www.barryodonovan.com/?p=194</guid>
		<description><![CDATA[See my article on the company blog for a discussion on this, and a how to on using Fail2ban to help stop these attacks.]]></description>
			<content:encoded><![CDATA[<p>See my <a href="http://www.opensolutions.ie/blog/2010/09/sip-brute-force-attacks/">article on the company blog</a> for a discussion on this, and a how to on using Fail2ban to help stop these attacks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryodonovan.com/index.php/2010/09/17/asterisk-sip-brute-force-attacks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>chan_ss7, pcap files and 64bit machines</title>
		<link>http://www.barryodonovan.com/index.php/2008/04/28/chan_ss7-pcap-files-and-64bit-machines</link>
		<comments>http://www.barryodonovan.com/index.php/2008/04/28/chan_ss7-pcap-files-and-64bit-machines#comments</comments>
		<pubDate>Mon, 28 Apr 2008 19:01:32 +0000</pubDate>
		<dc:creator>Barry O'Donovan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[VoIP]]></category>
		<category><![CDATA[asterisk chan_ss7 linkedin ss7]]></category>

		<guid isPermaLink="false">http://www.barryodonovan.com/?p=75</guid>
		<description><![CDATA[UPDATE: April 29th 2008 Anders Baekgaard of Dicea ApS (current chan_ss7 maintainers) recommends the following alternative patch. Please note that mtp3d.c will also need to be patched in the same way: --- chan_ss7.c~ 2008-04-03 09:23:56.000000000 +0200 +++ chan_ss7.c 2008-04-29 08:29:20.000000000 &#8230; <a href="http://www.barryodonovan.com/index.php/2008/04/28/chan_ss7-pcap-files-and-64bit-machines">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: April 29th 2008</strong></p>
<p>Anders Baekgaard of <a href="dicea.dk">Dicea ApS</a> (current chan_ss7 maintainers) recommends the following alternative patch. Please note that <code>mtp3d.c</code> will also need to be patched in the same way:</p>
<pre>
--- chan_ss7.c~ 2008-04-03 09:23:56.000000000 +0200
+++ chan_ss7.c  2008-04-29 08:29:20.000000000 +0200
@@ -249,11 +249,12 @@

 static void dump_pcap(FILE *f, struct mtp_event *event)
 {
+  unsigned int sec  = event->dump.stamp.tv_sec;
   unsigned int usec  = event->dump.stamp.tv_usec -
     (event->dump.stamp.tv_usec % 1000) +
     event->dump.slinkno*2 + /* encode link number in usecs */
     event->dump.out /* encode direction in/out */;

-  fwrite(&#038;event->dump.stamp.tv_sec, sizeof(event->dump.stamp.tv_sec), 1, f);
+  fwrite(&#038;sec, sizeof(sec), 1, f);
   fwrite(&#038;usec, sizeof(usec), 1, f);
   fwrite(&#038;event->len, sizeof(event->len), 1, f); /* number of bytes of packet in file */
   fwrite(&#038;event->len, sizeof(event->len), 1, f); /* actual length of packet */
</pre>
<p><strong>END UPDATE: April 29th 2008</strong></p>
<p>A quickie for the Google trolls:</p>
<p>While trying to debug some SS7 Nature of Address (NAI) indication issues, I needed to use chan_ss7&#8242;s &#8216;dump&#8217; feature from the Asterisk CLI. It worked fine but the resultant pcap files always failed with messages like:</p>
<pre>
# tshark -r /tmp/now
tshark: "/tmp/now" appears to be damaged or corrupt.
(pcap: File has 409000-byte packet, bigger than maximum of 65535)
</pre>
<p>After much digging about and head-against-wall banging, I discovered the issue<br />
is with the packet header in the pcap file. It&#8217;s defined by its spec to be:</p>
<pre>
typedef struct pcaprec_hdr_s {
        guint32 ts_sec;         /* timestamp seconds */
        guint32 ts_usec;        /* timestamp microseconds */
        guint32 incl_len;       /* number of octets of packet saved in file */
        guint32 orig_len;       /* actual length of packet */
} pcaprec_hdr_t;
</pre>
<p>chan_ss7 uses the <code>timeval</code> struct defined by system headers to represent ts_sec and ts_usec. But, on 64bit machines (certainly mine), these values are defined as <code>unsigned long</code> rather than <code>unsigned int</code> (presumably as a step to get over the &#8216;year 2038 bug&#8217;). Hence the packet header is all wrong.</p>
<p>An easy solution is the following patch in <code>mtp.h</code>:</p>
<pre>
77a78,90
> /*
>  * The packet header in the pcap file (used for the CLI command 'dump') is
defined so has to
>  * have the two time components as unsigned ints. However, on 64bit
machines, the system
>  * timeval struct may use unsigned long. As such, we use a custom version
here:
>  */
> struct _32bit_timeval
> {
>   unsigned int tv_sec;            /* Seconds.  */
>   unsigned int tv_usec;      /* Microseconds.  */
> };
>
>
>
125c138
<       struct timeval stamp;        /* Timestamp */
---
>       struct _32bit_timeval stamp;        /* Timestamp */
</pre>
<p>There may be a better way &#8211; but this works.</p>
<p>This relates to chan_ss7-1.0.0 from <a href="http://www.dicea.dk/company/downloads">http://www.dicea.dk/company/downloads</a> and I have let them know also. It&#8217;s also a known issue for the Wireshark developers (although I did not investigate in detail to see what their resolution was for the future). See the following thread from 1999:</p>
<ul>
<li> <a href="http://www.ethereal.com/lists/ethereal-dev/199908/msg00065.html">http://www.ethereal.com/lists/ethereal-dev/199908/msg00065.html</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.barryodonovan.com/index.php/2008/04/28/chan_ss7-pcap-files-and-64bit-machines/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nagios Plugin to Check the Status of PRI Lines in Asterisk</title>
		<link>http://www.barryodonovan.com/index.php/2007/11/02/asterisk-pri-nagios</link>
		<comments>http://www.barryodonovan.com/index.php/2007/11/02/asterisk-pri-nagios#comments</comments>
		<pubDate>Fri, 02 Nov 2007 21:15:57 +0000</pubDate>
		<dc:creator>Barry O'Donovan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[Recipes]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://www.barryodonovan.com/index.php/2007/11/02/nagios-plugin-to-check-the-status-of-pri-lines-in-asterisk/</guid>
		<description><![CDATA[I have a number of Asterisk implementations that I keep an eye on that have multiple PRI connections. Knowing if and when they ever go down has the obvious benefits of alerting me to a problem in near real time. &#8230; <a href="http://www.barryodonovan.com/index.php/2007/11/02/asterisk-pri-nagios">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have a number of Asterisk implementations that I keep an eye on that have multiple PRI connections. Knowing if and when they ever go down has the obvious benefits of alerting me to a problem in near real time. But besides that, it allows my customers and I to verify SLAs, track and log issues, etc.</p>
<p>To this end, I have written <a href="http://www.opensolutions.ie/misc/check_asterisk_pri.php.txt">a Nagios plugin</a> which queries Asterisk&#8217;s manager interface and executes the <code>pri show spans</code> CLI command (this is Asterisk 1.4 by the way). The script then parses the output to ascertain whether a PRI is up or not. </p>
<p>The actual code to connect to the manager interface and execute the query is simply:</p>
<pre>
if( ( $astsock = fsockopen( $host, $port, $errno, $errstr, $timeout ) ) === false )
{
    echo "Could not connect to Asterisk manager: $errstr";
    exit( STATUS_CRITICAL );
}

fputs( $astsock, "Action: Login\r\n");
fputs( $astsock, "UserName: $username\r\n");
fputs( $astsock, "Secret: $password\r\n\r\n"); 

fputs( $astsock, "Action: Command\r\n");
fputs( $astsock, "Command: pri show spans\r\n\r\n");

fputs( $astsock, "Action: Logoff\r\n\r\n");

while( !feof( $astsock ) )
{
    $asttext .= fread( $astsock, 8192 );
}

fclose( $astsock );

if( strpos( $asttext, "Authentication failed" ) !== false )
{
    echo "Asterisk manager authentication failed.";
    exit( STATUS_CRITICAL );
}
</pre>
<p>This plugin is hard coded to English and expects to find <code>Provisioned, Up, Active</code> for a good PRI. For example, the Asterisk implementations that support the <code>pri show spans</code> command that I have access to return one of:</p>
<ul>
<li> <code>PRI span 1/0: Provisioned, In Alarm, Down, Active</code> </li>
<li> <code>PRI span 3/0: Provisioned, Up, Active</code> </li>
</ul>
<p>I&#8217;m actually running a slightly older version of Nagios at the moment, version 1.3. To integrate the plugin, first add the following command definition to an appropriate existing or new file under <code>/etc/nagios-plugings/config/</code>:</p>
<pre>
define command{
        command_name    check_asterisk_pri
        command_line    /usr/lib/nagios/plugins/check_asterisk_pri.php \\
             -H $HOSTADDRESS$ -U $ARG1$ -P $ARG2$ -w $ARG3$ \\
             -c $ARG4$ -n $ARG5$
}
</pre>
<p>where <code>$ARG1$</code> is the Asterisk manager username and <code>$ARG2$</code> is the password. <code>$ARG3$</code> and <code>$ARG4$</code> are the warning and critical thresholds respectively whereby if the number of available PRIs reaches one of these values, the appropriate error condition will be set. Lastly, <code>$ARG5$</code> is the number of PRIs the plugin should <string>expect</strong> to find. </p>
<p><strong>NB:</strong> the <code>command_line</code> line above is split for readability but it should all be on the one line.</p>
<p>Now create a test for a host in an appropriate file in <code>/etc/nagios/config/</code>:</p>
<pre>
define service{
        use                             core-service
        host_name                       hostname.domain.ie
        service_description             Asterisk PRIs
        check_command                   check_asterisk_pri!user!pass!2!1!4
}
</pre>
<p>Ensure that your Nagios server has permissions to access the Asterisk server via TCP on the Asterisk manager port (5038 by default). If on a public network, this should be done via stunnel or a VPN for security reasons. </p>
<p>Lastly, you&#8217;ll need a user with the appropriate permissions and host allow statements in your Asterisk configuration (<code>/etc/asterisk/manager.conf</code>):</p>
<pre>
[username]
secret = password
deny=0.0.0.0/0.0.0.0
permit=1.2.3.4/255.255.255.255
read = command
write = command
</pre>
<p>The next version may include support for BRI and Zap FXO ports also. I also plan on a Cacti plug in to show the channels on each PRI (up &#8211; on a call, down, etc). In any case, updates will be posted here.</p>
<p>The plug in can be download from: <a href="http://www.opensolutions.ie/misc/check_asterisk_pri.php.txt">http://www.opensolutions.ie/misc/check_asterisk_pri.php.txt</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryodonovan.com/index.php/2007/11/02/asterisk-pri-nagios/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Sangoma Inconsistancies with Latest Zaptel-1.4</title>
		<link>http://www.barryodonovan.com/index.php/2007/04/08/sangoma-zaptel-patch</link>
		<comments>http://www.barryodonovan.com/index.php/2007/04/08/sangoma-zaptel-patch#comments</comments>
		<pubDate>Sun, 08 Apr 2007 14:52:01 +0000</pubDate>
		<dc:creator>Barry O'Donovan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://www.barryodonovan.com/index.php/2007/04/08/sangoma-zaptel-patch/</guid>
		<description><![CDATA[I&#8217;m on a tight deadline and the last thing I need right now is kernel/Asterisk/Zaptel/Sangoma issues&#8230; This post may just help someone else save some time: When running Sangoma&#8217;s Setup script from their wanpipe-2.3.4-7 release, the following error occurs when &#8230; <a href="http://www.barryodonovan.com/index.php/2007/04/08/sangoma-zaptel-patch">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m on a tight deadline and the last thing I need right now is kernel/Asterisk/Zaptel/Sangoma issues&#8230; This post may just help someone else save some time:</p>
<p>When running Sangoma&#8217;s <tt>Setup</tt> script from their wanpipe-2.3.4-7 release, the following error occurs when it tries to patch the latest zaptel (version 1.4 checked from SVN revision 2399):</p>
<pre>
Enable TDMV DCHAN Native HDLC Support &#038; Patch Zaptel ? (y/n) y

Did NOT find the seached str:chan->writen\[chan->inwritebuf\] = amnt;
search_and_replace(zaptel-base.c) failed
</pre>
<p>Applying the following diff to <tt>Setup</tt> should solve the problem:</p>
<pre>
1c1
&lt; #!/bin/sh
---
&gt; #!/bin/bash
6128c6128
&lt; ZAPTEL_C_SEARCH_STR="chan->writen\[chan->inwritebuf\] = amnt;"
---
&gt; ZAPTEL_C_SEARCH_STR="chan->writen\[res\] = amnt;"
6134c6134
&lt;                       chan->writen[chan->inwritebuf] = amnt;"
---
&gt;                       chan->writen[res] = amnt;"
</pre>
<p>The change from <tt>sh</tt> to <tt>bash</tt> was to overcome the following error:</p>
<pre>
./Setup: 1014: Syntax error: Bad substitution
</pre>
<p>Finally, it looks like Sangoma&#8217;s current wanpipe will not work with linux-2.6.20.x:</p>
<pre>
/usr/src/wanpipe/kdrvtmp/sdla_xilinx.c:636:62: error: macro "INIT_WORK" passed 3 arguments, but takes just 2
/usr/src/wanpipe/kdrvtmp/sdla_xilinx.c: In function ‘wp_xilinx_init’:
/usr/src/wanpipe/kdrvtmp/sdla_xilinx.c:636: error: ‘INIT_WORK’ undeclared (first use in this function)
/usr/src/wanpipe/kdrvtmp/sdla_xilinx.c:636: error: (Each undeclared identifier is reported only once
/usr/src/wanpipe/kdrvtmp/sdla_xilinx.c:636: error: for each function it appears in.)
</pre>
<p>It works fine with linux-2.6.19.x.</p>
<p>I have let Sangoma&#8217;s support team know of these issues so hopefully they&#8217;ll be resolved before anyone has to actually use this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryodonovan.com/index.php/2007/04/08/sangoma-zaptel-patch/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SNMP Polling Cisco AS5300&#8242;s for E1 Channel Usage (with Cacti)</title>
		<link>http://www.barryodonovan.com/index.php/2007/03/31/cacti-as5300-e1-use</link>
		<comments>http://www.barryodonovan.com/index.php/2007/03/31/cacti-as5300-e1-use#comments</comments>
		<pubDate>Sat, 31 Mar 2007 18:45:15 +0000</pubDate>
		<dc:creator>Barry O'Donovan</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://www.barryodonovan.com/index.php/2007/03/31/cacti-as5300-e1-use/</guid>
		<description><![CDATA[This post is as much a reference for myself as it is for others. I had a need today to start graphing E1/PRI channel usage on some Cisco AS5300&#8242;s. The current priority is a simple graphical representation of the actual &#8230; <a href="http://www.barryodonovan.com/index.php/2007/03/31/cacti-as5300-e1-use">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post is as much a reference for myself as it is for others. I had a need today to start graphing E1/PRI channel usage on some Cisco AS5300&#8242;s. The current priority is a simple graphical representation of the actual usage:</p>
<p><img src="http://www.opensolutions.ie/misc/AS5300-Channels-in-Use.png" alt="AS5300 E1 Channels in Use" /></p>
<p>Hopefully at some point over the next couple of weeks I may expand this to other more interesting information such as average call duration, etc that can be useful to diagnosing issues almost as they happen.</p>
<p>The Cacti XML can be found <a href="http://www.opensolutions.ie/misc/cacti_graph_template_as5300_channels_in_use.xml">here</a> and I just posted the same to Cacti&#8217;s own forums <a href="http://forums.cacti.net/viewtopic.php?t=20443">here</a>.</p>
<p>The <a href="http://tools.cisco.com/Support/SNMP/do/BrowseMIB.do?local=en&#038;mibName=CISCO-POP-MGMT-MIB">CISCO-POP-MGMT-MIB</a> provides the MIBs for this information and the ones I specifically used (for my AS5300 which are all identical with 4 E1/PRI ports) are <tt>cpmDS1ActiveDS0s.0.</tt><em>x</em> (or <tt>.1.3.6.1.4.1.9.10.19.1.1.9.1.3.0.</tt><em>x</em>). Replace <em>x</em> with the appropriate port number (0-3) as required.</p>
<p>Explore the available information yourself with:</p>
<p><tt>$ snmpwalk -Os -c &lt;community&gt; &lt;host&gt;   .1.3.6.1.4.1.9.10.19</tt></p>
]]></content:encoded>
			<wfw:commentRss>http://www.barryodonovan.com/index.php/2007/03/31/cacti-as5300-e1-use/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

