2 checks 1 service

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
tmeto
Posts: 26
Joined: Tue Aug 20, 2013 4:59 am

2 checks 1 service

Post by tmeto »

hi,

can i put in one single service the result of 2 checks?

I mean, in the FortiMail, different mail queues, each with its name and size. I attached photo to be better understood.

I seek to represent multiple values of the same line in one service, like so:

snmpwalk -v2c xx.xx.xx.xx - -c comunity fmlMailQueueMailCount.1 && snmpwalk-v2c xx.xx.xx.xx -c comunity fmlMailQueueMailSize.1
FORTINET-FortiMail-MIB :: fmlMailQueueMailCount.1 = Gauge32: 0
FORTINET-FortiMail-MIB :: fmlMailQueueMailSize.1 = Gauge32: 0


Image
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: 2 checks 1 service

Post by jdalrymple »

The answer is a wrapper script for your plugin. Here is a simple example:

Code: Select all

#!/bin/bash

nrpe="/usr/local/nagios/libexec/check_nrpe"
hostname="127.0.0.1"
check_one="$1"
check_two="$2"

$nrpe -H $hostname -c $check_one
return_one=$?

$nrpe -H $hostname -c $check_two
return_two=$?

output=3

if [ "$return_one" -ge 0 ] && [ "$return_two" -ge 0 ]; then
        output=0
        status="OK"
fi
if [ "$return_one" -ge 1 ] && [ "$return_two" -ge 1 ]; then
        output=1
        status="WARNING"
fi
if [ "$return_one" -eq 2 ] && [ "$return_two" -eq 2 ]; then
        output=2
        status="CRITICAL"
fi

echo $status
exit $output
Locked