Nagios 如何參數傳遞給 NRPE

如何讓 NRPE 允許接收參數的傳遞是這次的重點

在遠端 Nagios Server 上,使用 check_nrpe 並以傳遞參數的方貸式,取得監控主機的服務狀態。卻得到以下的錯誤訊息:

[root@xxx ~]# /usr/local/nagios/libexec/check_nrpe -H 2.xx.xx.xx -c check_pingtest -a " -H 1.2.3.4 -w 150,30% -c 200,50% -p 5"
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

在被監控端主機查看日誌,發現以下訊息。而它說明 NRPE 目前是無法接受傳遞參數的狀態查詢:

/var/log/message
Jun 5 07:41:31 xxx nrpe[10807]: Error: Request contained command arguments!
Jun 5 07:41:31 xxx nrpe[10807]: Client request was invalid, bailing out...

因此需要在被監控端要做的事:
1. 重新編譯安裝 nrpe 帶這個參數 –enable-command-args 讓編譯後的 nrpe 可以接收參數。

./configure --enable-command-args;make all ;make install
#####allows clients to specify command arguments. *** THIS IS A SECURITY RISK! *** Read the SECURITY file before using this option!

2. 編輯 /usr/local/nagios/etc/nrpe.cfg 設定檔 :

dont_blame_nrpe=1 #打開參數傳遞功能
...........................
...
command[check_pingtest]=/usr/local/nagios/libexec/check_ping -H $ARG1$ -w 1500,100% -c 2000,100% -p $ARG2$ -t 10 #宣告帶參數的檢查命令

Nagios Server 服務端測試:

[root@xxx ~]# /usr/local/nagios/libexec/check_nrpe -H 2.xx.xx.xx -c "check_pingtest" -a 1.2.3.4 10

測試ok 返回結果:PING OK – Packet loss = 0%, RTA = 53.43 ms|rta=53.426998ms;1500.000000;2000.000000;0.000000 pl=0%;100;100;0
Note:ping

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s