Mark Swayne wrote:
> I'm trying to get a pass_persist based extension working with my 
> Net-SNMP install.
>
> I have the handler registered in snmpd.conf:
>
> pass_persist  .1.3.6.1.4.1.9999 /usr/local/bin/test.pl
>
> After the PING/PONG response, the code seems to get an EOF and the input 
> reception loop terminates:
>   
<SNIP>

> I am running Net-SNMP version 5.4.1 on an Ubuntu 8.10 system.  Perl is 
> version 5.8.8.
>   
I found the problem--for future reference, here is the solution:

After looking at pass_persist.c and debugging output in the logs, I 
found that my PONG output from my script was being ignored/incorrectly 
interpreted by snmpd.

This lead me to suspect that there were some shenanigans going on with 
character encoding.  Adding explicit encoding to my Perl solved the issue:
binmode(STDIN, ':bytes');
binmode(STDOUT, ':bytes');

In addition, it is important to disable buffering on the output of your 
Perl. 
If your handler hangs after acknowledging the snmpd's PING command, the 
problem is probably due to the way STDOUT is buffered changes based on 
how a program is called.  When called from a tty, STDOUT is line 
buffered, otherwise it is block buffered.  So you either need to flush 
it manually or just disable buffering by setting  $| = 1;

--Mark Swayne

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to