Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-09-2016, 10:58 AM   #1
LQ Newbie
Registered: May 2016
Posts: 5

Rep: Reputation: Disabled
Nagios XI correlation dependency between two hosts

I have two hosts. If host1 goes down and host2 is up the Nagios must not create a critical alert as the host2 is still up. Instead it must create a warning alert for the host1 so that there is no need for immediate action. The same must be done when the host2 is down and host1 is up. Can anyone please help how this can be done on Nagios XI??
Old 05-10-2016, 03:15 AM   #2
Senior Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,930

Rep: Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192
Off the top of my head I can't think of an easy way to do this in Nagios, possibly something to do with dependencies?

What I'd do though is write a custom check script that takes two hosts as parameters, the first being the main host to check and the second being its slave.

Run your check and if the main host fails but the second host is up then return the warning alert.

So the pseudocode (I'm too lazy to write the whole script here!) would be something like

Code: hosta hostb
check_host_ping -h ${HOSTA} [plus whatever other parameters for timeout, etc.]

if ${AUP} = 0; then
  # A is up, so we're fine here, even if B is down.
  # We don't need to check B because if it's down
  # then our check of B A will catch it.
  echo "OK"
  exit 0

if ${AUP} != 0; then
  # A Isn't up, let's check our twin
  check_host_ping -h ${HOSTB} [plus whatever other parameters for timeout, etc.]

if ${BUP} = 0; then
  # A is down, but B is up, so we exit with a warning
  echo "Down but twin up"
  exit 1

if ${BUP} != 0; then
  # A is down and B isn't in an "OK" state
  # So we exit with a CRITICAL
  echo "Down and twin down"
  exit 2

Last edited by TenTenths; 05-12-2016 at 02:27 PM. Reason: Tidy up my broken [code] tag
Old 05-12-2016, 02:12 PM   #3
Senior Member
Registered: Dec 2011
Location: Simplicity
Posts: 1,179

Rep: Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533
This script is a bit closer to the requirement:
err=0; errhost=""
for arg
  check_host_ping -h "$arg" || {
    ((err++)); errhost="$errhost $arg"
case $err in
  echo "OK"; exit 0
  echo "WARNING: host $errhost is down"; exit 1
  echo "CRITICAL: hosts $errhost are down"; exit 2
You can also look at host and service dependencies, but this can only suppress notifications (or suppress further service checks).


nagios, nagios ha

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto detect hosts with Nagios aocferreira Linux - Networking 1 02-17-2011 08:17 PM
Nagios RPM dependency error kenneho Linux - Software 2 01-02-2009 06:26 AM
nagios, same command for multiple hosts muha Linux - Software 2 07-04-2007 07:08 AM
nagios + virtual hosts = How to keep it to one domain neocontrol Linux - Server 2 05-30-2007 01:33 AM
Nagios v.2.9 - hosts/hostgroups not recognized??? arktik Linux - Networking 2 05-25-2007 07:45 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:00 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration