#!/bin/bash
## This is check system shell script.
## Writen by zhunzhun.zeng 2013-07-08.
export LANG=zh_CN.UTF-8
zhujiming=`hostname`
ip=`ifconfig`
xitongshijian=`date +%H:%M:%S`
yunxingshijian=`uptime | awk '{print $3,$4}'`
xitongbanben=`head -n 1 /etc/issue`
neihebanben=`uname -r`
xitongfuzai=`cat /proc/loadavg | awk '{print $1,$2,$3}'`
jincheng=`top -bn 1 | sed -n '7,17'p`
shuliang=`cat /proc/cpuinfo | grep -c processor`
neicun=`free -m`
guazaifenqu=`mount | column -t`
kongjian=`df -ah`
denglu=`lastlog | grep -v "从未登录过"`
dengluyonghu=`w | sed '1'd`
tcpzhuangtai=`netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a,S[a]}'`
xitongyonghu=`cut -d: -f1 /etc/passwd`
xitongzu=`cut -d: -f1 /etc/shadow`
jinchengshu=`ps -ef | wc -l`
jiangshijincheng=`ps -ef | grep -v grep | grep -c defunct`
fanghuoqiang=`iptables -L`
luyoubiao=`route -n | sed -n '2,$'p`
jihuarenwu=`crontab -l`
eth0=`mii-tool eth0`
eth1=`mii-tool eth1`
kaijiqidongfuwu=`chkconfig --list | awk '{print $1,$5}' | grep 启用`
d=`date +%y-%m-%d`
[ -d /var/log/check-system/$d ] || mkdir -p /var/log/check-system/$d
echo "============================================================================"
echo "当前主机名为:$zhujiming"
echo "============================================================================"
echo "当前主机IP地址信息为:"
echo "$ip"
echo "============================================================================"
echo "当前系统时间为:$xitongshijian"
echo "============================================================================"
echo "当前系统运行时间为:$yunxingshijian"
echo "============================================================================"
echo "当前系统版本为:$xitongbanben"
echo "============================================================================"
echo "当前系统内核版本为:$neihebanben"
echo "============================================================================"
echo "当前系统负载为:$xitongfuzai"
echo "============================================================================"
echo "当前系统前十个占用cpu最高的进程为:"
echo "$jincheng"
echo "============================================================================"
echo "当前系统逻辑cpu个数为:$shuliang"
echo "============================================================================"
echo "当前系统内存状态为:"
echo "$neicun"
echo "============================================================================"
echo "当前挂载的分区状态为:"
echo "$guazaifenqu"
echo "============================================================================"
echo "当前所有分区使用空间:"
echo "$kongjian"
echo "============================================================================"
echo "当前系统登录状态为:"
echo "$denglu"
echo "============================================================================"
echo "当前系统登录用户为:"
echo "$dengluyonghu"
echo "============================================================================"
echo "当前系统tcp连接状态为:"
echo "$tcpzhuangtai"
echo "============================================================================"
echo "当前系统用户为:"
echo "$xitongyonghu"
echo "============================================================================"
echo "当前系统组为:"
echo "$xitongzu"
echo "============================================================================"
echo "当前系统进程数为:"
echo "$jinchengshu"
echo "============================================================================"
echo "当前系统僵尸进程数为:"
echo "$jiangshijincheng"
echo "============================================================================"
echo "当前系通防火墙状态为:"
echo "$fanghuoqiang"
echo "============================================================================"
echo "当前系统路由表为:"
echo "$luyoubiao"
echo "============================================================================"
echo "当前系统计划任务为:"
echo "$jihuarenwu"
echo "============================================================================"
echo "当前系统网卡物理接口状态为:"
echo "$eth0"
echo "$eth1"
echo "============================================================================"
echo "当前系统开机启动服务为:"
echo "$kaijiqidongfuwu"
echo "============================================================================"