![Nagios가 이벤트 핸들러를 통해 Oracle 데이터베이스를 시작할 수 없는 이유는 무엇입니까?](https://linux55.com/image/109180/Nagios%EA%B0%80%20%EC%9D%B4%EB%B2%A4%ED%8A%B8%20%ED%95%B8%EB%93%A4%EB%9F%AC%EB%A5%BC%20%ED%86%B5%ED%95%B4%20Oracle%20%EB%8D%B0%EC%9D%B4%ED%84%B0%EB%B2%A0%EC%9D%B4%EC%8A%A4%EB%A5%BC%20%EC%8B%9C%EC%9E%91%ED%95%A0%20%EC%88%98%20%EC%97%86%EB%8A%94%20%EC%9D%B4%EC%9C%A0%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
이벤트 핸들러 스크립트를 사용하여 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 데이터베이스를 시작하는 데 사용됩니다.
또한 logger "Then it went here"
이벤트 핸들러 스크립트에 있는 콘텐츠는 Linux 로그에도 나타납니다 /var/log/messages
. 그래서 WARNING
사건은 계류 중이다.
내 Nagios 이벤트 로그에 다음이 표시됩니다.Nagios 이벤트 로그 스크립트
nagios
터미널에서 사용자로 스크립트를 실행 하면 스크립트가 완벽하게 실행되고 Oracle 데이터베이스가 시작됩니다. 그러나 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는 이 폴더에서 실행하지 않습니다. 전체 경로를 언급하고 작동하게 하면.