Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with traphandlers in NET-SNMP

Status
Not open for further replies.

kaleb500

Programmer
Jul 20, 2012
2
GB
Hello.

I'm currently having issue getting trap handling to work. My snmptrapd.conf is as follows:

# Example configuration file for snmptrapd
#
# No traps are handled by default, you must edit this file!
#
authUser log,execute,net rwlatis

# the generic traps
traphandle default /usr/bin/reboot

logoption s 2
logoption f /var/log/snmptrapd-direct.log

To start with I'm just trying to execute the reboot script (before I move onto writing my own script). I am testing it by sending the following arbitrary inform using the command:

snmpinform -v 3 -u rwlatis -l authPriv -a SHA -A "trustno1" -x AES -X "trustno1" -l authPriv localhost 1 SNMPv2-MIB::coldStart

Now I know the trap is getting through OK because it logs it to the file ‘/var/log/snmptrapd-direct.log’ which has the following output:

NET-SNMP version 5.5
2012-07-20 14:59:56 localhost [UDP: [127.0.0.1]:55481->[127.0.0.1]]:
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1) 0:00:00.01 SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-MIB::coldStart

So I’m assuming I’ve set the user account up properly. It just won't do the 'execute'. I've also ran snmptrapd using the debug flag. The following is a section of the output:

...
...
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1) 0:00:00.01 SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-MIB::coldStart
trace: snmp_input(): snmptrapd_handlers.c, 1039:
snmptrapd: Running trap specific handlers
trace: netsnmp_get_traphandler(): snmptrapd_handlers.c, 551:
snmptrapd:lookup: Looking up Trap OID: SNMPv2-MIB::coldStart
trace: netsnmp_get_traphandler(): snmptrapd_handlers.c, 602:
snmptrapd:lookup: get_traphandler default (0x14df408)
trace: netsnmp_trapd_check_auth(): snmptrapd_auth.c, 166:
snmptrapd:auth: Comparing auth types: result=56, request=16, result=1
trace: command_handler(): snmptrapd_handlers.c, 788:
snmptrapd: command_handler
trace: command_handler(): snmptrapd_handlers.c, 789:
snmptrapd: token = '/usr/bin/reboot'
trace: netsnmp_ds_set_boolean(): default_store.c, 205:
netsnmp_ds_set_boolean: Setting LIB:13 = 1/True
trace: command_handler(): snmptrapd_handlers.c, 826:
snmptrapd: execute format
trace: sprint_realloc_by_type(): mib.c, 1961:
output: sprint_by_type, type 67
trace: run_shell_command(): mibgroup/utilities/execute.c, 55:
run_shell_command: running /usr/bin/reboot
trace: run_shell_command(): mibgroup/utilities/execute.c, 56:
run:shell: running '/usr/bin/reboot'
trace: netsnmp_ds_set_string(): default_store.c, 283:
netsnmp_ds_set_string: Setting LIB:15 = "/var/run/net-snmp/snmp-tmp-XXXXXX"
trace: netsnmp_mktemp(): system.c, 1264:
netsnmp_mktemp: temp file created: /var/run/net-snmp/snmp-tmp-Hglejk
trace: netsnmp_ds_set_boolean(): default_store.c, 205:
netsnmp_ds_set_boolean: Setting LIB:13 = 0/False
trace: snmp_input(): snmptrapd_handlers.c, 1039:
...
...

Judging by the line ‘run:shell: running '/usr/bin/reboot'’ it looks like it’s trying to execute the reboot script. It just doesn't seem to work. I've tried executing a few other things, like an executable and shell script too, but with the same result.

If anyone has any ideas I’d be very grateful. I feel like I’ve hit a brickwall

Thanks

Stuart
 
Update

I've discovered it works fine if I start snmptrapd from the command line. It doesn't work when it runs as a service. I would prefer to run it as a service. Any idea why running as a service effects the 'execute' function? Something to do with permissions?
 
In my experience there is a lot of weirdness when it comes to processes running as services on Windows.

Might want to google this or check net-snmp forums for similar issues.

Bill



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top