Blog Archives

Cant wait…

After reading this benchmark: http://blog.centreon.com/public/Centreon_Engine_Benchmarks.pdf, I was wondering. isn’t it strange that their own benchmark is telling us they beat the good-old-nagios on all elements?

Do not get me wrong, I still believe that Centreon is a wonderful product. But i cant ignore the fact that the Nagios Core / Nagios XI are on the move as well.  And for some reason I get the feeling they are referring to history. Last time I was informed,  Nagios employed a team of developers as well in developing Nagios XI. And next to that, Nagios also enables OS programmers to commit code: http://www.nagios.org/contribute.

Please dear Centreon, don’t spoil your good name and stick to the facts. You have a great product, no need for bashing. Next to that, don’t use a translate without review in your benchmark documents.

Having that said, what happed to Icinga?

It seams that Icinga is well on their way as well seeing this sheet: https://www.icinga.org/nagios/feature-comparison/

Anyway, any monitoring needs?

It seems a crossroad is nearing in which you are forced to pick a side and stick by it.

And yet somehow, I cant suppress a feeling of sadness about this development.
Goodbye years of scripting, hacking and rewriting happiness, Hello ‘next-next-finish’ world 😉

Any insights?
Please share them with us web reading it-guy folk  :=)

Advertisements

Fixing the monitoring hosts > hosts view in centreon 2.1.4

When opening the Monitoring > Hosts > Hosts view to view all the available and configured hosts in Centreon 2.1.4 you will get a blank result. This happens because there is a coding error in the following file.

/usr/local/centreon/www/include/monitoring/status/Hosts/xml/hostXML.php on line 249

To correct it you need to add a else statement to the if, elseif validation that happens there. So open the file listed above using your fav. editor (vim in my case)

vim /usr/local/centreon/www/include/monitoring/status/Hosts/xml/hostXML.php

Version 2.1.4

Skip to line 249 typing ” :249 ” followed by an enter stroke.
On that line there should be something like;

if (($ndo["last_hard_state_change"] > 0) && ($ndo["last_hard_state_change"] >= $ndo["last_state_change"]))
                        $hard_duration = Duration::toString(time() - $ndo["last_hard_state_change"]);
                else if ($ndo["last_hard_state_change"] > 0)
                        $hard_duration = " N/A ";

Change it to this by adding the part starting from “else”.

if (($ndo["last_hard_state_change"] > 0) && ($ndo["last_hard_state_change"] >= $ndo["last_state_change"]))
                        $hard_duration = Duration::toString(time() - $ndo["last_hard_state_change"]);
                else if ($ndo["last_hard_state_change"] > 0)
                        $hard_duration = " N/A ";
                else
                        $hard_duration = " unknown ";

Version 2.1.8

Goto rule 272 in the same file and locate this piece of code:

if (($ndo["last_hard_state_change"] > 0) && ($ndo["last_hard_state_change"] >= $ndo["last_state_change"]))
                        $hard_duration = Duration::toString(time() - $ndo["last_hard_state_change"]);
                else if ($ndo["last_hard_state_change"] > 0)
                        $hard_duration = " N/A ";

Add the following to make it work.

if (($ndo["last_hard_state_change"] > 0) && ($ndo["last_hard_state_change"] >= $ndo["last_state_change"]))
                        $hard_duration = Duration::toString(time() - $ndo["last_hard_state_change"]);
                else if ($ndo["last_hard_state_change"] > 0)
                        $hard_duration = " N/A ";
                else
                        $hard_duration = "N/A";

This same rule is responsible for the following errors in your apache error_log.

PHP Notice: Undefined variable: hard_duration in /usr/local/centreon/www/include/monitoring/status/Hosts/xml/hostXML.php on line 271, referer: http://centreon.amis.nl/centreon/main.php?p=20102&o=h

This change should fix it for ya.

Grtz, Chris.

NRPE – Check_memory script

this script is intended to “mime” the NSClient++ checkMem option on linux. Most check_mem scripts i have found where rather “minimal” so i ended up writing my own one. Feel free to test, use, alter, redis or what ever with it 🙂

Here is a new version. Improvements.

– Var footprints reduced to a bare minimum.
– Free command is now only executed once.
– Corrected the swap validation that was using the wrong vars.
– Added small corrections like adding ; within “ execs to mark end of command etc.

Here you go 🙂

    #!/bin/bash
#
#
# @Type 	: Bash
# @Date 	: 19-05-2009
# @Author 	: Chris Gralike
# @Category	: Nagios Monitoring/SLA
# @Category	: MemoryCheck Linux, All memory spaces
# @Company	: AMIS Services BV.
# @License	: GNU_Public
# @ToDo		: See Comments in script. Suggestions are welcome... 
##

## You are free to alter, modify and distribute the content of this file
 # This file is offered "as is", and we offer no guarantee on functionality
 # and or outcome of this check. Neither can the author nor AMIS be
 # responsible for any damages caE by this script. 
 #
 # Have fun with it, and we hope it proves usefull
 # Script is based on precentage orientated monitoring / SLAs
 ##

#Get Options
while getopts 'u:v:w:x:y:z:hpef' OPT; do
  case $OPT in
    u) U=$OPTARG;;
    v) V=$OPTARG;;
    w) W=$OPTARG;;
    x) X=$OPTARG;;
    y) Y=$OPTARG;;
    z) Z=$OPTARG;;
    e)  E="yes";;
    f)  FR="yes";;
    p)  P="yes";;
    h)  H="yes";;
    *)  unknown="yes";;
  esac
done
#Help Output
USAGE="
	usage: $0 [ -option [value]]
	
	[options:]
		-h		->	Show this help page
		-p		->	Show performance options
		-e		->	Warn/Crit based on usage precentage, warn/crit based on usage orientation
		-f		->	Warn/Crit based on free precantage, warn/crit based on free space orientation
		-u [valeu]	->	Physical warning treshold (in %)
		-v [value]	->	Physical critical treshold (in %)
		-w [value]	->	Virtual waring treshold (in %)	
		-x [value]	->	Virtual critical treshold (in%)
		-y [value]	->	Swap warning value (in%)
		-z [value]	->	Swap critical value (in%)
"
#Show usage if requested
if [ "$H" = "yes" -o $# -lt 1 ]; then
	echo "$USAGE"
	exit 0
fi
#Check if all the thresholds are defined.
if [ "$W" = "" -o "$X" = "" -o "$U" = "" -o "$V" = "" -o "$Y" = "" -o "$Z" = "" ]; then
	echo "All the [u,v,w,x,y,z] options should be defined! \r\n"
	exit 0
fi
#Check if all the thresholds are integers
# if syntax is $0 -e -u 10 -v 10 -w 10 -x 10 -y 10 -z 10 -p things are allright
# if syntax is $0 -e -u 10 -v 10 -w 10 -x 10 -y 10 -z -p A bunch of errors arise because " " is not equal too ""
# and failes the check above.
# This typo needs to be fixed someday...
#Check the orientation
if [ "$E" = "yes" -a "$FR" = "yes" ]; then
	echo "You cant use both the free, as E orientation for the tresholds. Please select -e or -f as orientation"
	exit 0
elif [ "$E" = "yes" ]; then
	# Check the critical / warning thresholds
	if [ "$W" -gt "$X" -o "$U" -gt "$V" -o "$Y" -gt "$Z" ]; then
		echo "Warning: Warning > Critical while using usage orientation!"
	fi	

elif [ "$FR" = "yes" ]; then
	# Check the warning / Critical thresholds
	if [ "$W" -lt "$X" -o "$U" -lt "$V" -o "$Y" -lt "$Z" ]; then
                echo "Warning: Warning < Critical while using free space orientation!"
        fi
else
	echo "Please define an orientation using either the -e or the -f option"
	exit 0;
fi

#Get physiscal numbers 
FRE=`free -m`

PT=`echo "$FRE" | grep Mem | awk '{ print $2; exit;}';`
PU=`echo "$FRE" | grep Mem | awk '{ print $3; exit;}';`
FP=$(($PT-$PU));
#Get virtual memory numbers
VU=`echo "$FRE" | grep buffers/cache | awk '{ print $3; exit;}';`
VF=`echo "$FRE" | grep buffers/cache | awk '{ print $4; exit;}';`
VT=$(($VU+$VF));
#Get Swapped memory numbers
ST=`echo "$FRE" | grep Swap | awk '{ print $2; exit;}';`
SU=`echo "$FRE" | grep Swap | awk '{ print $3; exit;}';`
SF=$(($ST-$SU));

#still needs to be done in an nice syntax.
#Start validating our numbers.
if [ "$E" = "yes" ]; then
	#calculate E precentages
	PPF=`echo "scale=5; (100/$PT)*$PU" | bc -l | awk -F '.' '{ print $1; exit; }'`
	VPF=`echo "scale=5; (100/$VT)*$VU" | bc -l | awk -F '.' '{ print $1; exit; }'`
	SPF=`echo "scale=5; (100/$ST)*$SU" | bc -l | awk -F '.' '{ print $1; exit; }'`
	#still needs to be done in an nice syntax.
	if [ "$P" = "yes" ]; then
        	#not sure about the syntax...
		PD="|Ph=$PPF%;$U;$V; Vi=$VPF%;$W;$X; Sw=$SPF%;$Y;$Z;"
	else
        	PD=""
	fi

	MSG="Ph:$PU/$PT($PPF%), Vi:$VU/$VT($VPF%), Sw:$SU/$ST($SPF%) $PD"

	#Validate Physical Memory
	if [ "$PPF" -gt "$U" -a "$PPF" -gt "$V" ]; then
		NPE=2
	elif [ "$PPF" -gt "$U" -a "$PPF" -lt "$V" ]; then
		NPE=1
	elif [ "$PPF" -lt "$U" -a "$PPF" -lt "$V" ]; then
		NPE=0
	else
		#unknown crit and warn the same?
		NPE=3
	fi 
	#Validate Virtual Memory
	if [ "$VPF" -gt "$W" -a "$VPF" -gt "$X" ]; then
       	        NVE=2
        elif [ "$VPF" -gt "$W" -a "$VPF" -lt "$X" ]; then
       		NVE=1
   	elif [ "$VPF" -lt "$W" -a "$VPF" -lt "$X" ]; then
               	NVE=0
       	else
               	#unknown crit and warn the same?
               	NVE=3
       	fi
	#Validate Swap memory
	if [ "$SPF" -gt "$W" -a "$SPF" -gt "$X" ]; then
                NSE=2
        elif [ "$SPF" -gt "$W" -a "$SPF" -lt "$X" ]; then
                NSE=1
        elif [ "$SPF" -lt "$W" -a "$SPF" -lt "$X" ]; then
                NSE=0
        else
                #unknown crit and warn the same?
                NSE=3
        fi
	#We only want to see the most critical,...
	if [ "$NPE" -eq "2" -o "$NVE" -eq "2" -o "$NSE" -eq "2" ]; then
		echo "Critical - $MSG"
		exit 2
	elif [ "$NPE" -eq "1" -o "$NVE" -eq "1" -o "$NSE" -eq "1" ]; then
		echo "Warning - $MSG"
		exit 1
	elif [ "$NPE" -eq "0" -a "$NVE" -eq "0" -a "$NSE" -eq "0" ]; then
                echo "Ok - $MSG"
                exit 0
	else
		echo "Unknown - $MSG"
		exit 3
	fi
elif [ "$FR" = "yes" ]; then
	#calculate free precentages
	PPF=`echo "scale=5; (100/$PT)*$FP" | bc -l | awk -F '.' '{ print $1; exit; }'`
	VPF=`echo "scale=5; (100/$VT)*$VF" | bc -l | awk -F '.' '{ print $1; exit; }'`
	SPF=`echo "scale=5; (100/$ST)*$SF" | bc -l | awk -F '.' '{ print $1; exit; }'`
	
	#still needs to be done in an nice syntax.
	if [ "$P" = "yes" ]; then
			#not sure about the syntax...
			PD="|Ph=$PPF%;$U;$V; Vi=$VPF%;$W;$X; Sw=$SPF%;$Y;$Z;"
	else
			PD=""
	fi

	MSG="Ph:$FP/$PT($PPF%), Vi:$VF/$VT($VPF%), Sw:$SF/$ST($SPF%) $PD"

        #Validate Physical Memory
        if [ "$PPF" -lt "$U" -a "$PPF" -lt "$V" ]; then
                NPE=2
        elif [ "$PPF" -lt "$U" -a "$PPF" -gt "$V" ]; then
                NPE=1
        elif [ "$PPF" -gt "$U" -a "$PPF" -gt "$V" ]; then
                NPE=0
        else
                #unknown crit and warn the same?
                NPE=3
        fi
        #Validate Virtual Memory
        if [ "$VPF" -lt "$W" -a "$VPF" -lt "$X" ]; then
                NVE=2
        elif [ "$VPF" -lt "$W" -a "$VPF" -gt "$X" ]; then
                NVE=1
        elif [ "$VPF" -gt "$W" -a "$VPF" -gt "$X" ]; then
                NVE=0
        else
                #unknown crit and warn the same?
                NVE=3
        fi
        #Validate Swap memory
        if [ "$SPF" -lt "$W" -a "$SPF" -lt "$X" ]; then
                NSE=2
        elif [ "$SPF" -lt "$W" -a "$SPF" -gt "$X" ]; then
                NSE=1
        elif [ "$SPF" -gt "$W" -a "$SPF" -gt "$X" ]; then
                NSE=0
        else
                #unknown crit and warn the same?
                NSE=3
        fi
        #We only want to see the most critical,...
        if [ "$NPE" -eq "2" -o "$NVE" -eq "2" -o "$NSE" -eq "2" ]; then
                echo "Critical - $MSG"
                exit 2
        elif [ "$NPE" -eq "1" -o "$NVE" -eq "1" -o "$NSE" -eq "1" ]; then
                echo "Warning - $MSG"
                exit 1
        elif [ "$NPE" -eq "0" -a "$NVE" -eq "0" -a "$NSE" -eq "0" ]; then
                echo "Ok - $MSG"
                exit 0
        else
		 echo "Unknown - $MSG"
                exit 3
        fi
else
	echo "Something is very off..... please review all the settings, or report this as a bug"
	exit 3
fi

Rgrds Chris

Ndo Utils startup script for usage with chkconfig.

Is functional, there is a bug in the start portion that i still need to fix. But it will start the deamon correctly and if you use the “service ndodaemon rewrite-lock” the status and stop functions will also work correctly.


#!/bin/sh
#
# chkconfig: 345 90 01
# description: Nagios NDO Utils Deamon
# ./etc/init.d/ndodaemon

prefix=/usr/sbin
Bin=ndo2db
NdoBin=$prefix/$Bin
NdoUsr=root
NdoConf=/usr/local/nagios/etc/ndo2db.cfg
RunFile=/usr/local/nagios/var/ndo2db.lock

#check if ndobin exists
if [ ! -f $NdoBin ]; then
echo "NDO Binairy doesnt exist!"
exit 1
fi

#check if ndoConfig exists
if [ ! -f $NdoConf ]; then
echo "NDO Config file not found!"
exit 1
fi

case $1 in

start)
if test -f $RunFile; then
echo "NDO Deamon allready started"
exit 1
else
echo -n "Starting the NDO Deamon:"
$NdoBin -c $NdoConf & > /dev/null 2>&1;

if [ $? -eq 0 ]; then
for i in 1 2 3 4 5 6 7 8 9 10 ; do
echo -n ".";
sleep 1
done
P=`ps -C $Bin -o pid | grep -P [0-9]`

echo "Done."
exit 0
else
echo "Failed to start the deamon, check the config file!"
exit 1
fi
fi
;;

stop)
if test -f $RunFile; then
#make sure we have both services!
`ps -C $Bin -o pid | grep -P [0-9] > $RunFile`
#Get first PID
ndo1PID=`head -n 1 $RunFile`;
#Get 2nd PID
ndo2PID=`tail -n 1 $RunFile`;
echo $ndo1PID
echo $ndo2PID
#need to make this a bit more logic, but it works for the moment....
kill $ndo1PID > /dev/null 2>&1;
kill $ndo2PID > /dev/null 2>&1;
rm $RunFile > /dev/null
if [ $? -eq 0 ]; then
echo "Done."
exit 0;
else
echo "Failed."
exit 1
fi
else
echo "No NDO deamon to stop!"
exit 1;
fi

;;

rewrite-lock)
ps -C $Bin -o pid | grep -P [0-9] > $RunFile
;;

status)
if test -f $RunFile; then
#We have a runfile, so we check based on PID
ndo1PID=`head -n 1 $RunFile`;
ndo2PID=`tail -n 1 $RunFile`;
#Process Parent NDO deamon
if [ $ndo1PID > 0 ]; then
ps -p $ndo1PID > /dev/null 2>&1;
if [ $? -eq 0 ]; then
Status1="NDO Parent (PID $ndo1PID) is alive!"
else
Status1="NDO Parent (PID $ndo1PID) not alive, remove lock file then check for orphan processes then restart deamon."
fi
else
Status1="NDO Parent (PID $ndo1PID) not alive!"
fi

if [ $ndo2PID > 0 ]; then
ps -p $ndo2PID > /dev/null 2>&1;
if [ $? -eq 0 ]; then
Status2="NDO Child (PID $ndo2PID) is alive!"
else
Status2="NDO Child (PID $ndo2PID) not alive!"
fi
else
Status2="NDO child (PID $ndo2PID) not alive!"
fi
echo $Status1
echo $Status2
exit 0
else
#We dont have a Runfile so lets see if someone started it manually.
ps -C $Bin > /dev/null 2>&1;
if [ $? -eq 0 ]; then
echo "NDO process seems to be manually started!"
exit 1
else
echo "NDO Deamon is not running."
exit 1
fi
fi
;;

*)
echo "Usage: $0 {start|stop|status|rewrite-lock}"
exit 1
;;
esac