So I have everything sorted out and figured I'd post what I ended up doing to get Net-SNMP to log everything and have a traphandle trigger an event which is my custom perl script:
Requirements
Code:
Net-SNMP (Only need to use snmptrapd)
Perl
File::ReadBackwards Perl module from CPAN
snmptrapd.conf
snmppl (custom script)
My snmptrapd.conf contains:
Code:
disableAuthorization yes
traphandle default /usr/local/bin/snmppl
My /usr/local/bin/snmppl contains:
Code:
#!/usr/bin/perl
use File::ReadBackwards;
$bw = File::ReadBackwards->new( '/var/log/everything/current' ) or die "can not read $!";
$errString = $bw->readline;
print "$errString\n";
if ($errString =~ /Switched to battery backup power/) {
print "Switched to battery power\n";
system "shutdown -h +2";
} elsif ($errString =~ /Returned from battery backup power/) {
print "Power returned switching off battery power\n";
system "shutdown -c";
}
if ($errString =~ /configuration/) {
print "Config change\n";
} Edited /etc/conf.d/snmptrapd :
Code:
SNMPTRAPD_FLAGS="-Lf /var/log/snmptrapd.out"
Then I added it to my start up:
Code:
rc-update -a snmptrapd default
And I ended up finding the OID:
1.3.6.1.4.1.318.2.3.3.0 being the full oid with object for the msg
SNMPv2-SMI::enterprises.318.2.3.3.0 same but named
1.3.6.1.4.1.318 just the root OID
When I changed data I got this and every message has the same OID just the STRING changes:
SNMPv2-SMI::enterprises.318.2.3.3.0 = STRING: "System: SNMP configuration change. SNMP trap receiver 4 address."
I hope this helps some one, took way longer to sort all this out then it should of. I know it's not perfect but it works.