#!/bin/sh
# Solaris system_monitor
#. /.profile
day=`date +%m%d%Y`
file="/var/log/system/sysinfo$day"
if [ -f $file ]; then
echo "ok">/dev/null
[@more@]
#!/bin/sh
# Solaris system_monitor
#. /.profile
day=`date +%m%d%Y`
file="/var/log/system/sysinfo$day"
if [ -f $file ]; then
echo "ok">/dev/null
else
echo " date cpu mem swap load average oracle sessions">>$file
echo " user system idle free free 1 5 15">>$file
echo "">>$file
fi
time=`date '+%m%d %H:%M:%S '`
load=`uptime |grep load|sed s/,//g|awk '{printf"%10s %6s %6s", $10,$11,$12}'`
#cpu=`vmstat |grep -v [cpu][swap]|awk '{printf "%8s %6s %9s", $20,$21,$22}'`
cpu=`vmstat 1 2 | sed -n '$p' |awk '{printf "%8s %6s %9s", $20,$21,$22}'`
real=`vmstat |grep -v [cpu][swap]|awk '{printf "%12s %10s",$5,$4}'`
httpd_number=`ps -ef|grep httpd|grep -v grep|wc -l|awk '{printf "%9d",$1}'`
oracle_number=`ps -ef|grep "LOCAL="|grep -v grep|wc -l|awk '{printf "%9d",$1}'`
echo "$timet$cpu$real$load$oracle_number" >>$file
========================================='
#!/bin/sh
# linux system_monitor
day=`date +%m%d%Y`
file="/var/log/system/sysinfo$day"
if [ -f $file ]; then
echo "ok">/dev/null
else
echo " date cpu mem load average sessions">>$file
echo " user system idle free 1 5 15">>$file
echo "">>$file
fi
time=`date '+%m%d %H:%M:%S '`
load=`uptime |grep load|sed s/,//g|awk '{printf"%10s %6s %6s", $8,$9,$10}'`
cpu=`vmstat 1 2 | sed -n '$p' |awk '{printf "%8s %6s %9s", $13,$14,$15}'`
real=`vmstat |grep -v [cpu][swap]|awk '{printf "%12s",$4}'`
httpd_number=`ps -ef|grep httpd|grep -v grep|wc -l|awk '{printf "%9d",$1}'`
app_number=`ps -ef |grep "java"|grep -v grep | wc -l`
oracle_number=`ps -ef|grep '/db/mysql/bin/mysqld' |grep -v grep|wc -l|awk '{printf "%9d",$1}'`
echo "$time $cpu$real$load$httpd_number+$app_number+$oracle_number" >>$file
============================================
root.cron
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /var/log/system/system_monitor&
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8806316/viewspace-912060/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/8806316/viewspace-912060/