Froxlor Panel Nagios/Icinga Plugin

This plugin helps to keep track of hanging Froxlor cron jobs. It works only with a modified froxlor_master_cronjob.php and cron_ini.php. (see here for a patch). The below listed script will also serve as the framework for any other checks that may be needed in the future.

Once you have the cronjobs running right use check_froxlor to keep an eye on things:

#!/bin/bash
#
# check_froxlor (0.01b)
#
# A Nagios plugin to test the status of a Froxlor server.
#
# Charles Williams, Schwerin, Germany. <slydder@itadmins.net> 11-01-2012
# Copyright (c) Charles Williams   (http://www.itadmins.net/)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

usage()
{
cat << EOF
usage: $0 [-j cronjob] -w # -c # [-h]

OPTIONS:
   -w      WARNING threashold (seconds)
   -c      CRITICAL threashold (seconds)
   -j      Cronjob to check (default ALL)
   -l      lock directory (default /var/run/)
   -h      Usage, prints this message
EXAMPLE :
    $0 -w 15 -c 20 (checks all cron jobs and reports on delays)
EOF
}

while getopts "hw:c:j:l:" OPTION
do
     case "$OPTION" in
        h)
	    usage 
	    exit 0
	    ;;
        c)
             CRIT=$OPTARG
             ;;
        w)
             WARN=$OPTARG
             ;;
        j)
             CRONJOB=$OPTARG
	          ;;
	     l)
	     		 LOCKDIR=$OPTARG
	     		 ;;
        ?)
             usage
             exit
             ;;
     esac
done

if [[ -z $CRIT ]] || [[ -z $WARN ]]
then
     usage
     exit 1
fi

if [[ -z $LOCKDIR ]]
then
	LOCKDIR="/var/run/"
fi

if [[ -z $CRONJOB ]]
then
	CRONJOB="*"
fi


DIRLEN=$((${#LOCKDIR} + 9))

CRITICAL="2"
WARNING="1"
UNKNOWN="3"
OK="0"


FROXCRONS=`ls ${LOCKDIR}froxcron_${CRONJOB} 2> /dev/null`

if grep -q "*No such file or directory*" <<<$FROXCRONS; then
	echo "Cron jobs are OK"
	exit 0
fi

for FROXCRON in $FROXCRONS
do
	CRONSTART=$(<$FROXCRON)
	CURRENT=`date +%s`
	RUNNING=$(($CURRENT - $CRONSTART))
   
   if [[ $RUNNING > $CRIT ]]
   then
   	echo "CRITICAL: ${FROXCRON:$DIRLEN} Cronjob is marked as still running after $RUNNING seconds"
   	exit 2
   elif [[ $RUNNING > $WARN ]]
   then
   	echo "Warning ${FROXCRON:$DIRLEN} Cronjob is marked as still running after $RUNNING seconds"
   	exit 1
   fi
done

echo "Cron jobs are OK"
exit 0
/var/customers/webs/cw01/wiki/data/pages/froxlor_panel/nagios_plugin.txt · Last modified: 2012/01/12 11:17 by wadmin
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki