Hey guys,
I want to run a query on the nagios mysql database to get the hosts that are down more then 9 days, but I'm not familiar with the database architect. Can someone help me, or give me a suggestion?
Thanks
Hosts that are down more than 9 days
Hosts that are down more than 9 days
You do not have the required permissions to view the files attached to this post.
Re: Hosts that are down more than 9 days
Interacting directly with the database isn't always recommended. What are you trying to accomplish that you would like this information?
Former Nagios Employee.
me.
me.
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Hosts that are down more than 9 days
You could use the JSON query generator to get all the hosts down:
Then you could take that JSON data and parse it to only get the hosts down using the last_time_down field.
Code: Select all
http://xiserver/nagios/jsonquery.htmlCode: Select all
https://xiserver/nagios/cgi-bin/statusjson.cgi?query=hostlist&details=true&dateformat=%25Y-%25m-%25d+%25H%3A%25M%3A%25S&hoststatus=downYou do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Hosts that are down more than 9 days
hey hsmith and Box
We have an automate way to add new hosts to be monitored with Nagios, whenever a customers provision new environments for testing their codes. After a certain period of times these environments is expired and released, yets these hosts are still active in Nagios. I just want to setup a query and get all the hosts that have been down more then 5-9 days and removed them from Nagios. Thanks
We have an automate way to add new hosts to be monitored with Nagios, whenever a customers provision new environments for testing their codes. After a certain period of times these environments is expired and released, yets these hosts are still active in Nagios. I just want to setup a query and get all the hosts that have been down more then 5-9 days and removed them from Nagios. Thanks
- snapon_admin
- Posts: 952
- Joined: Mon Jun 10, 2013 10:39 am
- Location: Kenosha, WI
- Contact:
Re: Hosts that are down more than 9 days
Isn't that what the deadpool is for under Admin > deadpool settings?
Re: Hosts that are down more than 9 days
hey snapon_admin,
I have tried the deadpool setting, but I dunno why these doesn't work for me. It is because I have all my services in the static directory?
I have tried the deadpool setting, but I dunno why these doesn't work for me. It is because I have all my services in the static directory?
Re: Hosts that are down more than 9 days
This is most likely the case, yes. Anything in the static directory will be ignored by XI basically. You will either need to add these in using the API introduced in XI 5, or use the method that @Box293 suggested.haile711 wrote:I have all my services in the static directory?
Former Nagios employee
Re: Hosts that are down more than 9 days
Hey guys,
I know it's recommend not to touch the nagios db, I just want to see if there is a way to query that.
To Box, the API approach can work for us as well, but we have so many hosts, can you help us in how to parse to get just the hosts that has been down more than 9 days?
Thanks
I know it's recommend not to touch the nagios db, I just want to see if there is a way to query that.
To Box, the API approach can work for us as well, but we have so many hosts, can you help us in how to parse to get just the hosts that has been down more than 9 days?
Thanks
Re: Hosts that are down more than 9 days
I was able to pull all down hosts using a curl / grep, I suspect you'll need to write a script to filter out the 9 day thing. This should work though -
Here's the one liner -
As an example, I have -
Here's the one liner -
Code: Select all
curl -s "http://192.168.4.254/nagiosxi/backend/?cmd=gethoststatus&username=nagiosadmin&ticket=tickettest" | grep "CRITICAL"
Code: Select all
[root@suse11 ~]# curl -s "http://192.168.4.254/nagiosxi/backend/?cmd=gethoststatus&username=nagiosadmin&ticket=tickettest" | grep "CRITICAL"
<status_text>CRITICAL - 192.168.3.243: Host unreachable @ 192.168.4.254. rta nan, lost 100%</status_text>
<status_text>CRITICAL - 1.1.1.1: rta nan, lost 100%</status_text>
Former Nagios Employee