check_nb_cleaning_left.sh #!/usr/bin/bash #Script to check cleaning left for Netbackup ################################# ## Pool Name for query in media POOL=$1 ################################# ## Name of cleaning tapes MEDIANAME=$2 ################################# ## Media List quantity for error CRITICAL=$3 ################################# ## Check if parameters are OK if [ $# -lt 3 ];then echo "UNKNOWN: Parameters are not OK USE: $0 EXAMPLE: $0 Pool_de_Limpieza CL 5" exit 3 fi # We use the integer CL for all cleaning tapes for i in $(vmquery -pn $POOL -b | grep $MEDIANAME | grep TLD | awk '{print $1}');do CL=$(/usr/openv/volmgr/bin/vmquery -m $i | egrep "cleanings|left" | awk ' { print $3 }') CR=$? if [ $CR -ne 0 ];then MESSAGE="CRITICAL: Query Error for Media $i" EXIT_CODE=2 fi if [ $CL -lt $CRITICAL ];then MESSAGE=" Cleaning left for Media $i is $CL" EXIT_CODE=2 else MESSAGE=" Cleaning left for Media $i is $CL" EXIT_CODE=0 fi # EXIT_CODE_NG specific variable if any error if [ $EXIT_CODE -ne 0 ];then EXIT_CODE_NG=2 ERROR="$MESSAGE,$ERROR" elif [ $EXIT_CODE -eq 0 ];then ERROR="$MESSAGE,$ERROR" fi done; #If there's any error then 2, print all status if [ "$EXIT_CODE_NG" ];then echo "CRITICAL:$ERROR" exit $EXIT_CODE_NG else echo "OK:$ERROR" exit $EXIT_CODE fi