#!/bin/bash
#先定义监控的服务程序,采用数组
prog_list=(
'./fms_position'
'./fms_store'
'./fms_backupServer'
'./fms_backupClient'
)
#输出监控时间
tjdate=`date`
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" >>b.txt
echo $tjdate >>b.txt
count=0;
while [ "x${prog_list[count]}" != "x" ]
do
progID=`ps -ef|awk -v p=${prog_list[count]} '{if($NF==p) print $2}'`
#echo $progID
#top -p `ps -ef|awk ' {if($NF=='${prog_list[count]}') print $2}'` -n 1|tail -n 3
#top -p $progID -n 1|tail -n 3|awk '{print $2" "$3" "$4" "$5" "$6" "$7}' >>b.txt
top -p $progID -n 1 -b |tail -n 3 >>b.txt
# echo ${prog_list[count]}
count=$count+1
done
#输出 系统资源信息
echo "system load" >>b.txt
load=`top -n 1 -b|awk 'NR==1{print $(NF-2)" "$(NF-1)" "$NF}'`
#load=`top -n 1 -b|awk 'NR==1{print $0}'`
free=`free|awk 'NR==3{print $4}'`
buffer=`free|awk 'NR==2{print $6}'`
cache=`free|awk 'NR==2{print $7}'`
echo "load average:"$load >>b.txt
echo "free:"$free >>b.txt
echo "buffer:"$cache >>b.txt
echo "cache:"$cache >>b.txt
阅读(2675) | 评论(1) | 转发(0) |