I have to receive snmptraps in php script, so what i've done is:
snmptrapd.conf
traphandle 1.3.6.1.4.1.3.1.1 /usr/home/user/trap/l.php
l.php
#!/usr/local/bin/php
<?php
$flow = fopen("php://stderr","r");
while(!feof($flow)){
file_put_contents("out",fread($flow,1024)."\n", FILE_APPEND);
}
?>
then i start snmptrapd like this:
snmptrapd -Le -f
and generated traps like this:
snmptrap -v 1 -c public localhost '' localhost 6 1 ''
snmptrapd gives me such output
2012-01-16 14:38:49 127.0.0.1(via UDP: [127.0.0.1]:11478->[0.0.0.0]:0) TRAP, SNMP v1, community public
SNMPv2-SMI::enterprises.3.1.1 Enterprise Specific Trap (1) Uptime: 70 days, 1:03:57.00
so it seems working... but the problem is that l.php is not executed, or there's nothing in stderr - i can't realize.
please, where's my mistake?