Nms-trapReceiver

From I Will Fear No Evil
Revision as of 15:06, 15 October 2021 by Chubbard (talk | contribs)
Jump to navigation Jump to search

This script: trapReceiver.php is not part of the API spec, and is however part of the overall system. This is what snmptrapd calls for all inbound SNMP events.

Specifically note the absolute path to the php script. Also it is a good idea to pass the path to the php binary itself as well since snmptrapd does not build a full environment.

cat /etc/snmp/snmptrapd.conf | grep -v '^#'
snmpTrapdAddr :162
traphandle .1.* php /opt/nmsApi/traps/trapReceiver.php
disableAuthorization yes

The trap reciever itself is kind of brainless.

  1. receive event
  2. connect to database
  3. begin setting defaults and datestamps
  4. iterate over trap oids and start filtering and building arrays
  5. sanitize the arrays
  6. reindex the arrays so there are no gaps
  7. JSON encode the array
  8. Search for existing database hostname that matches our event
  9. Map our raw oid values to pretty names
  10. using an eval (shudder) do our pre-processing now before inserting into the database
  11. insert event into the database
  12. Do any postprocessing now (should not be any TBH)
  13. Dump our vars to stdout