HP-UX memory and CPU usage control with sar

#!/bin/ksh
DATE_LAST=`echo "$(date +%d) - 1" | bc`
HOSTNAME=`hostname`
DEG=0
swpin=`sar -w -f /var/adm/sa/sa$DATE_LAST|grep "Average"|awk '{print $2}'`
swpout=`sar -w -f /var/adm/sa/sa$DATE_LAST|grep "Average"|awk '{print $4}'`
cpuidle=`sar -u -f /var/adm/sa/sa$DATE_LAST|grep "Average"|awk '{print $5}'`
if [[ $swpin -gt 0 ]]
then
DEG_VAL=`echo "swpin = $swpin"`
DEG=$(( $DEG + 1 ))
fi
if [[ $swout -gt 0 ]]
then
DEG=$(( $DEG + 1 ))
DEG_VAL=`echo $DEG_VAL| "swpin = $swpin"`
fi
if [[ $cpuidle -lt 50 ]]
then
DEG=$(( $DEG + 1 ))
DEG_VAL=`echo $DEG_VAL| "cpuidle = $cpuidle"`
fi
if [[ $DEG -gt 0 ]]
then
echo $DEG_VAL
else
echo "0"
fi

 

Tagged In:

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me

Related Post

0 Comments

Leave a Reply