Page 1 of 1

How to change SNMP strings in servers en masse

Posted: Wed May 15, 2024 4:57 pm
by adamsj
Hi, folks,

We're changing out our community strings for SNMP and I'm trying to figure out how to do this programmatically.

My best thought is to go into /usr/local/nagios and change the items in ./etc and ./share which match those strings. The stuff in ./var I assume is volatile and will change when the rest is changed. Do I have this figured out, or am I missing something (like a better way to do this).

Thanks,

John A

Re: How to change SNMP strings in servers en masse

Posted: Thu May 16, 2024 5:18 pm
by ajcoil
Hello @adamsj,

Thank you for reaching out!

I would recommend first checking out the following forum post, as I believe you are trying to accomplish something similar:
viewtopic.php?p=334641

If you have any further questions, comments, or concerns, feel free to reach out!

Re: How to change SNMP strings in servers en masse

Posted: Thu May 16, 2024 11:42 pm
by kg2857
It might be a good idea to set this in resources.cfg in the future.
You could also set the C-string in cfg files, copy them to the import dir and run a reconfig to import them.

Re: How to change SNMP strings in servers en masse

Posted: Tue May 21, 2024 9:58 am
by adamsj
Hi, @ajcoil,
ajcoil wrote: Thu May 16, 2024 5:18 pmI would recommend first checking out the following forum post, as I believe you are trying to accomplish something similar:
viewtopic.php?p=334641
That is similar to what I'm doing; however, I've got to do it on a defined (by host list) subset of the hosts being monitored. I'll dig a little into that table and see what I can see.

Thanks,

John A

Re: How to change SNMP strings in servers en masse

Posted: Tue May 21, 2024 10:24 am
by adamsj
adamsj wrote: Tue May 21, 2024 9:58 am Hi, @ajcoil,
ajcoil wrote: Thu May 16, 2024 5:18 pmI would recommend first checking out the following forum post, as I believe you are trying to accomplish something similar:
viewtopic.php?p=334641
That is similar to what I'm doing; however, I've got to do it on a defined (by host list) subset of the hosts being monitored. I'll dig a little into that table and see what I can see.
It turns out our SNMP strings are set entirely differently, not as Free Variables but set (I believe) by the input wizard.

Re: How to change SNMP strings in servers en masse

Posted: Tue May 21, 2024 1:42 pm
by adamsj
By the way, in case you're wondering, this is an installation I inherited. I didn't set it up and I don't fully understand its innards.

Re: How to change SNMP strings in servers en masse

Posted: Thu May 23, 2024 9:48 am
by adamsj
Hi, folks,

I'm puzzled by something. As an experiment, I changed one host's string to the desired new string, both on the host and on our Nagios installation in /usr/local/nagios/etc/services/hostname.cfg . It's doing what I expected--it's responding with current information. When I look in the console under Monitoring, I see the string has been changed. I didn't change the string where it appeared in files under /usr/local/nagios/share/perfdata/hostname/ and thus expected monitoring to stop--but it did not.

This seems inconsistent to me. What am I not understanding?

Thanks,

John A

Re: How to change SNMP strings in servers en masse

Posted: Thu May 23, 2024 11:41 am
by bbahn
Hello @adamsj,

So long as there are the same number of perfdata points for the given host, just changing the data source for a host will not stop the perfdata as the check is controlled by Nagios Core and the check listed in the XML is ornamental and is updated when the check is ran. Is it not updating for you?

Anything in the perfdata folder is not configuration-related and will be updated by Nagios Core automatically.

Re: How to change SNMP strings in servers en masse

Posted: Thu May 23, 2024 12:50 pm
by adamsj
Hi, bbahn,
bbahn wrote: Thu May 23, 2024 11:41 amSo long as there are the same number of perfdata points for the given host, just changing the data source for a host will not stop the perfdata as the check is controlled by Nagios Core and the check listed in the XML is ornamental and is updated when the check is ran. Is it not updating for you?
It did not update, but then, all I did was change a file in etc/services.
bbahn wrote: Thu May 23, 2024 11:41 amAnything in the perfdata folder is not configuration-related and will be updated by Nagios Core automatically.
So when the new SNMP string is truly in Core, that'll update? Which implies the new string isn't there now. But then how is performance updating?

Thanks,

John A

P.S. It's possible the right answer is "Johnnie, RTFM," in which case just point me to it.

Re: How to change SNMP strings in servers en masse

Posted: Fri May 24, 2024 10:47 am
by bbahn
@adamsj,

Assuming you have the standard setup for Nagios Core, updating your host files in /usr/local/nagios/etc/hosts/[hostname].cfg (or the services folder) should update Nagios Core. Have you restarted the Nagios service?

Code: Select all

sudo systemctl restart nagios