SNMPMonitor - Perl extension for writing SNMP Monitors
use SNMPMonitor; my $monitor = SNMPMonitor->new ($root_oid);
This module is designed to allow easy creation of custom SNMP monitors by using a pluggable architecture. By far, the easiest way to implement this module is to include the following lines in /etc/snmpd.conf
perl use SNMPMonitor; perl my $monitor = SNMPMonitor->new;
This will include all plugins in $INSTALLDIR/SNMPMonitor/Plugin/
You may, however, use the above toinitialize the module from a script and simply include this script in /etc/snmpd.conf (obviously, omit the 'perl'):
perl do '/path/to/script.pl'
None by default. It's an object...
Plugins are self containd Perl scripts. There are five basic requirements, as long as these are met, anything is possible.
Requirements,
-Package Name that matches the file name -isa relationship with SNMPMonitor::Plugin -sub set_plugin_oid -sub monitor -module returns a true value and ends with '__END__'
listing: PluginTemplate.pm package SNMPMonitor::Plugin::PluginTemplate; use common::sense; use NetSNMP::ASN (':all'); use parent qw(SNMPMonitor::Plugin); sub set_plugin_oid { '0.0.0' }; sub monitor { my $self = shift; my $request = shift; my $FH = shift || 'STDERR'; # Print some debug output, optional print $FH "--> Request in: " . $self->name . "\n"; print $FH "--> reporting 'Test Successful'\n"; $request->setValue(ASN_OCTET_STR, "Test Successful"); } 1; __END__
Net-SNMP Documentation
Currently, there are some, but I don't remember right now. Something about something... Good, I know right?
Jon, <Jon@localdomain>
Copyright (C) 2011 by Jon
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install SNMPMonitor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SNMPMonitor
CPAN shell
perl -MCPAN -e shell install SNMPMonitor
For more information on module installation, please visit the detailed CPAN module installation guide.