randomspam has asked for the wisdom of the Perl Monks concerning the following question:

I will post up my script later, but as a general question.
i have a log that i am tailing using file::tail, that takes line by line and sorts the data into certain queues which are just values then based on them values generates a snmp trap and sends the data off to a server which takes care of that side.
The problem is that randomly there will be an error generated.
FATAL: select() error [] at /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Net/SNMP/Dispatcher.pm line 635.
i am in the process now of putting debugging into the script so that i may see the output and that before it dies.
origannly i thought this was due to the tail missing lines and then passing bad data into the trap, i have since tweaked the tail to be more stable but i would like to eradicate this for good.
but as a general question what sort of things should i be looking at, or things that could help?. i will post up parts of the script soon. :)
Cheers
ADDED
my( $session, $error ); ( $session, $error ) = Net::SNMP->session( -hostname=>'1.1.1.1', -community=>'silly', -port=>162 ); if( length( $session->error())) { print "Session Error $session->error()\n"; return; } my( $result ); $result = $session->trap( -enterprise=>'.3.1.4.1.5', -specifictrap=>1000, -varbindlist=>['.3.1.4.1.5', UNSIGNED32, $resu +lt{1}, '.3.1.4.1.5', UNSIGNED32, $resu +lt{2}, '.3.1.4.1.5', UNSIGNED32, $resu +lt{3}, '.3.1.4.1.5', UNSIGNED32, $resu +lt{4}, '.3.1.4.1.5', UNSIGNED32, $resu +lt{5}, '.3.1.4.1.5', UNSIGNED32, $resu +lt{6}, '.3.1.4.1.5', UNSIGNED32, $resu +lt{7}, '.3.1.4.1.5', UNSIGNED32, $resu +lt{8} ] ); if (!defined($result)) { printf ("SCript error: %s.\n", $session->error); $session->close; return; } $result = $session->trap( -enterprise=>'.1.3.6.1.3.42', -specifictrap=>999, -varbindlist=>['.3.1.4.1.5', UNSIGNED32, $resu +lt{9}, '.3.1.4.1.5', UNSIGNED32, $resu +lt{10}] ); if (!defined($result)) { printf("ERROR: %s.\n", $session->error); $session->close; return; } $session->close(); }
this has been changed so normally the values are unique and all that :P
That is how the snmp traps are generated.. and i cant seem to put a finger on why the dispatcher module throws an error

Replies are listed 'Best First'.
Re: SNMP Trap Help
by shmem (Chancellor) on Mar 22, 2007 at 09:11 UTC
    but as a general question what sort of things should i be looking at, or things that could help?
    Well, you should be looking at line 635 of /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/Net/SNMP/Dispatcher.pm, that could give you a clue.

    Without myself having done so, I suspect some network error (timeout?). So, something that could help - wrap your $session->trap calls into a block eval:

    my $result; eval { local $SIG{__DIE__}; $result = $session->trap( -enterprise=>'.1.3.6.1.3.42', ... ); } if($@) { warn "error calling \$session->trap(): $@\n"; }

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: SNMP Trap Help
by randomspam (Initiate) on Mar 22, 2007 at 09:50 UTC
    thankz for your advice
    what issues do i have to look into if i just warn about it and then close the session and continue with tailing the file. this script runs continously, then maybe shutdown and restart the script again every 24 hours.
    cheers