×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problem with traphandlers in NET-SNMP

Problem with traphandlers in NET-SNMP

Problem with traphandlers in NET-SNMP

(OP)
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

RE: Problem with traphandlers in NET-SNMP

(OP)
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?

RE: Problem with traphandlers in NET-SNMP

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



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close