Return to Snippet

Revision: 45761
at May 7, 2011 00:22 by crackiron


Initial Code
#!/bin/bash
#####################################
#
# Script para monitorizar el tamano de los agregados
# 04/05/2011 Jose Ramon Lambea
# -v para verbose.
#
#####################################

stat=0
strServer=$1
maxperuAggr=$2
verbose=$3
binSSH='/usr/bin/ssh'
cmdAggr='aggr status'
cmdAggrSpc='aggr show_space'
lstAggr=`${binSSH} [email protected]${strServer} "${cmdAggr}" | grep aggr | sed 's/^ *//g' | cut -d" " -f1`

for var in `echo ${lstAggr}`
do
        uAggr=`${binSSH} [email protected]${strServer} "${cmdAggrSpc} ${var}" | tail -5 | head -1 | sed 's/  */ /g' | sed 's/KB//g' | cut -d" " -f3`
        aAggr=`${binSSH} [email protected]${strServer} "${cmdAggrSpc} ${var}" | tail -5 | head -1 | sed 's/  */ /g' | sed 's/KB//g' | cut -d" " -f5`
        uAggrGB=`echo "scale=2;${uAggr}/1073741824" | bc`
        aAggrGB=`echo "scale=2;${aAggr}/1073741824" | bc`
        tAggrGB=`echo "scale=2;${uAggrGB}+${aAggrGB}" | bc`
        peruAggr=`echo "scale=2;${uAggrGB}/${tAggrGB}*100" | bc | cut -d"." -f1`

        if [ "${verbose}" == "-v" ]; then
                echo "Espacio usado en " ${var} ": " ${uAggrGB} "GB"
                echo "Espacio libre en " ${var} ": " ${aAggrGB} "GB"
                echo "Espacio total en " ${var} ": " ${tAggrGB} "GB"
                echo "Porcentaje usado : " ${peruAggr} "%"
        fi

        if (( $peruAggr>$maxperuAggr )); then
                echo ${var} " tiene mas de " ${maxperuAggr} "% ocupado: " ${peruAggr} "%. "
                stat=2
        fi

done

if (( $stat==0 )); then
        echo "Control finalizado sin incidencias"
fi

exit ${stat}

Initial URL


Initial Description


Initial Title
nagios: netapp ontap 8 control de tamaño por agregado

Initial Tags


Initial Language
Bash