Page 1 of 1
Performing SNMP set requests in Nagios
Posted: Wed Nov 16, 2016 6:31 am
by hornseym
Hi,
I'm new to Nagios and hoping to use it in a system that uses SNMP.
Can Nagios (Core or XI or some other variant/extension/plugin) be used to make SNMP SetRequests?
I've been searching for a while, here and on Google, and I can't seem to find anything (apologies in advance if I just missed it). Are SetRequests missing because Nagios is a purely monitoring tool?
Thanks.
Re: Performing SNMP set requests in Nagios
Posted: Wed Nov 16, 2016 11:35 am
by rkennedy
I haven't seen much talk of it, but because Nagios is generally used as a frame work, it should be possible since snmpset will just be executed from the CLI.
I don't know of an exact use case that would make this beneficial, but it should be possible.
There was a pretty good presentation done with more info about SNMP that may help you out -
https://assets.nagios.com/presentations ... lugins.pdf
Re: Performing SNMP set requests in Nagios
Posted: Thu Nov 17, 2016 3:47 am
by hornseym
Thanks for the response...
The specific use case is to update the logging level (e.g. error to debug) of specific services within our system so that, if they're found to be misbehaving, support engineers can get more information into the log files. We already have SNMP in the system (for monitoring) so thought updating the logging levels via an SNMP SetRequest would be easiest. As you can imagine, this would likely be an ad hoc request.
I had thought of writing a plugin to do this and there were a couple of issues to overcome:
1. How to get a user input (the requested logging level) to a plugin.
2. How to do the requests ad hoc when, as I understand it, plugins are called periodically.
I thought that, before I went on to solve these, I would check with the Nagios community to see if there was an obvious solution I was missing with inexperience of the system...
Thanks.
Re: Performing SNMP set requests in Nagios
Posted: Thu Nov 17, 2016 11:17 am
by rkennedy
I think your use case sounds like something Nagios would be able to do, will take some slight scripting, but how far you go is up to you.
1. Start off with a bash script, something like -
Code: Select all
#!/bin/sh
/usr/bin/snmpset $1 $2 $3 $4 $5
This will tell it to take whatever input is passed as the first 5 variables, and send it straight to the snmpset application. So, running myscript.sh hello world how are you would be interpreted as /usr/bin/snmpset hello world how are you. (you could use quotes to make $1 encapsulate a string, but that's more into bash programming.)
2. Plugins are periodic, but you could use event handlers to trigger based on the state a service is in. For your use case, have it trigger every time a state is switched to CRITICAL. See this doc (for XI, but concepts apply still, just different ways of applying it with Core) -
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Assuming your logging is going to syslog / messages, engineers will be able to continue looking at the logs as they normally would, but with a higher level.
Re: Performing SNMP set requests in Nagios
Posted: Fri Nov 18, 2016 10:23 am
by hornseym
I hadn't come across event handlers yet, thanks for that; I'll give that a go and see what happens.
Thanks
Re: Performing SNMP set requests in Nagios
Posted: Fri Nov 18, 2016 11:01 am
by dwhitfield
Awesome! Be aware that our Fridays end at 2pm US Central, so if you need more help today, please make sure you get us a response before then.