Chinaunix首页 | 论坛 | 博客
  • 博客访问: 107646
  • 博文数量: 32
  • 博客积分: 1222
  • 博客等级: 中尉
  • 技术积分: 350
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-08 16:36
个人简介

天高任鸟飞,海阔凭鱼跃

文章分类

全部博文(32)

文章存档

2011年(5)

2010年(27)

我的朋友
最近访客

分类: LINUX

2010-06-22 10:57:59

服务器的系统状态监控
-------------------
案例描述:
为了持续观察服务器每天的运行状态,需要结合shell脚本程序和计划任务,定期跟踪记录不同时段服务器的cpu负载,内存,交换空间,磁盘使用量等信息。
实现手段:利用shell脚本程序
具体设计思路:
1.编写脚本monitor.sh
#!/bin/bash
#this is the second script!
day_time=`date+"%F %R"`
cpu_test=`uptime`
mem_test=`free -m | grep "mem" | awk '{print $2}'`
swap_test=`free -m | grep "mem" | awk '{print $4}'`
disk_test=`df -hT`
user_test=`last -n 10`
echo "now is $day_time"
echo "%cpu is $cpu_test"
echo "Numbet of Mem size(MB) is $mem_test"
echo "Number of swap size(MB) is $swap_test"
echo "the disk shiyong qingkuang is $disk_test"
echo "the users login qingkuang is $user_test"
2.设置cron任务
*/15 * * * *  bash /monitor.sh
55 23 * * * tar cxf /var/log/runrec /var/log/running.today && --remove-files
备注:设置cron计划任务是为了时时执行此脚本,来监控系统状态,并记入日志,便于对系统更好的管理!
阅读(1138) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~