Hello,
nice script... just the right thing now, I was starting to think about
how to implement the "guess if volume space is enough for next runs"
function for baculareport.pl :-)
Now, if only you could rely on the scheduled jobs output, concerning
tape requirement... I, at least, can't, and even if I see why that
doesn't help me a lot...
Arno
Ludovic Strappazon wrote:
Hi all,
This is a little script we use to check our pools.
We run it in passive mode, once a day with a RunAfterJob.
Ludovic.
------------------------------------------------------------------------
#! /bin/sh
# Author : Ludovic Strappazon. [EMAIL PROTECTED]
# Copyright : Kern Sibbald
# Any comment, advice or enhancement are welcome :-)
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
MYSQL="/usr/bin/mysql -u bacula --password=pT3v5YcPx"
TMP=/tmp
BACULA=/usr/local/bacula
PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
STATUS=""
. $PROGPATH/utils.sh
print_usage() {
echo "Usage: $PROGNAME -P <pool> -M <media-type> -w <warning threshold> -c
<critical threshold>"
}
print_help() {
echo ""
print_usage
echo ""
echo "This plugin checks the space available in the pool against the space
required for the next scheduled backups"
echo "Example : $PROGNAME -P default -M LTO -w 20 -c 10 will check the default pool, return OK if space dispo > 1,20*space required, WARNING if 1,20*space required > space dispo > 1,10*space required, and CRITICAL else."
echo ""
echo "The evaluation of the space required is done by adding the biggest
backups of the same level than the scheduled jobs"
echo "The available space is evaluated by the number of out of retention
tapes and the average VolBytes of these Full tapes"
echo ""
echo "I think this plugin should be used in passive mode, and ran by a
RunAfterJob"
exit 3
}
NB_ARGS=$#
while getopts :P:M:w:c:h OPTION
do
case $OPTION in
P) POOL="$OPTARG"
;;
M) MEDIA_TYPE="$OPTARG"
;;
w) WARNING="$OPTARG"
;;
c) CRITICAL="$OPTARG"
;;
h) print_help
exit 3
;;
*) print_usage
exit 3
;;
esac
done
shift $(($OPTIND - 1))
if [ "$NB_ARGS" -ne 8 ]; then
print_revision $PROGNAME 25/05/2005
print_usage
exit 3
fi
LAST_CHECK=`ps -ef | grep check_ba[Cc]ula_pools.sh | awk {'print $5'} | uniq |
wc -l`
if [ "$LAST_CHECK" -gt 1 ]; then
echo "The last check was not complete, you should increase the
check_period."
exit 3
fi
NB_VOLUMES_OUT_OF_RETENTION=`$MYSQL << EOF
USE bacula
SELECT COUNT(MediaId) from Media, Pool where Media.PoolId=Pool.PoolId and Pool.Name="$POOL" AND LastWritten
<> "NULL" AND UNIX_TIMESTAMP()-UNIX_TIMESTAMP(LastWritten)>Media.VolRetention AND Inchanger =
"1";
EOF
`
NB_VOLUMES_OUT_OF_RETENTION=`echo $NB_VOLUMES_OUT_OF_RETENTION | cut -f 2 -d '
'`
NB_VOLUMES_ERROR=`$MYSQL << EOF
USE bacula
SELECT COUNT(MediaId) from Media, Pool where Media.PoolId=Pool.PoolId and Pool.Name="$POOL" AND
VolStatus="Error" AND Inchanger = "1";
EOF
`
NB_VOLUMES_ERROR=`echo $NB_VOLUMES_ERROR | cut -f 2 -d ' '`
AVERAGE_CAPA_VOLUME=`$MYSQL << EOF
USE bacula
SELECT SUM(VolBytes)/COUNT(MediaId) FROM Media where VolStatus="Full" AND
MediaType="$MEDIA_TYPE";
EOF
`
AVERAGE_CAPA_VOLUME=`echo $AVERAGE_CAPA_VOLUME | cut -f 2 -d ' ' | cut -f 1 -d
'.'`
CAPA_VOLUMES_APPEND=`$MYSQL << EOF
USE bacula
SELECT SUM("$AVERAGE_CAPA_VOLUME"-VolBytes) from Media, Pool where Media.PoolId=Pool.PoolId and
Pool.Name="$POOL" AND VolStatus = "Append" AND Inchanger = "1" AND
MediaType="$MEDIA_TYPE";
EOF
`
CAPA_VOLUMES_APPEND=`echo $CAPA_VOLUMES_APPEND | cut -f 2 -d ' '`
echo "st
1
q" | $BACULA/etc/bconsole | sed -n /Scheduled/,/Running/p | grep Backup | tr -s
[:blank:] | tr '[:blank:]' '@' > ${TMP}/Scheduled.txt
CAPA_REQUIRED=0
for LINE in `cat ${TMP}/Scheduled.txt`
do
SCHEDULED_JOB=`echo $LINE | awk -F@ '{print $6}'`
LEVEL=`echo $LINE | awk -F@ '{print $1}' | cut -c 1`
MAX_VOLUME_JOB_FOR_LEVEL=`$MYSQL << EOF
USE bacula
SELECT MAX(JobBytes) from Job, Pool where Level="$LEVEL" AND Job.Name="$SCHEDULED_JOB"
AND Job.PoolId=Pool.PoolId AND Pool.Name="$POOL";
EOF
`
MAX_VOLUME_JOB_FOR_LEVEL=`echo $MAX_VOLUME_JOB_FOR_LEVEL | cut -f 2 -d ' ' `
CAPA_REQUIRED=$[CAPA_REQUIRED+MAX_VOLUME_JOB_FOR_LEVEL]
done
rm ${TMP}/Scheduled.txt
CAPA_WARNING=`echo $[(WARNING+100)*CAPA_REQUIRED]/100 | bc | cut -f 1 -d '.'`
CAPA_CRITICAL=`echo $[(CRITICAL+100)*CAPA_REQUIRED]/100 | bc | cut -f 1 -d '.'`
CAPA_DISP=$[NB_VOLUMES_OUT_OF_RETENTION*AVERAGE_CAPA_VOLUME+CAPA_VOLUMES_APPEND]
echo "Required : $[CAPA_REQUIRED/1000000000] Go, available : $[CAPA_DISP/1000000000]
Go, Volumes Error : $NB_VOLUMES_ERROR"
if [ "$CAPA_DISP" -gt $CAPA_WARNING ]; then
exit 0
elif [ "$CAPA_DISP" -gt $CAPA_CRITICAL ];then
exit 1
else
exit 2
fi
exit 3
--
IT-Service Lehmann [EMAIL PROTECTED]
Arno Lehmann http://www.its-lehmann.de
-------------------------------------------------------
SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate
online with coworkers and clients while avoiding the high cost of travel and
communications. There is no equipment to buy and you can meet as often as
you want. Try it free.http://ads.osdn.com/?ad_id=7402&alloc_id=16135&op=click
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users