Build precise queries to find exactly what you need
Press ESC to close
@lucup
Member Since: December 20, 2012
Favorites0
Views
Projects0
Really useful! Easy and quick to install! Thanks a lot!
Reviewed 13 years ago
Hi, good! But just you can improve the performance of the script avoiding the first step where you execute all the systems commands invocation. If you move them to each select cases. Cosider that in the firs option: srfr the (vmstat 1 2) is too slow, so if you want to execute the orther options: numperm|pctused|pgspaceused, is better to avoid the invocation of the (vmstat 1 2), just invoking the vmstat -v that is faster. :-) So here the script modified: ----------------------------------------------------------------------------- #!/bin/sh # #------------------------------------------------------- # Check du taux d'utilisation mmemoie sur AIX - Fabrice Dupre - 11/01/08 # Moving the systems command invocation to each select cases. - LUCUP - Lucas Moreschi - 27/02/2015. #------------------------------------------------------- Syntaxe() { echo " " echo " Command Syntaxe: check_aix_mem.sh [-c val] [-w val] [-t srfr|numperm|pctused|pgspaceused]" echo " " exit 3; } #------------------------------------------------------- if [[ $# == 0 ]] then Syntaxe fi valw=0 valc=0 while [[ $# > 0 ]] do par=$1 case $par in -c) shift valc=$1;; -w) shift valw=$1;; -t) shift type_sortie=$1;; -h) shift Syntaxe exit;; *) shift;; esac done ok=0 str_out="CHARGE MEM:" xcpu=0 total=0 case $type_sortie in srfr) retour_srfr=$(vmstat 1 2 | awk '{ print $8" "$9 }' | tail -1) fr=$(echo $retour_srfr | cut -d " " -f1 ) sr=$(echo $retour_srfr | cut -d " " -f2 ) #echo "sr : $sr - fr : $fr" if [[ $sr -gt 0 ]] && [[ $fr -gt 0 ]] then str_out="$str_out $(expr $sr / $fr)% " if (( $(expr $sr / $fr) > $valw )) then ok=1 fi if (( $(expr $sr / $fr) > $valc )) then ok=2 fi # Sortie au format perfparse echo "$str_out Srfr = $(expr $sr / $fr)%;| Srfr=$(expr $sr / $fr)%;$valw;$valc"; exit $ok # Sortie au format non perfparse #echo "$str_out Srfr = $(expr $sr / $fr)%"; exit $ok else str_out="$str_out 0% " # Sortie au format perfparse echo "$str_out Srfr = 0%;| Srfr=0%;$valw;$valc"; exit $ok # Sortie au format non perfparse #echo "$str_out Srfr = 0%;"; exit $ok fi ;; numperm) retour_numperm=$(vmstat -v | grep numperm | sed 's/ //g' | cut -d " " -f 2) #echo "Numperm : $retour_numperm" str_out="$str_out $retour_numperm% " if (( $retour_numperm > $valw )) then ok=1 fi if (( $retour_numperm > $valc)) then ok=2 fi # Sortie au format perfparse echo "$str_out Numperm = $retour_numperm%;| Numperm=$retour_numperm%;$valw;$valc"; exit $ok ;; pctused) retour_inuse=$(svmon | awk '{ print $3 }' | head -2 | tail -1) retour_memory=$(svmon | awk '{ print $2 }' | head -2 | tail -1) retour_p_used=$(expr 100 * $retour_inuse / $retour_memory) str_out="$str_out $retour_p_used% " if (( $retour_p_used > $valw)) then ok=1 fi if (( $retour_p_used > $valc)) then ok=2 fi # Sortie au format perfparse echo "$str_out MemUsed = $retour_p_used%;| MemUsed=$retour_p_used%;$valw;$valc"; exit $ok ;; pgspaceused) retour_pguse=$(svmon | grep "pg space" | awk '{ print $3 }') retour_memory=$(svmon | awk '{ print $2 }' | head -2 | tail -1) retour_pg_used=$(expr 100 * $retour_pguse / $retour_memory) str_out="$str_out $retour_pg_used% " if (( $retour_pg_used > $valw)) then ok=1 fi if (( $retour_pg_used > $valc)) then ok=2 fi # Sortie au format perfparse echo "$str_out PgSpaceUsed = $retour_pg_used%;| PgSpaceUsed=$retour_pg_used%;$valw;$valc"; exit $ok ;; esac
Reviewed 11 years ago