Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2472996
  • 博文数量: 225
  • 博客积分: 11622
  • 博客等级: 上将
  • 技术积分: 7358
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-18 10:05
个人简介

我们的生活是多么美好呀!!!!

文章存档

2013年(2)

2012年(9)

2011年(59)

2010年(8)

2009年(35)

2008年(112)

分类: LINUX

2008-09-25 16:19:41

监控项目---磁盘IO模块

  磁盘IO模块涉及到的参数有:

    alarm_io_util_up 80  io上限
    alarm_io_times 3  报警次数

  其中根据盘的多少,IO的数据文件位于IP目录下的disk_io_util_table文件内,此文件以行形式,一块盘一行,每行二列分别存盘符和当前IO值,以逗号区隔..要求无论几块盘,,只要某块盘连续三次IO值超出,发邮件或短信报警...

  IO模块名为: Module_IO_Alarm.sh 内容如下:   而后的DISK占用模块同于此..后不再介绍

  #!/bin/sh
  if [ $# -ne 1 ];then
          /bin/echo "Usage: $0 IP"
          exit 1
  fi
 
  MONITOR_DIR=/performance_center/performance_monitor
  DEFAULT_CONF_DIR=$MONITOR_DIR/default_conf
  DATA_DIR=/cacti/idctraffic/hosttraffic
  CONF_DIR=$DEFAULT_CONF_DIR
 
  #check data validity
  IP=$1
  if [ -f $DATA_DIR/$IP/disk_io_util_table ];then
          /bin/echo OK > /dev/null
  else
          /bin/echo $DATE "$IP io util is no data_file" >> $MONITOR_DIR/logs/IO_error.log
          $MONITOR_DIR/scripts/Alarm.sh "$IP io util is no data_file" 2>>$MONITOR_DIR/logs/IO_error.log 1>/dev/null
          exit 1
  fi
 
  #set conf
  if [ -d $DATA_DIR/$IP/alarm_conf ];then
          CONF_DIR=$DATA_DIR/$IP/alarm_conf
          if [ -f $CONF_DIR/alarm_io_times ];then
                  IO_ALARM_TIMES=`/bin/cat $CONF_DIR/alarm_io_times`
          else
                  IO_ALARM_TIMES=`/bin/cat $DEFAULT_CONF_DIR/default.conf | /bin/grep "alarm_io_times" | /bin/awk '{print $2}'`
          fi
          if [ -f $CONF_DIR/alarm_io_util_up ];then
                  IO_ALARM_VALUE_UP=`/bin/cat $CONF_DIR/alarm_io_util_up`
          else
                  IO_ALARM_VALUE_UP=`/bin/cat $DEFAULT_CONF_DIR/default.conf | /bin/grep "alarm_io_util_up" | /bin/awk '{print $2}'`
          fi
  else
          IO_ALARM_TIMES=`/bin/cat $DEFAULT_CONF_DIR/default.conf | /bin/grep "alarm_io_times" | /bin/awk '{print $2}'`
          IO_ALARM_VALUE_UP=`/bin/cat $DEFAULT_CONF_DIR/default.conf | /bin/grep "alarm_io_util_up" | /bin/awk '{print $2}'`
  fi
 
  #alarm check
  while read LINE
  do
          CURRENTLY_IO_NAME=`/bin/echo $LINE | awk -F, '{print $1}'`
          CURRENTLY_IO_USED=`/bin/echo $LINE | awk -F, '{print $2}'`
          MD5_FILENAME_IO=`/bin/echo "$IP io util $CURRENTLY_IO_NAME used is over" -n | /usr/bin/md5sum | /bin/awk '{print $1}'`
          if [ $CURRENTLY_IO_USED -gt $IO_ALARM_VALUE_UP ];then
                  if [ ! -f $MONITOR_DIR/alarm_info/$MD5_FILENAME_IO ];then
                          /bin/echo 1 > $MONITOR_DIR/alarm_info/$MD5_FILENAME_IO
                          /bin/echo "$IP io util $CURRENTLY_IO_NAME used is over $IO_ALARM_VALUE_UP:$CURRENTLY_IO_USED" >> $MONITOR_DIR/alarm_info/$MD5_FILENAME_IO
                  else
                          CUR_ALARM_TIMES_IO=`/bin/cat $MONITOR_DIR/alarm_info/$MD5_FILENAME_IO | /bin/sed -n '{1p}'`
                          CUR_ALARM_TIMES_IO=`/usr/bin/expr $CUR_ALARM_TIMES_IO + 1`
                          if [ $CUR_ALARM_TIMES_IO -ge $IO_ALARM_TIMES ];then
                                  $MONITOR_DIR/scripts/Alarm.sh "$IP io util $CURRENTLY_IO_NAME used is over $IO_ALARM_VALUE_UP:$CURRENTLY_IO_USED" 2>$MONITOR_DIR/logs/IO_error.log 1>/dev/null &
                                  /bin/rm -rf $MONITOR_DIR/alarm_info/$MD5_FILENAME_IO
                          else
                                  /bin/echo $CUR_ALARM_TIMES_IO > $MONITOR_DIR/alarm_info/$MD5_FILENAME_IO
                                  /bin/echo "$IP io util $CURRENTLY_IO_NAME used is over $IO_ALARM_VALUE_UP:$CURRENTLY_IO_USED" >> $MONITOR_DIR/alarm_info/$MD5_FILENAME_IO
                          fi
                  fi
          else
                  if [ -f $MONITOR_DIR/alarm_info/$MD5_FILENAME_IO ];then
                          /bin/rm -rf $MONITOR_DIR/alarm_info/$MD5_FILENAME_IO
                  fi
          fi
  done < $DATA_DIR/$IP/disk_io_util_table
 
  exit 0

阅读(1629) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~