Page 1 of 1
Generate CSV report from command line
Posted: Thu Mar 12, 2015 3:26 am
by rajasegar
Nagios XI 2014R1.2
Code: Select all
curl "http://10.17.19.235/nagiosxi/backend/?cmd=getstatehistory&&search=&reportperiod=last24hours&startdate=&enddate=&hostgroup=&servicegroup=&statetype=both&mode=csv&username=nagiosadmin&ticket=ei5111111"
Please advice if the above can be exported as csv instead of xml.
Thanks.
Re: Generate CSV report from command line
Posted: Thu Mar 12, 2015 10:04 am
by abrist
Unfortunately no. The XI backend responds only with XML. The Core JSON backend responds in JSON format (through the json cgis). There are a few reports that can be exported as csv, though you are probably better off just converting the xml to csv using one of the many online or cli tools. I think excel can convert them as well.
Re: Generate CSV report from command line
Posted: Thu Mar 12, 2015 7:29 pm
by rajasegar
Can you please advice how to query using time period?
Code: Select all
curl "http://10.17.19.235/nagiosxi/backend/?cmd=getstatehistory&search=&reportperiod=custom&startdate=2015-03-12+7%3A00&enddate=2015-03-12+15%3A30&hostgroup=&servicegroup=&statetype=both&reporttime&username=nagiosadmin&ticket=ei111111"
The URL above just returns last 24 hours based on current datetime.
Re: Generate CSV report from command line
Posted: Thu Mar 12, 2015 8:06 pm
by rajasegar
Already found solution
Timestamp must use unix format
date -d '2015-03-10 07:30:00' +"%s"
curl "
http://10.17.19.235/nagiosxi/backend/?c ... t=ei111111" >t.xml
Please close this thread.
Re: Generate CSV report from command line
Posted: Fri Mar 13, 2015 9:02 am
by ssax
Thank you for posting the solution, closing now.