리눅스, 자료실, 성경검색, 추억의게임, 고전게임, 오락실게임, rootman, http://www.rootman.co.kr
* 54.196.42.8 *
| Home | Profile | Linux | 자료실 | zabbix | Mysql 5.6 | 갤러리 | 성경검색 | 해피니스 | 자유게시판 | 게시물검색 | L | O | R |    

 
[Shell] [nagios] HP MSA60 P800 하드디스크 에러 검출 스크립트
 작성자 : rootman
Date : 2009-06-26 16:40  |  Hit : 8,919  
안녕하세요..
사이트 관리자입니다..
HP P800 하드디스크 에러 검출 스크립트입니다.

이것 짜다가 죽는줄 알았네요 >.<</P>

혹시, 사용할 곳 있으면.. ~ 쓰세요..

#!/bin/bash
#
# Usage: ./check_msa60
#
# 2009/05/29 04:00
#
# JeongChanHo([email protected])
#
#-----------------------------------------------------------------------
#
# You may have to change this, depending on where you installed your Nagios plugins
#
PATH="/usr/bin:/usr/sbin:/bin:/sbin"
LIBEXEC="/usr/local/nagios/libexec"
. $LIBEXEC/utils.sh


ThisDay=$(date +%Y%m%d-%H%M);

TmpMSA60="tmpMSA60.txt";
TmpMSA60_parse="tmpMSA60_parse.txt";

AllErrorFile="/var/log/HP_HardErrorList.txt";

if [ ! -f ${AllErrorFile} ];
then
touch ${AllErrorFile};
fi;

if [ -f /tmp/${TmpMSA60_parse} ];
then
rm -f /tmp/${TmpMSA60_parse};
fi;

### DEBUGGING SETUP ###
# Cause you never know when you'll need to squash a bug or two
DEBUG="0"
DEBUGFILE="/tmp/foobar"

_EXEC_hpaducli="/usr/sbin/hpaducli";

### REQUISITE NAGIOS COMMAND LINE STUFF ###

print_usage() {
echo "Usage: $PROGNAME --help"
}

print_help() {
echo ""
print_usage
echo ""
echo "Semi-intelligent uptime for Nagios"
echo ""
echo "This plugin not developped by the Nagios Plugin group."
echo "Please do not e-mail them for support on this plugin, since"
echo "they won't know what you're talking about :P"
echo ""
echo "For contact info, read the plugin itself..."
}

while test -n "$1"
do
case "$1" in
--help) print_help; exit $STATE_OK;;
-h) print_help; exit $STATE_OK;;
*) print_usage; exit $STATE_UNKNOWN;;
esac
done

_EXEC_hpaducli="/usr/sbin/hpaducli";

if [ ! -f ${_EXEC_hpaducli} ];
then
echo "CRIT alert - It isn't exist $_EXEC_hpaducli} utility!!";
exit ${STATE_WARNING};
else
${_EXEC_hpaducli} -r -f /tmp/${TmpMSA60};
if [ ! -f /tmp/${TmpMSA60} ];
then
echo "CRIT alert - It exist ${_EXEC_hpaducli} but it can't make dump file !!";
exit ${STATE_WARNING};
else
CountAll=1;
CountFAILED=0;
/bin/grep -A 7 \\
-e "^Smart Array P*.*Performance Statistics" \\
-e "^Smart Array P*.*Parameter Control" /tmp/${TmpMSA60} | \\
/bin/grep -e "--" -e "Read Errors Hard" -e "^Smart Array P" > /tmp/${TmpMSA60}_result

while read line
do
CheckLine=`echo -e $line |egrep "\\--" | wc -l`;
if [ ${CheckLine} -eq "1" ];
then
continue;
fi

CheckLine=`echo $line |grep -i "Smart Array" |wc -l`;
if [ ${CheckLine} -ne 0 ];
then
Disk=`echo $line |awk -F "Physical Drive " '{print $2}'|cut -d" " -f1`
fi

CheckLine=`echo $line |grep -i "Read Errors Hard" |wc -l`;
if [ ${CheckLine} -ne 0 ];
then
Status=`echo $line |awk -F " " '{print $4}'|cut -d" " -f1`
Status="$(echo $Status | sed -e 's/[^[:alnum:]]//g')"
fi

if [ $CountAll -eq 2 ];
then
CountAll=1;
if [ ${Status} = "0x00000000" ] || [ ${Status} = "0x0000" ] || [ ${Status} = "0x2104" ];
then
:
else
((CountFAILED += 1));
rm -f /tmp/${TmpMSA60}_result;
HexValue=`echo $Status | sed -e 's/0x//g' | tr [a-z] [A-Z]`
RESULT=`echo "ibase=16; ${HexValue}" | bc`
echo "$Disk (${RESULT})" >> /tmp/${TmpMSA60_parse}
fi
else
CountAll=$((CountAll + 1));
fi

done < /tmp/${TmpMSA60}_result<BR>
if [ $CountFAILED -eq 0 ];
then
rm -f /tmp/${TmpMSA60};
echo "[HP] STATUS OK";
exit ${STATE_OK};
else
PrintFail="[HP]";
PrintFailCount=1;
if [ -f /tmp/${TmpMSA60_parse} ];
then
for I in `cat /tmp/${TmpMSA60_parse}|uniq`
do
if [ $PrintFailCount -eq 1 ];
then
PrintFail="${PrintFail} $I";
else
PrintFail="${PrintFail},$I";
fi
done;
echo ${PrintFail};
echo "[${ThisDay}] ${PrintFail}" >> ${AllErrorFile}
exit ${STATE_WARNING};
else
echo "/tmp/TmpMSA60_parse not found !";
exit ${STATE_WARNING};
fi

fi
fi
fi
exit;
##########################################################################


[[email protected] /usr/local/nagios/libexec]# ./check_HPdebug
[HP] 1E:1:3 (3)

1E:1:3 디스크에 ErrorCount 3건이 발생했다는 뜻입니다...

[[email protected] /usr/local/nagios/libexec]# cat /var/log/HP_HardErrorList.txt
....
[20090626-1636] [HP] 1E:1:3 (3)

 
 

Total. 645
번호 분류 제목 작성자 등록일 조회수
645 기초강좌 NFS server unable to open connection to tcp6/udp6 networks rootman 09-27 2080
644 php [php] mssql ms-sql 한글 변환 끄적임.. 정리 rootman 03-29 3015
643 기초강좌 java vim 에서 자바 환경 만들기 rootman 02-16 2335
642 삭제예정 [xencenter] xenserver tool 설치 rootman 08-24 3277
641 mysql [mysql] Creating a File-Per-Table Tablespace Outside the Dat… rootman 08-03 3447
640 기초강좌 Centos Xwindow 설치 rootman 06-16 4305
639 php [php] highlight 함수 rootman 04-01 4162
638 qmail [qmail] qmail-scanner에 filtering 된 이메일 처리 rootman 02-14 4602
637 Shell [날짜] awk를 이용하여 unixtime의 시간 차 구하기 rootman 01-27 5348
636 기초강좌 centos에 그놈(gnome) 설치하기 rootman 01-10 5224
635 쉘(awk) [awk] shell 변수 사용하기 rootman 12-27 5091
634 기초강좌 서버 캐시 메모리 초기화하기 (drop_caches) rootman 12-11 5943
633 windows tips 그리드 제거 배치 스크립트 rootman 11-28 5660
632 기초강좌 패스워드 lockgin control rootman 09-06 4
631 windows tips win7 자동 로그인 설정하기 rootman 08-18 5320
 1  2  3  4  5  6  7  8  9  10    
AND OR