2

Is there any way to achieve below scenario in Nagios using NRPE?

Nagios box will first check if NRPE on client box is up and if yes it wil check on other services configured for that client. If NRPE is down on client, it will throw notification for NRPE and will stop checking rest of the services configured for that client box until NRPE comes up.

2 Answers2

2

This setting is what are you looking for. Look at your nagios.cfg

# DISABLE SERVICE CHECKS WHEN HOST DOWN
# This option will disable all service checks if the host is not in an UP state
#
# While desirable in some environments, enabling this value can distort report
# values as the expected quantity of checks will not have been performed

host_down_disable_service_checks=1

Check your hosts status via check_nrpe. Create new command in your config, if you don't have it:

define command{
        command_name    check-host-alive-nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$
        }

Now, use this command in your host definition, something like that:

define host {
  host_name                      your_server
  address                        your_server
  use                            generic-host
  check_command                  check-host-alive-nrpe
}

When the NRPE on remote host stop responding due some problems, this host will be in CRITICAL state and remote check for services will be temporary disabled.

After you configure this don't forget restart your Nagios service.

PS: This setting works only with Nagios 4+

Rohlik
  • 1,286
  • 19
  • 28
  • @Rohilk , Thanks for the response. But i am looking for case where NRPE is down. Consider client host is up but NRPE is down, in this case above solution will fail as it will keep on checking rest of the services as host is marked as up. – Paresh Gandhare May 23 '18 at 14:53
  • Thanks Rohit, it worked for me. Wanted to refine it more as if nrpe is down, nagios is throwing alert as HOST is down, if there are any options to make this notification more general , say NRPE is down in subject line – Paresh Gandhare Jul 06 '18 at 09:49
  • @PareshGandhare I think this is possible only via your own version of NRPE. You must edit source code and then built it. But this is out of my skill, so I cannot help you. – Rohlik Jul 30 '18 at 20:23
0

I achieved this via service dependency where all nrpe checks depend on nrpe service availability check.

define servicedependency{
    hostgroup                       linux-servers
#    host_name                      xyz.example.com
    service_description             check_nrpe_alive
    dependent_service_description   check_disk,check_mem,chech_load,check_time,check_disk
    execution_failure_criteria      w,c,u
    notification_failure_criteria   u,w,c,o
}

Below is check_nrpe_alive check command definition.

define command{
        command_name    check_nrpe_alive
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$
        }

Also needed to set soft_service_dependencies=1 in nagios.cfg

# SOFT STATE DEPENDENCIES
# This option determines whether or not Nagios will use soft state
# information when checking host and service dependencies. Normally
# Nagios will only use the latest hard host or service state when
# checking dependencies. If you want it to use the latest state (regardless
# of whether its a soft or hard state type), enable this option.
# Values:
#  0 = Don't use soft state dependencies (default)
#  1 = Use soft state dependencies
# Changing fpr service dependency
#soft_state_dependencies=0
soft_state_dependencies=1

When nrpe service on client is in CRITCAL state Nagios will only send out notification for check_nrpe_alive but not any dependent service checks. This is tested on Nagios core 4.4.6

Alap Shah
  • 11
  • 1