CPUやメモリーの概況を知ることができる。
bash-3.00$ cat mstat.sh
#!/bin/sh
# for Solaris
# 080709 ST(KRB) http://code.nanigac.com/source/view/334
# 080820 ST(KRB) fix LANG as C because incompatibility of swap -s output
LANG=C
export LANG
GREP=/usr/bin/grep
AWK=/usr/bin/awk
SED=/usr/bin/sed
VMSTAT=/usr/bin/vmstat
TAIL=/usr/bin/tail
PRTCONF=/etc/prtconf
SWAP=/etc/swap
PSR=/usr/sbin/psrinfo
# PHYSICAL Memory Size
PHYS_MEM_SIZE=`$PRTCONF | $GREP "Mem" | $AWK '{print $3}'`
PHYS_FREE_SIZE=`$VMSTAT 1 2 | $TAIL -1 | $AWK '{print $5}'`
PHYS_FREE_SIZE=`expr $PHYS_FREE_SIZE / 1024`
PHYS_USED_SIZE=`expr $PHYS_MEM_SIZE - $PHYS_FREE_SIZE`
X1=`expr $PHYS_USED_SIZE \* 100`
PHYS_USED_PERC=`expr $X1 / $PHYS_MEM_SIZE`
echo "------ PHYSICAL MEMORY ------"
echo "PHYS_MEM_SIZE =" $PHYS_MEM_SIZE " MB"
echo "PHYS_FREE_SIZE =" $PHYS_FREE_SIZE " MB"
echo "PHYS_USED_SIZE =" $PHYS_USED_SIZE " MB"
echo "PHYS_USED_PERC =" $PHYS_USED_PERC " %"
# SWAP Memory Size
#-bash-3.00$ swap -s
#total: 784620k bytes allocated + 362184k reserved = 1146804k used, 5191064k available
SWAP=`/usr/sbin/swap -s`
SWAP_FREE_SIZE=`echo $SWAP | $AWK '{print $11}' | $SED 's/k//'`
SWAP_USED_SIZE=`echo $SWAP | $AWK '{print $9}' | $SED 's/k//'`
SWAP_MEM_SIZE=`expr $SWAP_FREE_SIZE + $SWAP_USED_SIZE`
SWAP_MEM_SIZE=`expr $SWAP_MEM_SIZE / 1024`
SWAP_USED_SIZE=`expr $SWAP_USED_SIZE / 1024`
X1=`expr $SWAP_USED_SIZE \* 100`
SWAP_USED_PERC=`expr $X1 / $SWAP_MEM_SIZE`
SWAP_FREE_SIZE=`expr $SWAP_FREE_SIZE / 1024`
echo "------ SWAP ------"
echo "SWAP COMMNAD =" $SWAP
echo "SWAP_MEM_SIZE =" $SWAP_MEM_SIZE " MB"
echo "SWAP_FREE_SIZE =" $SWAP_FREE_SIZE " MB"
echo "SWAP_USED_SIZE =" $SWAP_USED_SIZE " MB"
echo "SWAP_USED_PERC =" $SWAP_USED_PERC " %"
# PROCESSOR
echo "------ PROCESSORS ------"
$PSR -pv
0 件のコメント:
コメントを投稿