How to change SNMP strings in servers en masse

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
adamsj
Posts: 6
Joined: Wed May 15, 2024 4:52 pm

How to change SNMP strings in servers en masse

Post 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
User avatar
ajcoil
Posts: 66
Joined: Wed Aug 09, 2023 10:30 am

Re: How to change SNMP strings in servers en masse

Post 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!
kg2857
Posts: 254
Joined: Wed Apr 12, 2023 5:48 pm

Re: How to change SNMP strings in servers en masse

Post 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.
adamsj
Posts: 6
Joined: Wed May 15, 2024 4:52 pm

Re: How to change SNMP strings in servers en masse

Post 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
adamsj
Posts: 6
Joined: Wed May 15, 2024 4:52 pm

Re: How to change SNMP strings in servers en masse

Post 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.
adamsj
Posts: 6
Joined: Wed May 15, 2024 4:52 pm

Re: How to change SNMP strings in servers en masse

Post 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.
adamsj
Posts: 6
Joined: Wed May 15, 2024 4:52 pm

Re: How to change SNMP strings in servers en masse

Post 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
bbahn
Posts: 150
Joined: Thu Jan 12, 2023 5:42 pm

Re: How to change SNMP strings in servers en masse

Post 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.
April: Actively advancing awesome answers with ardent alliteration, aptly addressing all ambiguities. Amplify your acumen and avail our amicable assistance. Eagerly awaiting your astute assessments of our advice.
adamsj
Posts: 6
Joined: Wed May 15, 2024 4:52 pm

Re: How to change SNMP strings in servers en masse

Post 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.
bbahn
Posts: 150
Joined: Thu Jan 12, 2023 5:42 pm

Re: How to change SNMP strings in servers en masse

Post 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
April: Actively advancing awesome answers with ardent alliteration, aptly addressing all ambiguities. Amplify your acumen and avail our amicable assistance. Eagerly awaiting your astute assessments of our advice.
Post Reply