Page 1 of 1

Check two websites for one service...

Posted: Thu Aug 17, 2017 2:00 pm
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...

Re: Check two websites for one service...

Posted: Thu Aug 17, 2017 3:14 pm
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;
}

Re: Check two websites for one service...

Posted: Thu Aug 17, 2017 4:50 pm
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