Feb 05

We regularly get customer requests to write snmp checks for their devices but a problem we have is we don’t necessarily get access to those devices – 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.

This doesn’t sit very well with me as I don’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?

Well, there is a better way, by using SNMP::Persist

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:

#!/usr/bin/perl
use strict;
use warnings;
use SNMP::Persist qw(&define_oid &start_persister &define_subtree);
define_oid(".1.3.6.1.4.1.123.123"); # base of OID tree
start_persister();
while (1) {
 # define all sub OIDS within the base to respond to
 define_subtree(
 { '1.1' => [ 'STRING', 'string value' ],
 '1.2' => [ 'INTEGER', 9 ],
 '1.3' => [ 'Counter32', 342.3 ],
 }
 );
 sleep 300;
}

and then add an entry to your snmpd.conf such as

pass_persist .1.3.6.1.4.1.123.123 /path/to/perl/script

After restarting your snmpd agent you should now be able to query the oids

$ snmpwalk -v2c -c public localhost .1.3.6.1.4.1.123.123

While the above isn’t in a fit state to use for TAP tests, it shouldn’t take too much imagination to extend it by using ‘pass’ instead of ‘pass_persist’ in NET::SNMP in a small server started when running the project tests.

Leave a Reply

Opsview © Opsera Limited 2010 All Rights Reserved
Nagios © 1999-2009 Ethan Galstad. Respective copyrights apply to third party source code
Opsview is a registered trademark of Opsera Limited. Nagios is a registered trademark of Nagios Enterprises. All Rights Reserved
preload preload preload