Page 1 of 1

Export Service Detail to .csv

Posted: Mon Feb 15, 2016 10:37 am
by SavaSC
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!

Re: Export Service Detail to .csv

Posted: Mon Feb 15, 2016 1:19 pm
by gormank
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

Re: Export Service Detail to .csv

Posted: Mon Feb 15, 2016 1:23 pm
by WillemDH
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

Re: Export Service Detail to .csv

Posted: Mon Feb 15, 2016 1:23 pm
by SavaSC
Thank you for the information.

Re: Export Service Detail to .csv

Posted: Mon Feb 15, 2016 4:05 pm
by hsmith
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.

Re: Export Service Detail to .csv

Posted: Mon Feb 15, 2016 4:18 pm
by SavaSC
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.
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.

Re: Export Service Detail to .csv

Posted: Tue Feb 16, 2016 2:32 pm
by hsmith
This seems like a reasonable request. I'll put in a FR for you.

Re: Export Service Detail to .csv

Posted: Tue Feb 16, 2016 2:34 pm
by hsmith
FR 7785 submitted.

Re: Export Service Detail to .csv

Posted: Tue Feb 16, 2016 2:38 pm
by SavaSC
hsmith wrote:FR 7785 submitted.
Thank you!

Re: Export Service Detail to .csv

Posted: Tue Feb 16, 2016 2:40 pm
by hsmith
I'll leave this topic open so you check on it at a later date.