Find the answer to your Linux question:
Results 1 to 6 of 6

Thread: Net-SNMP

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1


    I've installed net-snmp in hopes to be able to capture the SNMP messages sent out by our UPS on our nix/win boxes in case of power failure. Is there a way to log all snmp traffic sent? In windows with loriotpro the message I get is:

    <0> americanpower () for agent from proxy [] ups: switched to battery backup power.

    I'm really confused on how to make a trap for this and I thought if I could at least log everything I could sort through to find the data I need. I tried Net-SNMP in windows but got the same results.

  2. #2
    Well i always recommend Ntop for such issues. U have one machine sniffing all the packets and u can see the whole network's throughput. in both graphs and pie charts.
    All the best

  3. #3
    I'll give it a shot. It wouldn't be so hard if there was some short of shell/gui on the boxes so I could use some of the many available apps but they are just bare essential installs of gentoo.

    I ended up writing a program to ssh from win into nix and shutdown that way which is not my preferred method.
    Last edited by minutemaid; 11-21-2007 at 08:44 PM. Reason: added more to the post

  4. $spacer_open
  5. #4
    ntop is nice but it doesn't have working snmp logging yet:
    "SNMP support disabled or not available"

    Wish there was a better net-snmp guide out there. The ones they provide are good but the trap testing part is too vague for me to follow

  6. #5
    When the UPS send out its messages it works in windows but in linux I get:
    <28>Nov 26 11:13:23 snmptrapd[8224]: No access configuration - dropping trap.

    traphandle default /usr/local/bin/Hello
    traphandle public /usr/local/bin/Hello
    traphandle "default" /usr/local/bin/Hello
    traphandle "public" /usr/local/bin/Hello
    traphandle americanPower. /usr/local/bin/Hello

  7. #6
    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:

    Net-SNMP (Only need to use snmptrapd)
    File::ReadBackwards Perl module from CPAN
    snmppl (custom script)
    My snmptrapd.conf contains:
    disableAuthorization yes
    traphandle default /usr/local/bin/snmppl
    My /usr/local/bin/snmppl contains:
    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 :
    SNMPTRAPD_FLAGS="-Lf /var/log/snmptrapd.out"
    Then I added it to my start up:
    rc-update -a snmptrapd default
    And I ended up finding the OID: being the full oid with object for the msg
    SNMPv2-SMI::enterprises.318. same but named 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. = 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts