Nagiosがイベントハンドラを介してOracleデータベースを起動できないのはなぜですか?

Nagiosがイベントハンドラを介してOracleデータベースを起動できないのはなぜですか?

イベントハンドラスクリプトを使用して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.sql1行が含まれますstartup。 Oracleデータベースの起動に使用されます。

また、logger "Then it went here"イベントハンドラスクリプトの内容はLinuxログにも表示されます/var/log/messages。だからWARNING事件は係留中だ。

私のNagiosイベントログには次のものが表示されます。Nagiosイベントログスクリプト

nagios端末でユーザーとしてスクリプトを実行すると、スクリプトが完全に実行され、Oracleデータベースが起動します。ただし、nagiosWebサーバーを介して実行すると、Nagios Web Monitorの状態はまだ警告であり、データベースはダウンしています。

ユーザーはnagiossudoers にいます。

私はこれのために10時間以上を無駄にした。なぜこれが起こるのですか?

イベントハンドラスクリプトを実行するときにNagiosがOracleデータベースを起動しないのはなぜですか?

ベストアンサー1

私はそれを働かせた。

私が犯した最初の間違いは、イベントハンドラスクリプトをエクスポートしていないことですORACLE_HOMEORACLE_PATH

2番目のエラーは次の行にあります。

echo "ora123" |sqlplus sys@walinv as sysdba @this_file.sql

はいthis_file.sql\usr\local\nagios\libexec\eventhandlersフォルダからスクリプトを手動で実行すると、eventhandlersファイルthis_file.sqlにアクセスできます。 Nagiosはこのフォルダでは実行しません。フルパスに言及し、働かせると。

おすすめ記事