Template:FAQ:Applications 18

From Net-SNMP Wiki
Jump to: navigation, search

If a traphandler script works fine when run manually from the command line, but fails or generates an error when triggered by an incoming notification, then there are two likely causes.

Firstly, the interactive shell environment may not be precisely the same as that for programs executed by the snmptrapd daemon. In particular, it's quite possible that the PATH environmental variable may not include all the additional directories that are commonly set up for a personal login configuration. To avoid this problem (particularly for traphandler shell scripts), it's worth giving the full path to all programs used within the script.

Secondly, the snmptrapd daemon may not always recognise the appropriate interpreter to use for a particular trap handler. If this is the case, then you can specify this interpreter explicitly as part of the trap handle directive:

       traphandle default /usr/bin/perl /usr/local/bin/log_it

In this case, it's almost certain that you'll also need to give the full path to the traphandle script (as shown)