文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>提取IO值导入数据库

提取IO值导入数据库

时间:2010-02-26  来源:night85

[root@nagiosbak sarlog]# cat /monitor/nagios/shell/sarlog/scan_sarlog.sh
#!/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
  [root@nagiosbak sarlog]# cat sarlog.sh
#!/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}')

/usr/bin/sar -u 60 120 >  /tmp/$(hostname)-${runday}.txt
/bin/sed '/ \+/s//,/g'  /tmp/$(hostname)-${runday}.txt |  /bin/sed -n '4,$p'  | grep -v Average  |awk -F "," '{print "'"$host"'"",""'"$channel"'"",""'"$IPhost"'"",""'"$runday"'"" "$1","$4","$6","$7","$9}'  > /tmp/$(hostname)${runday}.txt rm -rf /tmp/$(hostname)-${runday}.txt     [root@nagiosbak sarlog]# cat /monitor/nagios/shell/sarlog/process_sarlog.sh
#!/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}.txt ${TmpDir}
done
/bin/cat ${TmpDir}/*${runday}.txt >> ${TmpDir}/Tmp${runday}.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}Result.txt
        let count=count+1
done
rm -rf ${TmpDir}/*${runday}.txt /usr/local/mysql/bin/mysql -u root -D nagios -pbj7n48dM  <<EOF
   load data infile '${TmpDir}/${runday}Result.txt' into table t_daily_stats FIELDS TERMINATED BY  ',';
EOF
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载