Izhuceul 发表于 2018-8-25 08:57:53

shell脚本实现RAID状态监控

#!/bin/bash  #For monitoring raid status of XXX.
  #Written on XXXX--Singles' Day :)
  #Author:Levin.
  IP_Storage=`cat /home/admin/iplist`
  for i in $IP_Storage
  do
  ip=`echo $i|awk -F'--->' '{print $2}'`
  time=`date +%F--%T`
  echo "$i--->$time"
  if [ $ip = "x.x.x.x" -o $ip = "x.x.x.x" ];then
  ssh $ip "MegaCli -AdpAllInfo -a0|grep \"Degrade\"
  MegaCli -AdpAllInfo -a0|grep \"Failed Disks\""|awk '{if($NF!="0")print $0}'
  else
  ssh $ip "hpacucli ctrl all show status"|sed -n '/^$/d;/Slot/!p' |awk '{if($NF!="OK")print $0}'
  fi
  done |tee /home/adminwxg/raid-status
  cd /home/admin/
  num1=`grep -c . iplist`
  num2=`grep -c . raid-status`
  if [ "$num2" -gt "$num1" ];then
  mail -s "STORAGE RAID STATUS WRONG!!!" xxx@xx.com,xxx@xxx.com
页: [1]
查看完整版本: shell脚本实现RAID状态监控