Debugging pass scripts

From Net-SNMP Wiki
Revision as of 09:41, 30 March 2012 by Rstory (Talk | contribs) (check script permissions)

Jump to: navigation, search

If your pass script isn't working, here are a few things you can try:

check script permissions

Make sure that the script is executable.

chmod a+x /tmp/my_script

check for SELinux restrictions

On Linux systems with SELinux enabled, the script must have the right context. You can check for SELinux access violations with

grep AVC /var/log/audit/audit.log | grep snmp

check access control

Pass scripts generally fall in the enterprises branch. Some vendors default snmpd configuration do not include this branch. To see if you can see any objects in the enterprises branch, try this command:

snmpgetnext -On -v 1 -c public localhost .1.3.6.1.4.1

If you get back an object that starts with .1.3.6.1.4.1, then you should be ok.

turn on debugging

Try running snmpd in the foreground, with debugging

snmpd -f -Lo -Ducd-snmp/pass

which should result in debug output something like

 ucd-snmp/pass: pass-running:  /bin/sh /tmp/my_script -g .1.3.6.1.4.1.2021.224

touch a temporary file

At the top of your script, touch a temporary file. You can check the time stamp of the temporary file to see if the script is run. A simple example:

#!/bin/bash

echo "$0 run at `date`" >> /tmp/my_script.debug

# handle pass arguments
# ...