Hello,
I need to get a dump of all of our Hosts and their related services for a VP. Pretty much what the Service Detail shows. How do I get a dump of this out to an Excel file?
Thanks!
Export Service Detail to .csv
Re: Export Service Detail to .csv
I asked a similar question not too long ago and was pointed toward the JSON API, but I wound up not using it. It would produce JSON obviously, but there may be converters.
I can dig up the SQL to output the data, but it may take some postprocessing to reliably get CSV. If you wan to know about the DB and table relations, look for the doc "NDOUtils Database Model."
# mysql -B -pnagiosxi nagios
mysql> select name1 Hostname, current_state State, name2 'Service Name', output Output from nagios_objects, nagios_servicestatus where object_id = service_object_id and is_active = 1 order by name1, name2;
That gives tab delimited text, and you'd want to search and replace commas w/ something else, then replace tabs w/ commas. Both are easy to do w/ sed.
To run more interactively, use:
# mysql -t -pnagiosxi nagios
I can dig up the SQL to output the data, but it may take some postprocessing to reliably get CSV. If you wan to know about the DB and table relations, look for the doc "NDOUtils Database Model."
# mysql -B -pnagiosxi nagios
mysql> select name1 Hostname, current_state State, name2 'Service Name', output Output from nagios_objects, nagios_servicestatus where object_id = service_object_id and is_active = 1 order by name1, name2;
That gives tab delimited text, and you'd want to search and replace commas w/ something else, then replace tabs w/ commas. Both are easy to do w/ sed.
To run more interactively, use:
# mysql -t -pnagiosxi nagios
Last edited by gormank on Mon Feb 15, 2016 1:29 pm, edited 3 times in total.
Re: Export Service Detail to .csv
With Powershell you can very easily query the services with the JSON API, convert the JSON to a custom Powershell object and then pipe to Excel with this Powershell module: https://github.com/RamblingCookieMonster/PSExcel
Nagios XI 5.8.1
https://outsideit.net
https://outsideit.net
Re: Export Service Detail to .csv
Thank you for the information.
Re: Export Service Detail to .csv
Can you show me an example of what you would like the output to look like? I could put in a feature request, but would like to know exactly what you're looking for. Perhaps upload a mockup.
Former Nagios Employee.
me.
me.
Re: Export Service Detail to .csv
Sure. I just went through and did it by hand (Took a couple of hours, but got the job done). Here is an abbreviated version of what I made.hsmith wrote:Can you show me an example of what you would like the output to look like? I could put in a feature request, but would like to know exactly what you're looking for. Perhaps upload a mockup.
You do not have the required permissions to view the files attached to this post.
Re: Export Service Detail to .csv
This seems like a reasonable request. I'll put in a FR for you.
Former Nagios Employee.
me.
me.
Re: Export Service Detail to .csv
Thank you!hsmith wrote:FR 7785 submitted.
Re: Export Service Detail to .csv
I'll leave this topic open so you check on it at a later date.
Former Nagios Employee.
me.
me.