/ Published in: Bash
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/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} root@${strServer} "${cmdAggr}" | grep aggr | sed 's/^ *//g' | cut -d" " -f1` for var in `echo ${lstAggr}` do uAggr=`${binSSH} root@${strServer} "${cmdAggrSpc} ${var}" | tail -5 | head -1 | sed 's/ */ /g' | sed 's/KB//g' | cut -d" " -f3` aAggr=`${binSSH} root@${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}