To assist me with migrating the systems over in a more uniformed manner I am looking at setting up a cronjob or something to extract the hosts currently in Nagios Core. I see where this is much easier with XI so that will improve once I get to that stage but for now I really need to extract the hosts and IP address, not sure what other information at this point, into a csv file. Thoughts?
Daily extract of monitored hosts
Daily extract of monitored hosts
I am actively working on getting our Nagios Core 3.0.6 updated to Nagios XI 2014R1.3. I am wondering if there is a way I can export the hosts being monitored in a csv file? I have several .cfg files scattered throughout the /usr/local/nagios/etc directory as this Nagios Core 3.0.6 instance has been managed by 4 different people all with different methods. Good times!
To assist me with migrating the systems over in a more uniformed manner I am looking at setting up a cronjob or something to extract the hosts currently in Nagios Core. I see where this is much easier with XI so that will improve once I get to that stage but for now I really need to extract the hosts and IP address, not sure what other information at this point, into a csv file. Thoughts?
To assist me with migrating the systems over in a more uniformed manner I am looking at setting up a cronjob or something to extract the hosts currently in Nagios Core. I see where this is much easier with XI so that will improve once I get to that stage but for now I really need to extract the hosts and IP address, not sure what other information at this point, into a csv file. Thoughts?
Re: Daily extract of monitored hosts
Before we get into that, would importing the config files be an option for you?
http://assets.nagios.com/downloads/nagi ... ios-XI.pdf
http://assets.nagios.com/downloads/nagi ... ios_XI.pdf
http://assets.nagios.com/downloads/nagi ... ios-XI.pdf
http://assets.nagios.com/downloads/nagi ... ios_XI.pdf
Former Nagios employee
Re: Daily extract of monitored hosts
I will have both the Core and XI instances up and running. What I am trying to do is get a baseline, output from Core of the hosts and IP addresses, then on a daily or weekly basis run a diff on the output to make sure no one is still using Core once XI is implemented. This will also show I have imported all the Core systems into XI.
Re: Daily extract of monitored hosts
I would compare the /usr/local/nagios/var/objects.cache files for both systems as that should have all the objects and their full configs.
Former Nagios employee
Re: Daily extract of monitored hosts
Is there a way with Nagios XI to pull out all the hosts and IP address, etc into a csv file? I was looking at the reports but didn't see anything.
We have another system that I want to pull the hosts and if I need additional information from Nagios XI and then import into this other system. The other system can use a csv file but not sure how I can do that or how to obtain that information from Nagios XI.
We have another system that I want to pull the hosts and if I need additional information from Nagios XI and then import into this other system. The other system can use a csv file but not sure how I can do that or how to obtain that information from Nagios XI.
Re: Daily extract of monitored hosts
You can pull a host list from the XI server in xml or json format.
Core JSON:
XI XML:
Core JSON:
Code: Select all
http://<ip>/nagios/cgi-bin/objectjson.cgi?query=hostlistCode: Select all
http://<ip>/nagiosxi/backend/?cmd=gethosts&brevity=3Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Daily extract of monitored hosts
I am still having a bit of an issue getting this worked out. I need to export all my hosts into a csv file. I have no idea how I can pull the hosts from JSON or XML and convert to csv. Is there not a way to pull this from the internal database?
Re: Daily extract of monitored hosts
We do not have a built-in page that will give the hostname and address in a CSV format. Getting that data will require a mild amount of data massaging. If you want to go for the database directly (in XI) you can do something like this from the command line:
and then /tmp/hosts.csv will have what you need, bearing in mind this will only grab what is already in XI in the CCM. You may need to adjust your mysql password if it has been changed from the default of "nagiosxi".
Code: Select all
echo "use nagiosql; select host_name,address from tbl_host into outfile '/tmp/hosts.csv' fields terminated by ',' enclosed by '\"' lines terminated by '\n'" | mysql -u root -pnagiosxi
Former Nagios employee