<?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>Opsview Labs &#187; SNMP agent</title>
	<atom:link href="http://labs.opsview.com/tag/snmp-agent/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.opsview.com</link>
	<description>Opsview&#039;s Engineering Blog</description>
	<lastBuildDate>Fri, 20 Jan 2012 09:32:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mocking an SNMP agent and developing SNMP checks</title>
		<link>http://labs.opsview.com/2010/02/mocking-an-snmp-agent-and-developing-snmp-checks/</link>
		<comments>http://labs.opsview.com/2010/02/mocking-an-snmp-agent-and-developing-snmp-checks/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 17:02:16 +0000</pubDate>
		<dc:creator>Duncs</dc:creator>
				<category><![CDATA[Opsview]]></category>
		<category><![CDATA[checks]]></category>
		<category><![CDATA[SNMP agent]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/2010/02/mocking-an-snmp-agent-and-developing-snmp-checks.html</guid>
		<description><![CDATA[
			
				
			
		We regularly get customer requests to write snmp checks for their devices but a problem we have is we don&#8217;t necessarily get access to those devices &#8211; in the past we have used output from an snmpwalk command and written the check scripts as best we can, and then shipped the new check to the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F02%2Fmocking-an-snmp-agent-and-developing-snmp-checks%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F02%2Fmocking-an-snmp-agent-and-developing-snmp-checks%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>We regularly get customer requests to write snmp checks for their devices but a problem we have is we don&#8217;t necessarily get access to those devices &#8211; in the past we have used output from an snmpwalk command and written the check scripts as best we can, and then shipped the new check to the customer for testing.
<span id="more-76"></span>
This doesn&#8217;t sit very well with me as I don&#8217;t think this gives a good customer experience.  Why should the customer do the testing when they have paid us to write the code?  How much time and effort has the customer got to put in to then get all debug data back to us to improve the check?</p>
<p>Well, there is a better way, by using <a title="CPAN - SNMP::Persist" href="http://search.cpan.org/%7Eanias/SNMP-Persist-0.05/">SNMP::Persist</a></p>
<p>The snmpd agent on most unix type systems can be extended such that a script can be used to respond to all snmp requests for a particular oid tree.  This can be done by creating a script such as this:
<span style="font-family: Courier;"> </span></p>
<pre><span style="font-size: 11px; font-family: Courier;">#!/usr/bin/perl</span>
<span style="font-size: 11px; font-family: Courier;">use strict;</span>
<span style="font-size: 11px; font-family: Courier;">use warnings;</span>
<span style="font-size: 11px; font-family: Courier;">use SNMP::Persist qw(&amp;define_oid &amp;start_persister &amp;define_subtree);</span>
<span style="font-size: 11px; font-family: Courier;">define_oid(".1.3.6.1.4.1.123.123"); # base of OID tree</span>
<span style="font-size: 11px; font-family: Courier;">start_persister();</span>
<span style="font-size: 11px; font-family: Courier;">while (1) {</span>
<span style="font-size: 11px; font-family: Courier;"> # define all sub OIDS within the base to respond to</span>
<span style="font-size: 11px; font-family: Courier;"> define_subtree(</span>
<span style="font-size: 11px; font-family: Courier;"> { '1.1' =&gt; [ 'STRING', 'string value' ],</span>
<span style="font-size: 11px; font-family: Courier;"> '1.2' =&gt; [ 'INTEGER', 9 ],</span>
<span style="font-size: 11px; font-family: Courier;"> '1.3' =&gt; [ 'Counter32', 342.3 ],</span>
<span style="font-size: 11px; font-family: Courier;"> }</span>
<span style="font-size: 11px; font-family: Courier;"> );</span>
<span style="font-size: 11px; font-family: Courier;"> sleep 300;</span>
<span style="font-size: 11px; font-family: Courier;">}</span></pre>
<p>and then add an entry to your snmpd.conf such as</p>
<p><span style="font-size: 13px; font-family: Arial;"><span style="font-size: 11px; font-family: Courier;">pass_persist .1.3.6.1.4.1.123.123 /path/to/perl/script</span></span></p>
<p>After restarting your snmpd agent you should now be able to query the oids</p>
<p style="font-size: 11px; font-family: Courier;"><span style="font-size: 13px;">$ snmpwalk -v2c -c public localhost </span><span style="font-size: 13px;"><span style="font-size: 11px;">.1.3.6.1.4.1.123.123</span></span></p>
<p>While the above isn&#8217;t in a fit state to use for <a title="Description of TAP tests" href="http://en.wikipedia.org/wiki/Test_Anything_Protocol">TAP tests</a>, it shouldn&#8217;t take too much imagination to extend it by using &#8216;pass&#8217; instead of &#8216;pass_persist&#8217; in NET::SNMP in a small server started when running the project tests. </p>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2010/02/mocking-an-snmp-agent-and-developing-snmp-checks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

