LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-09-2016, 10:58 AM   #1
johnjones
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
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,481

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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:
twincheck.sh hosta hostb
Code:
#!/bin/bash
HOSTA=$1
HOSTB=$2
check_host_ping -h ${HOSTA} [plus whatever other parameters for timeout, etc.]
AUP=$?

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
fi

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.]
  BUP=$?
fi

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

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
fi

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
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,806

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


Reply

Tags
nagios, nagios ha



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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