2014-09-29 54 views
2

我有關於Nagios的/ NRPE服務的一個問題是:監測與Nagios的磁盤 - NRPE - Linux的

我已經做了每個文件的配置,但不承認我Nagios的響應交付通過在客戶端上NRPE:

文件:/etc/nagios/nrpe.cfg(客戶端)

command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10 
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/mapper/VG_opt-LV_opt 
command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z 
command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200 

文件:services.cfg(Servidor)

define service{ 
    use     generic-service 
    host_name    192.168.160.10, 192.168.160.11, 192.168.160.12 
    service_description Disk Space 
    notification_options w,u,c,r 
    check_command   check_nrpe!check_disk 
} 

顯然我重新啓動了客戶端和服務器上的服務,並通過NRPE獲得了其他諮詢結果,因爲進程數量,CPU和RAM是check_disk的問題。

本地與check_disk得到的結果是:

DISK OK - free space: /opt 34024 MB (76% inode=98%);| /opt=10522MB;37544;42237;0;46930 

通過web結果

Disk SpaceUNKNOWN 2014-09-26 09:18:31 0d 15h 52m 53s 4/4 (No output returned from plugin) 

它更怪的時候從的Nagios服務器,如果我得到的結果。

$ ./check_nrpe -H 192.168.160.10 -c check_disk 
DISK OK - free space: /opt 33389 MB (74% inode=98%);| /opt=11156MB;37544;42237;0;46930 

通過網絡:

**(No output returned from plugin)** 

(No output returned from plugin) 
NRPE Plugin for Nagios 
Copyright (c) 1999-2008 Ethan Galstad ([email protected]) 
Version: 2.15 
Last Modified: 09-06-2013 
License: GPL v2 with exemptions (-l for more info) 
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required 
\nUsage: check_nrpe -H <host> [ -b <bindaddr> ] [-4] [-6] [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>] 
\nOptions: 
-h = Print this short help. 
-l = Print licensing information. 
-n = Do no use SSL 
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL 
<host> = The address of the host running the NRPE daemon 
<bindaddr> = bind to local address 
-4 = user ipv4 only 
-6 = user ipv6 only 
[port] = The port on which the daemon is running (default=5666) 
[timeout] = Number of seconds before connection times out (default=10) 
[command] = The name of the command that the remote daemon should run 
[arglist] = Optional arguments that should be passed to the command. Multiple 
arguments should be separated by a space. If provided, this must be 
the last option supplied on the command line. 
\nNote: 
This plugin requires that you have the NRPE daemon running on the remote host. 
You must also have configured the daemon to associate a specific plugin command 
with the [command] option you are specifying here. Upon receipt of the 
[command] argument, the NRPE daemon will run the appropriate plugin command and 
send the plugin output and return code back to *this* plugin. This allows you 
to execute plugins on remote hosts and 'fake' the results to make Nagios think 
the plugin is being run locally. 
\n 
+0

這是一個延伸,但如何定義的check_nrpe命令? – 2014-10-09 06:20:31

回答

1

這可能是姍姍來遲,但我有手藝的響應。

@AlainCollins評論:

..how定義的check_nrpe命令?

define command{ 
    command_name check_nrpe 
    command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ 
} 

以上是基本的check_nrpe命令。你在這裏遇到的問題是你試圖運行nrpe.cfg定義的命令,不需要參數。當你定義一個命令時,上面的NRPE命令定義中的$ ARG2 $是'-a'正在獲取其值的地方。因此,如果您提供第一個參數'-c'作爲命令check_disk它不會獲得$ ARG2 $的值。

爲了解決這個問題,你有兩個選擇:

1)添加一個佔位符的命令參數後磁盤空間 check_command定義 「!」:

define service{ 
    use     generic-service 
    host_name    192.168.160.10, 192.168.160.11, 192.168.160.12 
    service_description Disk Space 
    notification_options w,u,c,r 
    check_command   check_nrpe!check_disk! 
} 

2)使用在/etc/nagios-plugins/config/check_nrpe中提供的「check_nrpe_1arg」命令。CFG - 此命令是專爲那些需要沒有參數,可以使用相同的常規check_nrpe插件:

define command{ 
    command_name check_nrpe_1arg 
    command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ 
}