Performing SNMP set requests in Nagios

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
hornseym
Posts: 13
Joined: Wed Nov 16, 2016 6:21 am

Performing SNMP set requests in Nagios

Post 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Performing SNMP set requests in Nagios

Post 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
Former Nagios Employee
hornseym
Posts: 13
Joined: Wed Nov 16, 2016 6:21 am

Re: Performing SNMP set requests in Nagios

Post 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Performing SNMP set requests in Nagios

Post 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.
Former Nagios Employee
hornseym
Posts: 13
Joined: Wed Nov 16, 2016 6:21 am

Re: Performing SNMP set requests in Nagios

Post by hornseym »

I hadn't come across event handlers yet, thanks for that; I'll give that a go and see what happens.

Thanks
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Performing SNMP set requests in Nagios

Post 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.
Locked