aix date 脚本_AIX巡检脚本

这是一个用于监控AIX系统的脚本,包括文件系统使用率检查、活动Volume Group验证、问题磁盘检测、错误报告、数据库状态确认、硬件状态检查、HACMP状态、SNA链接状态和CICS活动状态等多个方面。当特定条件满足时,脚本将记录问题并生成报告。
摘要由CSDN通过智能技术生成

#!/usr/bin/ksh

syserrdate=`date +"%m/%d"`

errcount=0

STATUS=

HOSTS=`hostname`

SCRIPT=`basename $0`

REPORT="/tmp/report.txt"

#FS percent

FILESYSTEM_CHECK() {

FS=`df -k|sed '1d'|awk 'sub("%","",$4) {if ($4 > 80) print $7}'|xargs`

for i in $FS

do

echo "The $i filesystem percent more than %80 \n"

done

}

#Active VG

VG_CHECK() {

echo "****************************ACTIVE VG****************************\n"

ACVG=`lsvg -o|xargs`

echo "Active VG is: $ACVG\n"

#LV_CHECK

echo "***************************PROBLEM LV****************************\n"

BLV=`lsvg -l rootvg|grep -E "jfs|jfs2|raw"|grep -v 'N/A'|awk '{if ($6~/closed/ || $6~/stale/) print $1}'|xargs`

for i in $BLV

do

echo "The $i filesystem has a problem!!!\n"

done

}

#Problem disk

DISK_CHECK() {

echo "***************************Problem disk***************************\n"

disk=`lsvg -o|lsvg -ip|awk '$1~/hdisk/ && $2!~/active/ {print $1}'|xargs`

if [ "$disk" != "" ]

then

for i in $disk

do

echo "The $disk in $i has a problem!!!\n"

done

fi

}

#error report

ERROR_CHECK() {

echo "***************************error report***************************\n"

errdate=`errpt |grep -v IDENTIFIER |awk '{print $2}' |cut -c 1-4 |xargs`

for syserrFor1 in $errdate

do

if [ "$syserrFor1" = "$syserrdate" ]

then

newerrcount=`expr $errcount + 1`

errcount=$newerrcount

fi

done

if [ "$errcount" -eq 0 ]

then

echo "Today error is add $errcount yesterday\n"

else

echo "Today errors is add $errcount than yesterday\n"

fi

#error detail

errors=`errpt -dH -TPERM`

if [ -z "$errors" ]

then

echo "The Hardware is ${STATUS:-NORMAL}.\n"

else

echo "The permanent error of Hardware as fllow:\n`errpt -dH -TPERM`"

fi

}

#Check Database

DB_CHECK() {

su - oracle -c "lsnrctl status"|grep -i "no listener"

if [ $? = 1 ]

then

echo "The listener status is ${STATUS:-NORMAL}\n"

else

echo "The listener has a problem!!!\n"

fi

#echo "The listener status is :`su - oracle -c \"lsnrctl status\"\`\n"

#echo "Database status is:"

#su - oracle -c "sqlplus -s /nolog"

#select log_mode,name,open_mode from v\$database;

#quit

#EOF

su - oracle -c "sqlplus -s /nolog"

able"

conn /as sysdba

select log_mode,name,open_mode from v\$database;

quit

EOF

if [ $? = 0 ]

then

echo "The database not available!!!\n"

else

echo "The database is NORMAL\n"

fi

}

#HBA card link

HARDWARE_CHECK() {

fget_config -Av|grep -i dacnone>>/dev/null

if [ $? -eq 0 ]

then

echo "The storage link has problem!!!"

else

echo "The storage link NORMAL!"

fi

}

#HACMP CHECK

HA_CHECK() {

echo "The HACMP status is: `lssrc -g cluster|sed '1d'`"

}

#CHECK SNA

SNA_CHECK() {

echo "The SNA LINK STATUS is:`sna -d l`"

echo "The SNA SESSION has problem as fllows:\n"

sna -d sl|tail +4|awk 'BEGIN { OFS="\t"; print "name","\tactsess","actconw"}{if ($7 == 0 && $8 == 0) print $1, $7,$8}'

}

#CHECK CICS

CICS_CHECK() {

echo "The not active CICS is as fllows:\n"

lssrc -a|grep cics|awk '$3!~/active/ {print $1}'

}

echo $SCRIPT >$REPORT

echo $HOSTS >> $REPORT

echo "IP ADDRESS:`ifconfig -a|grep -w inet|grep -v 127.0.0.1|awk '{print $2}'`" >> $REPORT

netstat -v|grep -E "STAT|Link" >>$REPORT

oslevel >> $REPORT

FILESYSTEM_CHECK >>$REPORT 2>&1

VG_CHECK >>$REPORT 2>&1

DISK_CHECK >>$REPORT 2>&1

ERROR_CHECK >>$REPORT 2>&1

DB_CHECK >>$REPORT 2>&1

HARDWARE_CHECK >>$REPORT 2>&1

lslpp -L|grep cluster >/dev/null

if [ $? -eq 0 ]

then

HA_CHECK >>$REPORT 2>&1

else

echo "This machine not install HACMP" >> $REPORT

fi

lslpp -L|grep "sna.rte" >/dev/null

if [ $? -eq 0 ]

then

SNA_CHECK >>$REPORT 2>&1

else

echo "This machine not install sna" >> $REPORT

fi

lslpp -L|grep -i cics >/dev/null

if [ $? -eq 0 ]

then

CICS_CHECK >>$REPORT 2>&1

else

echo "This machine not install cics" >> $REPORT

fi

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值