linux系统整体监控脚本
os平台:redhat linux 5
作为DBA要时刻注意系统的整体状况,我们不能人为的一直监控系统
这就需要DBA要写一些日常的监控脚本,帮助DBA分析问题,我们最近
要上个新的系统,我于是写了linux系统的整体监控脚本
monilog_timeswitch.sh :日志轮询脚本,保留最近5个监控日志,定期删除最陈旧的监控日志
moni_system.sh :linux 系统整体监控脚本
功能:监控系统的资源使用信息,及负载信息
使用方法:把这两个脚本做成定时任务
例如:
[root@ticket-A sh]# crontab -l
*/10 * * * * sh /home/oracle/sh/moni_system.sh >> moni_system.log
00 * * * * sh /home/oracle/sh/monilog_timeswitch.sh >> monilog_timeswitch.sh.log
脚本内容如下:
[root@ticket-A sh]# more moni_system.sh
[root@ticket-A sh]# vi monilog_timeswitch.sh#!/bin/bash####################################################time : 2009/03/10#author :skate#desc :auto switch log ,keep lasted five logfile# the lasted logfile of order is: 04,03,02,01#####################################################cd /home/oracle/sh/logDIR=/home/oracle/sh/logfor file in `ls $DIR |grep -v "[0-9]"`do echo $file size=`ls -l $file |awk '{print $5}'` echo $size if [ $size -gt 100 ] then if [ -f "$file"_01 ] then if [ -f "$file"_02 ] then if [ -f "$file"_03 ] then if [ -f "$file"_04 ] then mv -f "$file"_02 "$file"_01 mv -f "$file"_03 "$file"_02 mv -f "$file"_04 "$file"_03 renamefile="$file"_04 else renamefile="$file"_04 fi else renamefile="$file"_03 fi else renamefile="$file"_02 fi else renamefile="$file"_01 fi mv $file $renamefile fidone
这个脚本只是收集了统计信息,还没有做到去分析统计信息,当达到预计的阀值就报警给相关负责人