Net-SNMP, traphandlers and TrapOIDs.... - SNMP

This is a discussion on Net-SNMP, traphandlers and TrapOIDs.... - SNMP ; Hi all, For some time now, I've been using Net-SNMP to receive traps from various bit of network kit. I've written numerous trap handlers (mainly in PHP these days, but I still have some older ones in Rexx), and added ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Net-SNMP, traphandlers and TrapOIDs....

  1. Net-SNMP, traphandlers and TrapOIDs....

    Hi all,

    For some time now, I've been using Net-SNMP to receive traps from
    various bit of network kit. I've written numerous trap handlers
    (mainly in PHP these days, but I still have some older ones in Rexx),
    and added them along with OIDs to
    /usr/local/share/snmp/snmptrapd.conf. I have a default traphandler,
    which does nothing but echo its STDIN into an email to me. So far so
    good.

    I'm currently trying to build a replacement box, as my old one is
    getting quite long in the tooth and the hardware is now quite
    unreliable (!). I've built Net-SNMP v5.1 on Linux (Slakware 8.0 with
    Kernel 2.4.5). I have installed PHP-4.3.4 and Rexx-IMC 1.75.
    I've written traphandlers in PHP and Rexx, and updated the
    snmptrapd.conf file, adding a default traphandler (again, a dumb,
    repeat-to-email script - both in PHP and Rexx (code samples below).

    The problem is, I don't seem to be getting TrapOIDs out of Net-SNMP,
    with the consequence that the custom-written traphandlers are never
    being called. I've removed all the traphandle directives, just
    leaving the default, but even in that,the TrapOID is not shown.

    Any ideas where I'm going wrong?

    TIA
    Steve


    PHP default trap handler follows:
    #!/usr/local/php/bin/php
    $lines = file('php://stdin','r');
    $message = "";
    $subject = $lines[0] . " *trap*";
    for($loop=0; $loop < count($lines); $loop++)
    $message .= $loop . ": " . $lines[$loop];
    $message .= "This email brought to you by trap.default.php";
    $mailrc=mail("trap", $subject, $message);
    if(!$mailrc)
    echo "Couldn't send mail";
    ?>

    Rexx default trap handler follows:
    #!/usr/local/bin/rexx
    /* */
    linefeed=x2c("0A")
    data.=""
    count=1
    do forever
    parse pull snmpdata
    if snmpdata="" then leave
    data.count=snmpdata
    count=count+1
    end

    subject=data.1" trap.linkdefault"
    pr=popen("mail -s '"subject"' email@server","w",fpmail)
    do loop=1 to count-1
    pr=lineout(fpmail,loop": "data.loop)
    end
    pr=lineout(fpmail,count": This email brought to you by
    trap.default.rx")
    pr=pclose(fpmail)

    exit

  2. Re: Net-SNMP, traphandlers and TrapOIDs....

    Steve wrote:
    > The problem is, I don't seem to be getting TrapOIDs out of Net-SNMP,
    > with the consequence that the custom-written traphandlers are never
    > being called. I've removed all the traphandle directives, just
    > leaving the default, but even in that,the TrapOID is not shown.


    > Any ideas where I'm going wrong?


    It is not you going wrong, it is Net-SNMP. We are right now gearing up
    for a 5.1.1 release where this (among other things) have been fixed. You
    may want to try out the 5.1.1.pre1 that is currently available on
    SourceForge.

    /Niels

    --
    Niels Baggesen -- @home -- Århus -- Denmark -- niels@baggesen.net
    The purpose of computing is insight, not numbers -- R W Hamming

  3. Re: Net-SNMP, traphandlers and TrapOIDs....

    On Mon, 23 Feb 2004 17:54:45 +0000 (UTC), nba@users.sourceforge.net
    (Niels Baggesen) wrote:

    >Steve wrote:
    >> The problem is, I don't seem to be getting TrapOIDs out of Net-SNMP,
    >> with the consequence that the custom-written traphandlers are never
    >> being called. I've removed all the traphandle directives, just
    >> leaving the default, but even in that,the TrapOID is not shown.

    >
    >> Any ideas where I'm going wrong?

    >
    >It is not you going wrong, it is Net-SNMP. We are right now gearing up
    >for a 5.1.1 release where this (among other things) have been fixed. You
    >may want to try out the 5.1.1.pre1 that is currently available on
    >SourceForge.
    >
    >/Niels


    Thanks for the swift reply, Niels! That'll be my 1st job for this
    morning then :-)

    Steve


+ Reply to Thread