NagiosにカスタムJavaコマンドを実行させようとしていますが、常にエラー126が発生します。
[1360324906] Warning: Return code of 126 for check of service 'Java Process Test' on host 'localhost' was out of bounds.Make sure the plugin you're trying to run is executable.
今、私はいくつかのことをチェックしましたが、私はここの初心者なので、おそらく何かを逃しました。ここに環境に関するいくつかの情報があります:
-rwxr-xr-x. 1 root root 2938 Aug 17 15:39 check_wave
drwxr-xr-x. 2 root root 4096 Jan 13 15:08 eventhandlers
drwxr-xr-x. 2 root root 4096 Feb 7 17:22 jars
-rwxr-xr-x. 1 root root 38696 Aug 17 15:39 negate
-rwxr-xr-x. 1 root root 886 Feb 8 12:47 test_java_plugin.sh
test_java_plugin.shは私のテストスクリプトであり、「jars」はjarが配置されている現在のディレクトリです。
スクリプトは次のとおりです。
#!/bin/bash
#This will get the output of process
output=$(/usr/java/latest/bin/java -cp .:/usr/lib64/nagios/plugins/jars/SimpleNagiosPlugin.jar it.nagios.SimpleTest)
#This will catch the result returned by last process that is our java command
java_result=$?
echo "$java_result: $output"
exit $java_result
コンソールで手動で起動すると完全に機能します
[root@bw plugins]# ./test_java_plugin.sh
0: This is an OK message
コマンド定義を追加するのを忘れました:
# 'test_java_plugin' command definition
define command{
command_name test_java_plugin
command_line $USER1$/test_java_plugin.sh
}
また、コメントへのリクエストに従って、テストクラスの現在のJavaコードも追加しています
public static void main(String[] args) {
System.out.println("This is an OK message");
System.exit(0);
}
シェルからコマンドを起動するだけで、まだ0になります。
[root@bw plugins]# /usr/java/latest/bin/java -cp .:/usr/lib64/nagios/plugins/jars/SimpleNagiosPlugin.jar it.nagios.SimpleTest
This is an OK message
[root@bw plugins]# echo $?
0
ここで何が問題になっているのかを判断するには、他に何を確認する必要がありますか?