標籤:http io os ar sp on 問題 amp 工作
在ubuntu 14.04 系統探索部署 nagios nrdp 外掛程式過程中,遇到如下問題?
測試 http: ip /nrdp/ 提交結果的頁面中,總是報如下錯誤:
<result><status>-1</status><message>BAD COMMAND FILE</message></result><result><status>-1</status><message>BAD CHECK RESULTS DIR</message></result>
“BAD COMMAND FILE” “BAD CHECK RESULTS DIR” 開發人員定義的這兩條運行錯誤提示資訊,語義解偏差很大,弄了兩天依然無頭緒, 無奈之下只能在閱讀外掛程式的源碼,分別找到了源碼中的位置,現在把報錯資訊出處的調用的函數寫成兩個測試指令碼
test_file_exists.php <?php $result=file_exists("/var/lib/nagios3/spool/checkresults","c"); print $result."\n\r"; ?> test_tempnam.php <?php $tmpname=tempnam("/var/lib/nagios3/spool/checkresults","c"); print $tmpname."\n\r"; ?>
分別以nagios www-data 使用者身份執行,會返回不同的結果,外掛程式不能工作的正常原因就這裡,請讀者自行驗證,!
sudo -u nagios test_tempnam.php sudo -u nagios test_file_exists.phpsudo -u www-data test_tempnam.php sudo -u www-data test_file_exists.php
最後給出一個臨時解決辦法,更改apache服務的運行使用者
vim /etc/apache2/envvarsexport APACHE_RUN_USER=nagiosexport APACHE_RUN_GROUP=nagios
最後測試一切OK
主機檢測發送結果
python send_nrdp.py –url=http://10.2.0.191/server/ –token=“[email protected]&d” –host=localhost –state=0 –output=“ok ok ok”
服務檢測發送結果
python send_nrdp.py –url=http://10.2.0.191/server/ –token=“[email protected]&d” –host=localhost –service=check_disk_passive –state=0 –output=“ok ok ok”
部署 nagios nrdp 外掛程式過程中遇到的問題總結