
이벤트 핸들러 스크립트를 사용하여 Oracle 데이터베이스가 다운되면서 시작하려고 합니다.
개체 구성 파일에는 다음이 oraclehost.cfg
포함됩니다.
define host {
host_name Test_Oracle
address 127.0.0.1
check_command check-host-alive
check_interval 3
retry_interval 1
max_check_attempts 5
check_period 24x7
process_perf_data 0
retain_nonstatus_information 0
contacts nagiosadmin
notifications_enabled 1
notification_interval 30
notification_period 24x7
notification_options d,r
}
define service {
host_name Test_Oracle
service_description check_OraDB
check_command check_MyOracle
event_handler restart-oracle
event_handler_enabled 1
check_interval 5
retry_interval 1
max_check_attempts 5
check_period 24x7
notifications_enabled 1
notification_interval 30
notification_period 24x7
notification_options r,w,c
contacts nagiosadmin
}
가지고 있는 것 commands.cfg
:
# 'Oracle DB' command definition
define command {
command_name check_MyOracle
command_line $USER1$/check_oracle_on.sh
}
# 'Oracle DB Handler' command definition
define command {
command_name restart-oracle
command_line $USER2$/oracle_handle.sh $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
}
다음은 oracle_handle.sh
이벤트 처리기 스크립트인 스크립트입니다.
#!/usr/bin/sh
case "$1" in
OK)
;;
WARNING)
logger "Then it went here"
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/u/oracle/server/oracle12c102/bin
export PATH
ORACLE_HOME=/u/oracle/server/oracle12c102
export ORACLE_HOME
ORACLE_SID=walinv
export ORACLE_SID
echo "ora123" |sqlplus sys@walinv as sysdba @this_file.sql
;;
UNKNOWN)
;;
CRITICAL)
;;
esac
exit 0
에는 this_file.sql
내부에 한 줄이 포함되어 있습니다 startup
. Oracle Database를 시작하는 데 사용됩니다.
또한 logger "Then it went here"
이벤트 핸들러 스크립트에 있는 것이 Linux 로그에 표시됩니다 /var/log/messages
. 그래서 WARNING
사건은 진행 중이다.
내 Nagios 이벤트 로그에 다음이 표시됩니다.Nagios 이벤트 로그 스크립트
터미널에서 사용자로 스크립트를 실행하면 nagios
스크립트가 완벽하게 실행되고 Oracle Database가 시작됩니다. 그러나 nagios
웹 서버를 통해 실행하면 Nagios Web Monitor에서는 경고 상태로 유지되고 데이터베이스가 다운됩니다.
사용자 nagios
가 sudoers에 있습니다.
나는 이것 때문에 10시간 이상을 낭비했다. 왜 이런 일이 발생합니까?
Nagios가 이벤트 핸들러 스크립트를 실행할 때 Oracle 데이터베이스를 시작하지 않는 이유는 무엇입니까?
답변1
나는 그것을 작동시켰다.
제가 한 첫 번째 실수는 이벤트 핸들러 스크립트에서 ORACLE_HOME
및를 내보내지 않은 것입니다.ORACLE_PATH
두 번째 실수는 다음 줄에 있었습니다.
echo "ora123" |sqlplus sys@walinv as sysdba @this_file.sql
this_file.sql
는 에 있었습니다 \usr\local\nagios\libexec\eventhandlers
. eventhandlers
폴더 에서 스크립트를 수동으로 실행했을 때 this_file.sql
파일에 액세스할 수 있었습니다. Nagios는 이 폴더에서 실행하지 않습니다. 전체 경로를 언급하고 작동하게 만들었습니다.