Page 1 of 2
Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 8:00 am
by rez1sog
Is there away to get either a nice text or CSV type data dump of all the hosts/alerts that are configured on the server? Something that has a line for each monitor service that includes the host, service, check, settings, etc?
I can not really fine a nice button on the server to press that generates this? Perhaps a clever mysql command?
My configuration is below...
Nagios XI Installation Profile
Download Profile
System:
nagiosxi 2.6.18-308.4.1.el5 x86_64
CentOS release 5.6 (Final)
Gnome is not installed
Apache Information
PHP Version: 5.1.6
Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1
Server Name: nagiosxi
Server Address: 10.20.20.74
Server Port: 80
Date/Time
PHP Timezone: America/New_York
PHP Time: Tue, 07 Aug 2012 08:53:25 -0400
System Time: Tue, 07 Aug 2012 08:53:25 -0400
Nagios XI Data
nagios (pid 3806) is running...
NPCD running (pid 4046).
ndo2db (pid 4181) is running...
CPU Load 15: 10.50
Total Hosts: 237
Total Services: 2019
Function 'get_base_uri' returns:
http://nagiosxi/nagiosxi/
Function 'get_base_url' returns:
http://nagiosxi/nagiosxi/
Function 'get_backend_url(internal_call=false)' returns:
http://nagiosxi/nagiosxi/includes/compo ... rofile.php
Function 'get_backend_url(internal_call=true)' returns:
http://localhost/nagiosxi/backend/
Re: Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 9:11 am
by nscott
Could you give some sample output of what you're looking for?
Re: Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 9:26 am
by rez1sog
Sure. I can be flexible. Something like a csv with:
host, service, command, options, who gets notified, monitoring period, time periods
The "host, service, command, options, who gets notified" is the important part, the rest is nice to have as well. A mysql command or something that did this would be great. It would allow us to do this on the fly and keep our spreadsheets up to date.
Re: Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 11:19 am
by nscott
What do you think about the 'Notifications' page under the Reports heading? Does somewhat accomplish what you're looking for?
Re: Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 11:57 am
by rez1sog
I have been there, but it is not what I want. That shows all the alerts that have happened in a given period. It is very nice to look at, but I want a list of all the hosts/services that are configured on the system in a nice CSV format. Not what is alerting.
Any other thoughts?
Re: Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 1:07 pm
by mguthrie
Re: Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 1:48 pm
by nscott
Or here is the SQL for accessing the database and getting what you want:
Code: Select all
SELECT DISTINCT
nagios_hosts.display_name as HostName,
nagios_services.display_name as ServiceName,
nagios_commands.command_line as CommandLine,
nagios_services.check_command_args as CommandArguments,
nagios_services.check_interval as CheckInterval,
(SELECT GROUP_CONCAT(alias) FROM nagios_contacts),
nagios_timeperiods.alias as Timeperiod
FROM
nagios_services
JOIN
nagios_hosts
ON
nagios_hosts.host_object_id=nagios_services.host_object_id
JOIN
nagios_commands
ON
nagios_commands.object_id=nagios_services.check_command_object_id
JOIN
nagios_service_contacts
ON
nagios_service_contacts.service_id=nagios_services.service_id
JOIN
nagios_contacts
ON
nagios_contacts.contact_object_id=nagios_service_contacts.contact_object_id
JOIN
nagios_timeperiods
ON
nagios_timeperiods.timeperiod_object_id=nagios_services.check_timeperiod_object_id;
doing a
mysql -u root -p[rootpassword] nagios < [path to this sql file]
Where [rootpassword] would be replaced by your MySQL root password (you could also use the ndoutils acccount). This will yield tab delimited results.
Re: Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 2:48 pm
by rez1sog
I got to admit, that was way cool. I was able to get the results that I wanted with a little fudging.
What else can this backend thingie do? Is there a doc on it somewhere?
Re: Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 2:56 pm
by slansing
Re: Get a nice text or CSV dump of all configured alerts
Posted: Tue Aug 07, 2012 3:38 pm
by mguthrie
These are a few other commands for the backend API, and most of them take arguments, but it depends on what you need. Unfortunately we don't have much documentation on all of parameters at this time, but if you need them we can get them to you:
backend/?cmd=
• gethoststatus
• getservicestatus
• gethosts
• getservices
• getcomments
• getprogramstatus
• getusers
• getparenthosts
• getcontacts
• gethostgroups
• gethostgroupmembers
• getservicegrouphostmembers
• getcustomhostvariablestatus
• getstatehistory
• getnotifications