Page 1 of 1
Task to replace all IP addresses in Nagios service monitors
Posted: Fri Jan 10, 2020 8:56 pm
by ibmkenexa
Team,
Can you please help us on below task.
We have a task to replace all IP addresses in one of Nagios with the new set of IP addresses. which are many service monitor configurations have IP addresses in them as an argument. There are > 2500 entries as we see it. It will be difficult to do them manually. Is there anyway we can cook up a script to make it easier
reverse engineer (pull the data out) -> convert to a script -> modify to replace IP addresses with FQDNs -> execute & verify.
Thank you..!
Re: Task to replace all IP addresses in Nagios service monit
Posted: Mon Jan 13, 2020 10:28 am
by mbellerue
This could be done through the API. Go to Help -> Config Reference, and look under the hosts section. You use a PUT command to update hosts, and it looks like host address is one of the options.
Alternately, if you feel more confident with SQL, you could affect this change in the nagios database, altering the nagios_hosts table. Always, always, always take backups before you modify anything in the database, however. But once everything is changed, you would go to Configure -> Core Config Manager -> Config File Management, click the Delete Files button, the Write Configs button, and then the Verify Files button. Assuming everything verifies properly, click the Restart Nagios Core
Of those two options, I would highly recommend the API route.
Re: Task to replace all IP addresses in Nagios service monit
Posted: Tue Jan 28, 2020 10:06 am
by ibmkenexa
I have changed one of the service config file in the path /usr/local/nagios/etc/services/<servername>.cfg
Did replace ipaddress with FQDN.
after that nagios service was reload --> and applied configure settings in nagios gui.
however ipaddress still exist in service monitor settings in nagios GUI.
Can you please share the process after modify service.cfg file and how to apply new config file settings into nagios XI tool.
Re: Task to replace all IP addresses in Nagios service monit
Posted: Tue Jan 28, 2020 5:43 pm
by mbellerue
Modifying the configuration files won't work, because those are destroyed and re-created when you apply config. All of the data is stored in the database. I would make sure you have a fresh backup before going in to modify configuration data in the database, as that can cause large issues.