I have a Ubuntu server which is collecting incoming SNMP traps. Currently these traps are handled and logged using a PHP script.file /etc/snmp/snmptrapd.conftraphandle default /home/svr/00-VHOSTS/nagios/scripts/snmpTrap.phpThis script is quite long and it contains many database operations. Usually the server receives thousands of traps per day and therefore this script is taking too much CPU time. My understand is this is due to high start-up cost of the php script every-time when a trap received.I got a request to re-write this and I was thinking of running this script as a daemon. I can create an Ubuntu daemon. My question is how can I pass  trap-handler to this daemon using snmptrapd.conf file?Thank you in advance.
Pass SNMP trap packet to a php daemon on Ubuntu
ubuntu;php;daemon;snmp
While your question actually confused me, I believe you should move away from using a php script to handle the snmptrapd service.That file (/etc/snmp/snmptrapd.conf), is used by the snmptrapd service which can be enabled at whatever run level you wish (3, 4, 5) and can be configured to log traps to MySQL, so there is no need to create a separate daemon.On another note perhaps a small shell script would be more efficient than trying to handle the trap by initializing the PHP interpreter, loading the SNMP, MySQL & additional extensions. Here is a simple example, though you would definitely need to add the database handling (which you can use my examples to accomplish).With that being said if you still wish to implement a solution with PHP you should probably research the available SNMP extension for PHP