1,提取系统负载信息
复制代码 代码如下:
#!/bin/sh
host=$(hostname)
channel=$(hostname | sed 's/[0-9]//g')
runday=$(date +%Y-%m-%d)
IPhost=$(/sbin/ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')
i=1
while [ $i -le 120 ];do
rundaytime=$(date "+%Y-%m-%d %H:%M:%S")
/bin/cat /proc/loadavg | awk -F " " '{print "'"$rundaytime"'"","$1","$2","$3","$4","$5}' /tmp/$(hostname)-${runday}load.txt
/usr/bin/sar -u 1 1 | grep -v Average | /bin/sed -n '4,$p' | awk -F " " '{print "'"$rundaytime"'"","$4","$6","$7","$9}' /tmp/$(hostname)-${runday}sar.txt
i=$((i+1))
sleep 59
done
awk -F "," '{print "'"$host"'"",""'"$channel"'"",""'"$IPhost"'"","$1","$2","$3","$4","$5}' /tmp/$(hostname)-${runday}sar.txt > /tmp/$(hostname)${runday}sar.txt
awk -F "," '{print "'"$host"'"",""'"$channel"'"",""'"$IPhost"'"","$1","$2","$3","$4","$5","$6}' /tmp/$(hostname)-${runday}load.txt > /tmp/$(hostname)${runday}load.txt
rm -rf /tmp/$(hostname)-${runday}sar.txt
rm -rf /tmp/$(hostname)-${runday}load.txt
2,代码2
复制代码 代码如下:
#!/bin/sh
PDIR=/monitor/nagios/shell/sarlog
runday=$(date +%Y-%m-%d)
TmpDir=/monitor/nagios/tmp
for i in `/bin/cat /monitor/nagios/shell/sarlog/machine.lst`
do
/usr/bin/scp ${PDIR}/sarlog.sh ${i}:/root && /usr/bin/rsh ${i} /root/sarlog.sh &
done
3,代码3
复制代码 代码如下:
#!/bin/sh
PDIR=/monitor/nagios/shell/sarlog
runday=$(date +%Y-%m-%d)
TmpDir=/monitor/nagios/shell/sarlog/log
Machinelst=/monitor/nagios/shell/sarlog/machine.lst
for i in `/bin/cat /monitor/nagios/shell/sarlog/machine.lst`
do
/usr/bin/scp ${i}:/tmp/*${runday}sar.txt ${TmpDir}
/usr/bin/scp ${i}:/tmp/*${runday}load.txt ${TmpDir}
done
/bin/cat ${TmpDir}/*${runday}sar.txt ${TmpDir}/Tmp${runday}.txt
/bin/cat ${TmpDir}/*${runday}load.txt ${TmpDir}/${runday}loadResult.txt
count=1
Line=$(cat ${TmpDir}/Tmp${runday}.txt |wc -l)
>${TmpDir}/Result${runday}.txt
while [ "$count" -le "$Line" ]
do
Idle=$(sed -n "${count}p" ${TmpDir}/Tmp${runday}.txt | awk -F "," '{print $8}')
Busy=`echo "scale=2;100-$Idle"|bc`
sed -n "${count}p" ${TmpDir}/Tmp${runday}.txt | sed "s/$/,$Busy/g" ${TmpDir}/${runday}sarResult.txt
let count=count+1
done
/usr/local/mysql/bin/mysql -u root -D nagios -pbj7n48dM <<EOF
load data infile '${TmpDir}/${runday}sarResult.txt' into table t_daily_stats FIELDS TERMINATED BY ',';
load data infile '${TmpDir}/${runday}loadResult.txt' into table t_daily_load FIELDS TERMINATED BY ',';
EOF
rm -rf ${TmpDir}/*${runday}sar.txt
rm -rf ${TmpDir}/*${runday}load.txt
rm -rf rm -rf ${TmpDir}/*${runday}.txt
磁盘IO,系统负载
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 刘欢《雨中的树(新歌加精选)2CD》德国HD24K金碟[WAV+CUE]
- 郑源 《世间情歌》6N纯银SQCD[WAV+CUE][1G]
- 群星《粤潮2HQII》头版限量编号[低速原抓WAV+CUE][991M]
- 群星《2023好听新歌21》十倍音质 U盘音乐[WAV分轨][1G]
- 《热血传奇》双11感恩回馈 超值狂欢30天
- 原神5.2版本活动汇总 5.2版本活动有哪些
- 张敬轩.2010-NO.ELEVEN【环球】【WAV+CUE】
- 黄丽玲.2006-失恋无罪【艾回】【WAV+CUE】
- 阿达娃.2024-Laluna【W8VES】【FLAC分轨】
- 宝可梦大集结段位等级划分表大全 大集结段位一览
- 龙腾世纪影障守护者工坊与装备如何升级 工坊与装备升级说明
- 龙腾世纪影障守护者全成就攻略分享 龙腾世纪4全成就列表一览
- 《剑星》更新四套全新战衣!
- 卡普空老将伊津野英昭宣布入职腾讯光子 开发3A动作
- 38岁梅根·福克斯官宣怀孕:将迎来第四个孩子