Linux主机简易监控脚本 脚本check_host.sh内容如下(每分钟统计一次):
------------------------------------------------------------------------------------------------------------------------
#!/bin/bash
# check_host.sh
# 0 * * * * /u01/app/oracle/custom/oracle/bin/check_host.sh
DAT="`date +%Y%m%d`"
HOUR="`date +%H`"
DIR="/u01/app/oracle/dblog/host_${DAT}/${HOUR}"
DELAY=60
COUNT=60
# whether the responsible directory exist
if ! test -d ${DIR}
then
/bin/mkdir -p ${DIR}
fi
# general check
export TERM=linux
/usr/bin/top -b -d ${DELAY} -n ${COUNT} > ${DIR}/top_${DAT}.log 2>&1 &
# cpu check
/usr/bin/sar -u ${DELAY} ${COUNT} > ${DIR}/cpu_${DAT}.log 2>&1 &
#/usr/bin/mpstat -P 0 ${DELAY} ${COUNT} > ${DIR}/cpu_0_${DAT}.log 2>&1 &
#/usr/bin/mpstat -P 1 ${DELAY} ${COUNT} > ${DIR}/cpu_1_${DAT}.log 2>&1 &
# memory check
/usr/bin/vmstat ${DELAY} ${COUNT} > ${DIR}/vmstat_${DAT}.log 2>&1 &
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载