Page 1 of 2

EC2 Instances Monitoring

Posted: Mon Jun 19, 2017 8:46 am
by bosecorp
Hi

We are monitoring AWS EC2 instances, and we were wondering if there is a way to create a rule/condition in Nagios that doesnt sent alert and/or perform check when a EC2 instances is in stopped state.

should I be able to create a event handler to check the condition of the EC2 instance? if this is possible, do you have an event handler that already does this? or do I have to create one myself?

Re: EC2 Instances Monitoring

Posted: Mon Jun 19, 2017 2:08 pm
by dwhitfield
When you say stopped, do you mean that Nagios reports the host as down? If you know the hosts are going down, you can just put them in scheduled downtime.

We do not have specific event handlers for AWS. You may want to see if you find https://support.nagios.com/forum/viewto ... 10#p103689 useful. You could probably do this without handlers, but you also definitely could do it with handlers.

Re: EC2 Instances Monitoring

Posted: Mon Jun 19, 2017 2:50 pm
by bosecorp
Let me give you more info.

In our environment we give users the ability to shutdown/power off AWS EC2 instances, which means Nagios will report that as down.

What we want is that if an AWS ec2 isntance is in stopped state is for Nagios not to perform the check at that point.

schedule downtime assumes I know what the downtime schedule is, in this case we dont have it.

if I decide to do it via eventhandler, at a very high level how will do logic work. if the condition is met, should I just change the state of the device? how do I stop the host check at that point as well as notification?. could a way of doing be to ack the alert via host event handler when the condition is met? could this work

Re: EC2 Instances Monitoring

Posted: Mon Jun 19, 2017 5:00 pm
by scottwilkerson
We don't have anything pre-written, but you may be able to use a plugin such as the following
https://exchange.nagios.org/directory/P ... us/details

You can add your instances as another check, and then add these as a dependency for the others (or as a parent check or host check)

Re: EC2 Instances Monitoring

Posted: Tue Jun 20, 2017 7:27 am
by bosecorp
Although that might work, this will add too much management overhead. this means I will have to setup two host checks per AWS EC2 instance. In addition this will add more unnecessary load to the Nagios server

if I do it via eventhandler, by creating a shell script, check the status of the EC2 instance and it's in STOPPED state, then via event handler I am going to ack the host. do you have a macro that tells you if the host has been ack or not?

Re: EC2 Instances Monitoring

Posted: Tue Jun 20, 2017 9:32 am
by scottwilkerson
In the API you can look at the problem_acknowledged under Help -> Object Reference -> objects/hoststatus

So you could make a call like this

Code: Select all

curl -XGET "http://localhost/nagiosxi/api/v1/objects/hoststatus?apikey=XXXXXXXXXXX&pretty=1&host_name=localhost"
and look at the value of problem_acknowledged

Re: EC2 Instances Monitoring

Posted: Wed Jun 21, 2017 8:52 pm
by bosecorp
You just game me an kdea, can I ack a host via api

Re: EC2 Instances Monitoring

Posted: Thu Jun 22, 2017 1:40 pm
by dwhitfield
Were you able to test that? Are we ready to lock this up?

Re: EC2 Instances Monitoring

Posted: Thu Jun 22, 2017 3:45 pm
by bosecorp
test what?

what was provided earlier was to check the status of a HOST via API. what I would like to see if I can ack an alert via API.

Re: EC2 Instances Monitoring

Posted: Thu Jun 22, 2017 4:21 pm
by dwhitfield
Apologies. I read you have an idea as a statement, since there was no question mark.

The API documentation is available in the help menu of your version. Unfortunately, there is no external link I can give you to it. That said, you cannot acknowledge via any version of the API at this time. There are already many feature requests for the API, but I am happy to add this to the list if you like.

For clarity, a request is just that. I have no say in if/when it would be included.