NAME

SNMPMonitor - Perl extension for writing SNMP Monitors

SYNOPSIS

use SNMPMonitor;
my $monitor = SNMPMonitor->new ($root_oid);

DESCRIPTION

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'

EXPORT

None by default. It's an object...

Writing Plugins

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__'

Plugin Template

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__

SEE ALSO

Net-SNMP Documentation

Caveats

Currently, there are some, but I don't remember right now. Something about something... Good, I know right?

AUTHOR

Jon, <Jon@localdomain>

COPYRIGHT AND LICENSE

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.