Check two websites for one service...

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Unigarant
Posts: 42
Joined: Mon Jan 06, 2014 2:53 am

Check two websites for one service...

Post by Unigarant »

We are using Cisco for our telephony.
In order for us to see on what "side" we are running (backup or primary) we can check a website. If the website contains the word "idle" that side is not running. If it contains the word "active" that side is running.

I would like to receive a warning only if BOTH websites show the words ACTIVE or both websites show the word IDLE. Not if one says idle and one says active, since that is the expected behaviour. I would even be happy with the check just giving a warning if both websites show an IDLE state.

I think this can be done using service dependencies, but for the life of me I cannot figure out how...
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check two websites for one service...

Post by mcapra »

You essentially have 2 "checks" who's states are tightly coupled with one another. If it were my problem to solve, I would write a custom plugin for this. In pseudocode:

Code: Select all

$site1_content = http_request_to(site1);
$site2_content = http_request_to(site2);


if($site1_content IN ('idle', 'active') && $site2_content IN ('idle', 'active')) {
    if ($site1_content == $site2_content) {
        echo "CRITICAL";
        exit 2;
    }
    else {
        echo "OK";
        exit 0;
    }
}
else {
    echo "UNKNOWN - RACE CONDITION";
    exit 3;
}
Former Nagios employee
https://www.mcapra.com/
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Check two websites for one service...

Post by tgriep »

Thanks @mcapra for the help.

Another option is to use the check_multi plugin. You can use it to run multiple checks at once and output an alert when both systems are in the error state.
Take a look at the link below for more information.
https://exchange.nagios.org/directory/P ... ti/details
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked