<?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>The thoughts, ramblings and rants of Barry O&#039;Donovan</description>
	<lastBuildDate>Wed, 09 Dec 2009 14:30:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<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]]></category>
		<category><![CDATA[chan_ss7]]></category>
		<category><![CDATA[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 +0200 @@ -249,11 +249,12 @@ static void dump_pcap(FILE *f, struct mtp_event *event) { + unsigned [...]]]></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. But besides that, it allows my customers and I to verify SLAs, track and log [...]]]></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 it tries to patch the latest zaptel (version 1.4 checked from SVN revision 2399): Enable [...]]]></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 usage: Hopefully at some point over the next couple of weeks I may expand this [...]]]></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>
