Chinaunix首页 | 论坛 | 博客
  • 博客访问: 549774
  • 博文数量: 76
  • 博客积分: 2990
  • 博客等级: 少校
  • 技术积分: 827
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-26 10:53
文章分类

全部博文(76)

文章存档

2011年(47)

2010年(13)

2009年(5)

2008年(11)

分类:

2009-03-18 12:12:03

#!/bin/bash

NOW=`date -d today +"%Y-%m-%d %H:%M:%S"`
echo -e "\033[0;33;1mIt is start at $NOW\033[0m"
echo "..."

#1. system hardware monitor
echo -e "\033[0;31;1m1)Now The system idle value is `top -d 5 -n 1|grep id|awk '{print $5}'`\033[0m"
echo -e "\033[0;31;1m2)The system uptime infomation:\033[0m"
echo "  `uptime`"               # cat /proc/loadavg
echo -e "\033[0;31;1m3)The memory infomation:\033[0m"
echo "  `top -d 5 -n 1|grep Mem`"
echo -e "\033[0;31;1m4)report the virtual memory statistics:\033[0m"
echo "  `vmstat 2 3`"
echo -e "\033[0;31;1m5)Began the diskspace check......\033[0m"
for i in `df -k |awk '{print $5}'|grep -v ^[a-zA-Z] |awk -F"%" '{print $1}'`;do
 if [ $i -ge 85 ]; then
  echo "  The spare diskspace is not plenitidinous!"
 fi
done
echo "Complete the diskspace check."
#2. stat error files

echo -e "\033[0;31;1mCheck messages last modified time:\033[0m"
stat /var/log/messages|grep Modify
echo ""
#echo 'mysql error'
echo -e "\033[0;31;1mCheck messages last modified time:\033[0m"
stat /var/log/mysqld.log|grep Modify
echo ""
echo -e "\033[0;31;1mCheck messages last modified time:\033[0m"
stat /usr/local/apache2/logs/error_log|grep Modify
echo ""
#3. Port Listening
echo -e "\033[0;31;1m6)IS EVERY SERVICES LISTENING NOW?\033[0m"
for k in `cat /root/bin/mustlistenpt` ; do
 ISLISTEN=`netstat -an|grep LISTEN|grep ":$k\ "|wc -l`
 if [ $ISLISTEN == 0 ]
 then
   echo "The PORT $k is not listening now! Pls check the server."
 else
   echo -e "\033[0;31;1mCOUNT THE CONECTIONS FOR PORT $k:\033[0m"
   netstat -n |grep ":$k\ "|awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
 fi
 done

#4.network traffic statics
count_network_traffic.sh


#5.lastlogin
echo -e "\033[0;31;1mThe User login now:\033[0m"
who
阅读(960) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~