Bulk Change SNMP Community strings in NagiosXI

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
cgreve
Posts: 2
Joined: Mon Aug 16, 2021 12:38 pm

Bulk Change SNMP Community strings in NagiosXI

Post by cgreve »

Hey guys,

I'm trying to change our SNMP community across all of our devices currently monitored in NagiosXI. We have multiple strings across all devices and I would like to change them all to a single string.

Currently it looks like the devices have been configured in 3 different ways:

1: Directly on the host itself - with a Free Variable named _community
2: Directly on the Service - with a Free Variable named _community
3: Template with the Free Variable named _community

I was able to run some linux commands and find where all of the community strings are stored on within NagiosCore - however from what I understand is that will get overridden as soon as someone hits apply within Nagios XI because it is apparently storing this information in a database somewhere.

Is there any way to leverage the API to accomplish this?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Bulk Change SNMP Community strings in NagiosXI

Post by ssax »

While it's not currently possible to do through the Bulk Modifications tool, you should be able to do it through SQL like this:
- First, make sure you have a successful apply configuration config snapshot that you can revert to in Admin > Config Snapshots in case you want to revert
- This will change every free variable named _community for all templates/hosts/services that have the _community free variable defined and are set to oldcommunity to newcommunity

Code: Select all

mysql -h localhost -uroot -pnagiosxi nagiosql -e "update tbl_variabledefinition set value = 'newcommunity' where name = '_community' and value = 'oldcommunity';"
cgreve
Posts: 2
Joined: Mon Aug 16, 2021 12:38 pm

Re: Bulk Change SNMP Community strings in NagiosXI

Post by cgreve »

ssax wrote:While it's not currently possible to do through the Bulk Modifications tool, you should be able to do it through SQL like this:
- First, make sure you have a successful apply configuration config snapshot that you can revert to in Admin > Config Snapshots in case you want to revert
- This will change every free variable named _community for all templates/hosts/services that have the _community free variable defined and are set to oldcommunity to newcommunity

Code: Select all

mysql -h localhost -uroot -pnagiosxi nagiosql -e "update tbl_variabledefinition set value = 'newcommunity' where name = '_community' and value = 'oldcommunity';"
This is exactly what I was looking for thank you!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Bulk Change SNMP Community strings in NagiosXI

Post by ssax »

Great, let us know when we're okay to lock this up and mark it as resolved.
Locked