????3£ó?μ?Linux?à????±?(2)
then
fty89@163.com
fi4?¢ ?à??CPUoí?ú′?μ?ê1ó??é??
#!/bin/bash
#script to capture system statistics
OUTFILE=/home/xu/capstats.csvDATE='date +%m/%d/%Y'TIME='date +%k:%m:%s'TIMEOUT='uptime'VMOUT='vmstat 1 2' USERS='echo $TIMEOUT | gawk '{print $4}' 'LOAD='echo $TIMEOUT | gawk '{print $9}' | sed "s/,//' 'FREE='echo $VMOUT | sed -n '/[0-9]/p' | sed -n '2p' | gawk '{print $4} ' 'IDLE='echo $VMOUT | sed -n '/[0-9]/p' | sed -n '2p' |gawk '{print $15}' 'echo "$DATE,$TIME,$USERS,$LOAD,$FREE,$IDLE" >> $OUTFILE5?¢è?·????à???÷?ú
#!/bin/bash
# check_xu.sh
# 0 * * * * /home/check_xu.sh
DAT="`date +%Y%m%d`"
HOUR="`date +%H`"
DIR="/home/oslog/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 &
# I/O check
/usr/bin/iostat ${DELAY} ${COUNT} > ${DIR}/iostat_${DAT}.log 2>&1 &
# network check
/usr/bin/sar -n DEV ${DELAY} ${COUNT} > ${DIR}/net_${DAT}.log 2>&1 &
#/usr/bin/sar -n EDEV ${DELAY} ${COUNT} > ${DIR}/net_edev_${DAT}.log 2>&1 &·??úcrontabà???D?ê±×??ˉ?′DD£o
0 * * * * /home/check_xu.sh?a?ù?á?ú/home/oslog/host_yyyymmdd/hh??????éú3é?÷D?ê±cpu?¢?ú′??¢í???£?IOμ?í3??êy?Y?£
è?1??3??ê±????2úéú?êìaá?£??í?éò?è¥?′??ó|μ?è???D??¢£??′?′μ±ê±μ??÷?úD??üè?o??£
相关新闻>>
- 发表评论
-
- 最新评论 更多>>