Nms-trapReceiver: Difference between revisions

From I Will Fear No Evil
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 22: Line 22:
# using an eval (shudder) do our pre-processing now before inserting into the database
# using an eval (shudder) do our pre-processing now before inserting into the database
# insert event into the database
# insert event into the database
# Do any postprocessing now (should not be any TBH)
# Do any post-processing now (should not be any TBH)
# Dump our vars to stdout
# Dump our vars to stdout and syslog


[[Category:NMS]]
[[Category:NMS]][[Category:PHP]]

Revision as of 17:39, 17 February 2024

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 post-processing now (should not be any TBH)
  13. Dump our vars to stdout and syslog