El SCRIPT solicita el valor WARNING y CRITICO del uso de memoria. Pasando estos umbrales, reportara en la consola NAGIOS según corresponda :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#!/bin/bash # PORCENTAJES EJEMPLO 95 WARNING Y 98 CRITICAL warning=$1 critical=$2 if [ -z "$critical" ] || [ -z "$warning" ]; then echo "UNKNOWN" exit 3 fi # MEMORIA TOTAL USADA um=`svmon -G | head -2|tail -1| awk {'print $3'}` um=`expr $um / 256` # MEMORIA TOTAL tm=`lsattr -El sys0 -a realmem | awk {'print $2'}` tm=`expr $tm / 1024` # MEMORIA LIBRE Y PORCENTAJE fm=`expr $tm - $um` pt=`echo "scale=2; $fm/$tm" | bc` ps=`echo "scale=2; $pt * 100" | bc` # PORCENTAJE DE MEMORIA USADA pa=`echo "scale=2; $um/$tm" | bc` pr=`echo "scale=2; $pa * 100" | bc` porusado=$pr if [ "$porusado" -gt "$warning" ] && [ "$porusado" -lt "$critical" ]; then echo "WARNING - USADO $porusado% ${um}MB FREE $ps% ${fm}MB" exit 1 elif [ "$porusado" -ge "$critical" ]; then echo "CRITICAL - USADO $porusado% ${um}MB FREE $ps% ${fm}MB" exit 2 else echo "OK - USADO $porusado% ${um}MB FREE $ps% ${fm}MB" exit 0 fi |