Just CHECK if conditions are meet.

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Kevin Maschke
Posts: 3
Joined: Thu Oct 20, 2011 5:48 am

Just CHECK if conditions are meet.

Post by Kevin Maschke »

Hi,

I hope you guys here on the official support forum can help me.

What I need is that if a certain service "status_information" is meet, the other hosts checks should be done. Example:

HOST A
- SERVICE1
- SERVICE2
- SERVICE3

If SERVICE3 "status_information" is "OK - Standby", SERVICE1 and SERVICE2 checks should be done. The problem is that I can't use SERVICE3s "STATUS" as reference. Because STATUS is shown OK when "status_information" is either "OK" or "OK - Standby".

This is the extract of my services.cfg:
define service {
service_description CPU
check_command check_esx_cpu!80!90
host_name lxbruesx06
check_period 24x7
notification_period 24x7
contact_groups adminfgrp,admins
event_handler_enabled 0
action_url /pnp4nagios/graph?host=$HOSTNAME$&sr$
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
notification_interval 15
notification_options w,u,c,r,n
active_checks_enabled 1
passive_checks_enabled 0
notifications_enabled 1
check_freshness 0
freshness_threshold 86400
}

define service {
service_description mem
check_command check_esx_mem!90!95
host_name lxbruesx06
check_period 24x7
notification_period 24x7
contact_groups adminfgrp,admins
event_handler_enabled 0
action_url /pnp4nagios/graph?host=$HOSTNAME$&sr$
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
notification_interval 15
notification_options w,u,c,r,n
active_checks_enabled 1
passive_checks_enabled 0
notifications_enabled 1
check_freshness 0
freshness_threshold 86400
}

define service {
service_description status
check_command check_esx_alive!
host_name lxbruesx06
check_period 24x7
notification_period 24x7
contact_groups adminfgrp,admins
event_handler_enabled 0
action_url /pnp4nagios/graph?host=$HOSTNAME$&sr$
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
notification_interval 15
notification_options w,u,c,r,n
active_checks_enabled 1
passive_checks_enabled 0
notifications_enabled 1
check_freshness 0
freshness_threshold 86400
}

So I need that "CPU" and "mem" checks should only be done if "status" check results in Status "OK" and status_information "OK - Stanby".
I thought using Service Dependencies, so I tried this on services.cfg:

define servicedependency{

host_name lxbruesx06

service_description CPU

dependent_host_name lxbruesx06

dependent_service_description status

execution_failure_criteria o

notification_failure_criteria o

}


define servicedependency{

host_name lxbruesx06

service_description mem

dependent_host_name lxbruesx06

dependent_service_description status

execution_failure_criteria o

notification_failure_criteria o

}
Normally using this, CPU and mem should not be checked if the status of "status" results in OK. But it did not work. Checked where done normally, nor errors, no special operations done. Also, this way if Status_information of status results either in OK or "OK- Standby" checks wouldn't be done...



I'll appreciate any type of help or hint. thanks!
Kevin Maschke
Posts: 3
Joined: Thu Oct 20, 2011 5:48 am

Re: Just CHECK if conditions are meet.

Post by Kevin Maschke »

Anyone?
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Just CHECK if conditions are meet.

Post by jsmurphy »

Basically what the service dependency will do is prevent it from alerting, not stop it from checking... to the best of my knowledge there is no way to stop it from actually checking on a condition via nagios settings.

But the question is why does it matter? If you need it for reporting accuracy and you are desperate, you could write an event handler script that told the service to go passive and insert an ok state, then remove it when the parent service comes alive again.
Kevin Maschke
Posts: 3
Joined: Thu Oct 20, 2011 5:48 am

Re: Just CHECK if conditions are meet.

Post by Kevin Maschke »

It does matter.

When our ESX go into STANDBY mode, it still responds to ping, and the STATUS is shown as OK. So there's no difference in STATUS between ESX up or standby.

So I need to let nagios know that when the ESX is in STANBY, the other two checks (mem and CPU) of the ESX should not be made.

I also thought about an event handler, but the problem is that the STATUS is OK when the ESX is either up and working or standby. Would it be possible to write a event handler that looks for the "status information" field instead of the status field? And if the status information field shows "OK - STANDBY", the checks should not be done.
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Just CHECK if conditions are meet.

Post by jsmurphy »

Ah! I see, knowing that we are dealing with an ESX server however does open up some additional options :)

Option 1: set up passive SNMP monitoring and use vCenter to alert for ESX hosts crossing the CPU/Mem threshold... has plenty of limitations of its own but would provide a valid work around.

Option 2. change the host check_command directive from ping to some other check that will check for the ESX state (you may need to write your own using the vCenter Perl API) instead of host-alive, you could then add a ping service to the host if you want specifically host-alive for network performance purposes.

We personally use Option 1 for monitoring our ESX clusters.
Locked