Chinaunix首页 | 论坛 | 博客
  • 博客访问: 836987
  • 博文数量: 339
  • 博客积分: 3151
  • 博客等级: 中校
  • 技术积分: 3425
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-10 14:47
文章分类

全部博文(339)

文章存档

2023年(43)

2022年(44)

2021年(3)

2020年(13)

2019年(39)

2018年(25)

2015年(2)

2014年(18)

2013年(12)

2012年(48)

2011年(79)

2010年(13)

分类: 系统运维

2011-09-17 17:01:01

root@suzsysadmin # crontab -l
#ident  "@(#)root       1.21    04/03/23 SMI"
#
# The root crontab should be used to perform accounting data collection.
#
#
10 3 * * * /usr/sbin/logadm
15 3 * * 0 /usr/lib/fs/nfs/nfsfind
30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
#10 3 * * * /usr/lib/krb5/kprop_script ___slave_kdcs___
#Add Admin Task Her
0 08 * * * /export/root/cronjob/SupportServiceAudit -t
#0,5,10,15,20,25,30,35,40,45,50,55 * * * * /export/root/cronjob/PingCheck -t
0,30 * * * * /export/root/cronjob/DiskSuiteStatus
#Add Service Information Task Here
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /export/root/bin/ServerInfo-Alive
0 * * * * /export/root/bin/ServerInfo-Uptime
30 * * * * /export/root/bin/ServerInfo-SysCollect
root@suzsysadmin #
------------------------------------
上图可以看出,每小时的0分和30分,DiskSuitesStatus都会运行。找到这个脚本。
-------------------------------------
root@suzsysadmin # more /export/root/cronjob/DiskSuiteStatus
#!/usr/bin/bash
#Here is the develop information
#Script Name    : DiskSuiteStatus
#Description    : This script use check server Disk Suite Status.
#Version        : 1.0
#Platform       : Solaris
#Copyright      : Seagate CORP
#Author         : Anthony.Zhao@Seagate.Com
#Last Update    : August 16, 2010
#Modify History :
#                 August 17, 2010    Add Disk Suite DB check function and re-group main code procedure.

#Global Variable
ScriptPathAndName=$0
ScriptPath=`dirname $0`
ScriptName=`basename $0`
MailAddress="SystemAdministratorTeam"
MailSendSwitch="ON"
LogFile=$ScriptPath/../var/$ScriptName.log
MailListFile=$ScriptPath/../etc/Mail.List
PatrolFile=$ScriptPath/../var/$ScriptName.Patrol
MailContent=$ScriptPath/../var/$ScriptName.Mail.$$

#Define Variable
Buffer=""
Alert=""
DiskIssue="FALSE"
DBIssue="FALSE"

#Define Function
WRLOG()
{
  echo "`date +%Y-%m-%d-%H-%M-%S` $$ $1" >> $LogFile
}

WRAlertFlag()
{
  if [ "$1" == "Alert" ]
  then
    echo "1" > $PatrolFile
  else
    echo "0" > $PatrolFile
  fi
}

GetMailAddress()
{
  MailAddress=`cat $MailListFile | grep "^$MailAddress=" | awk -F= '{print $2}' | sed 's/"//g'`
}

CreateMailContent()
{
  echo "########################" > $MailContent
  metadb -i >> $MailContent
  echo "########################" >> $MailContent
  metastat >> $MailContent
}

MailSend()
{
  if [ "$MailSendSwitch" == "ON" ]
  then
    if [ "$1" == "Alert" ]
    then
      CreateMailContent
      mailx -s "DiskSuite: Warning `hostname` Has Disk Suite issue!!" $MailAddress < $MailContent
    else
      Buffer=`cat $PatrolFile`
      if [ "$Buffer" == "1" ]
      then
        WRLOG "Disk Suite restore from a error, send out dismiss mail"
        CreateMailContent
        mailx -s "DiskSuite: `hostname` Disk Suite issue dismissed." $MailAddress < $MailContent
      fi
    fi
  fi
  rm -rf $MailContent
}

CheckDiskStatus()
{
  Buffer=`metastat | grep "State:" | grep -v "Okay"`
  Alert=`echo $Buffer | sed 's/ //g'`
  if [ "$Alert" == "" ]
  then
    DiskIssue="FALSE"
  else
    DiskIssue="TURE"
  fi
}

CheckDBStatus()
{
  Buffer=`metadb -i | grep -v - | grep -v flags | awk '{print $1}' | grep -v "^a"`
  Alert=`echo $Buffer | sed 's/ //g'`
  if [ "$Alert" == "" ]
  then
    DBIssue="FALSE"
  else
    DBIssue="TURE"
  fi
}


#Main code Start Here
WRLOG "Script starting"
CheckDBStatus
CheckDiskStatus
GetMailAddress
if [ "$DBIssue" == "TURE" ]
then
  WRLOG "**** Disk Siute DB got issues, send out alert mail"
  MailSend Alert
  WRLOG "**** Set Patrol flag to 1"
  WRAlertFlag Alert
else
  if [ "$DiskIssue" == "TURE" ]
  then
    WRLOG "**** Disk Siute Drive got issues, send out alert mail"
    MailSend Alert
    WRLOG "**** Set Patrol flag to 1"
    WRAlertFlag Alert
  else
    WRLOG "Disk Siute working well"
    MailSend Dismiss
    WRLOG "Restore Patrol flag to 0"
    WRAlertFlag Dismiss
  fi
fi
WRLOG "Script End"
root@suzsysadmin #
root@suzsysadmin # pwd
/export/root/etc
root@suzsysadmin # more Mail.List
#GroupName="Mail-Address1,Mail-Address2"
SystemAdministrator="Anthony.Zhao@Seagate.Com"
SystemAdministratorTeam="RenQing.Z.Zhou@seagate.com,da.wan@seagate.com,zhengyang.z.zhou@seagate.com,gavin.lu@sea
gate.com,wei.w.shen@seagate.com,shilei.j.jin@seagate.com"

在这个地方修改就可以了。

阅读(1087) | 评论(0) | 转发(0) |
0

上一篇:帮我买个单

下一篇:17 ??

给主人留下些什么吧!~~