#!/usr/bin/env bash
### Function:monitor linux system status
### Author:webjin
### [email protected]
### Date:2013-8-8
### Version:1.0
Html="/home/www/default/index.html"
Load=$(uptime | awk  -F"," '{print  $4 $5 $6}' | cut -d: -f2)
Ip=$(ifconfig | awk '/inet addr/ {print $2}' | grep -v '127.0.0.1' |  cut -d: -f2)
Df=$(df -P | awk '{print $4}' |  grep '^[0-9.]' | awk 'BEGIN{sum=0}{sum+=$1}END{print sum/1048576}')
Free=$(free -m | grep cache | awk ' /cache/{print $3}' | grep -v free)
Uptime=$(uptime | cut -d, -f1 | awk '{print $3,$4}' )
Date=$(date -d today +"%Y-%m-%d %T")
Ping=$(ping -W 1 -c 1 $Ip &> /dev/null && echo "ok" || echo "no")
cat > $Html << EOF




服务器在线监控脚本


主机IP Ping 在线时间 磁盘空间 剩余内存 cpu负载
$Ip $Ping $Uptime $Df G $Free M $Load

以上系统信息采集于$(date -d today +"%Y-%m-%d %T")

EOF