Chinaunix首页 | 论坛 | 博客
  • 博客访问: 459092
  • 博文数量: 293
  • 博客积分: 4204
  • 博客等级: 上校
  • 技术积分: 3060
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-21 10:27
个人简介

nobody

文章分类

全部博文(293)

文章存档

2014年(27)

2013年(105)

2012年(41)

2011年(109)

2010年(11)

分类:

2011-06-02 17:07:50

#!/bin/sh
DATE=`date +"%Y-%m-%d %T"`
if [ ! -d /home/monitor ];then
mkdir -p /home/monitor
fi
connect=`lsof -i :1521|wc -l`
conn2=`ps -ef|grep LOCAL=NO|wc -l`
echo "$connect---$DATE---" >>/home/monitor/connect.out
echo "$conn2---$DATE---" >>/home/monitor/conn2.out
############CPU###############

cpu=`iostat -c |grep -v Linux  | grep -v %user | grep -v '^$' | awk '{print $1+$2+$3}'`
echo "$cpu ---$DATE---" >>/home/monitor/cpu-used.out

##########MEMORY##############

mem_used=`free -m | grep "buffers/cache" | awk '{print $3}'`
mem_total=`free -m | grep "Mem:" | awk '{print $2}'`
mem_used_percent=`echo "scale=2;100*$mem_used/$mem_total" | bc`
echo "$mem_used_percent ---$DATE---" >> /home/monitor/mem-used.out

###########DISK###############

disk_used=`df -l | grep -v Filesystem | awk 'BEGIN {SUM=0} {SUM+=$3} END {print SUM}'`
disk_total=`df -l | grep -v Filesystem | awk 'BEGIN {SUM=0} {SUM+=$2} END {print SUM}'`
disk_percent=`echo "scale=2;100*$disk_used/$disk_total" | bc`
echo "$disk_percent ---$DATE---" >> /home/monitor/disk-used.out

#############SWAP#############

swap_percent=`free -m | grep "Swap:" | awk '{print $3/$2*100}'`
echo "$swap_percent ---$DATE---" >>/home/monitor/swap-used.out

#############I/O##############

for type in cciss sda sdb sdc sdd sde sdf sdg sdh sdi
do
Blk_read=`iostat |grep $type |sed -n '1p'|awk '{print $3}'`
Blk_wrtn=`iostat |grep $type |sed -n '1p'|awk '{print $4}'`
if [ "$Blk_read" != "" ];then
echo "$type  $Blk_read k/s ---$DATE---" >> /home/monitor/Blk_read.out
echo "$type  $Blk_wrtn k/s ---$DATE---" >> /home/monitor/Blk_wrtn.out
fi
done
阅读(853) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~