我在我的Nagios服務器上安裝check_http_json.py
(URL:https://github.com/drewkerrigan/nagios-http-json)來解析JSON輸出&基於特定鍵的設置規則。「check_http_json.py」NAGIOS插件無法正常工作
JSON輸出如下所示:
[{"key":"Key","value":"Value"},{"key":"Receipt count in last 24 hours with status [Disallowed], OCR status [Complete] and Matching status [N/A]","value":"8"},{"key":"Receipt count in last 24 hours with status [Pending], OCR status [Complete] and Matching status [N/A]","value":"2"},{"key":"Last Execution for Notification Service ended","value":"10/21/2015 22:23:44PM"},{"key":"Last Execution for Payment Processor ended","value":"10/21/2015 22:23:45PM"},{"key":"Last Execution for Intelligent Offers ended","value":"10/21/2015 21:55:19PM"}]
在Nagios的側上,當我運行下面的命令,檢查JSON輸出的可用性;它的工作原理,並返回結果:
命令:
/usr/bin/python /usr/local/nagios/libexec/check_http_json.py -H datamgrqa.example.local -p api/NOC/ValidateBackend
輸出:
OK: Status OK
但是當我運行下面的命令,它會檢查,如果下面的鍵「上次執行的通知服務無止境」是否存在或沒有,
usr/bin/python /usr/local/nagios/libexec/check_http_json.py -H datamgrqa.example.local -p api/NOC/ValidateBackend -e "Last Execution for Notification Service ended"
我得到了下面的結果,儘管關鍵是堅持如你在上面的JSON輸出看到:
WARNING: Status check failed, reason: Key Last Execution for Notification Service ended did not exist
當我運行下面的命令,驗證是否鍵「發行張數在過去24小時內的地位[待定],OCR狀態[完成]和匹配狀態[ N/A]」具有小於或等於50的值:
/usr/bin/python /usr/local/nagios/libexec/check_http_json.py -H datamgrqa.example.local:80 -p api/NOC/ValidateBackend -l "Receipt count in last 24 hours with status [Pending], OCR status [Complete] and Matching status [N/A]",50
我得到下面的錯誤:
File "/usr/local/nagios/libexec/check_http_json.py", line 263, in <module>
is_alive, reason = processor.isAlive()
File "/usr/local/nagios/libexec/check_http_json.py", line 136, in isAlive
k, v = kv.split(',')
ValueError: too many values to unpack
任何想法請?
非常感謝您的幫助!
我已經更新了python文件並運行了你的命令,但是我得到了下面警告: 警告:狀態檢查失敗,原因:值3不小於或等於過去24小時內的密鑰收據計數值,狀態爲[不允許],OCR狀態[完成]和匹配狀態[N/A]。而當我運行命令(未返回正確答案)時,鍵「在過去24小時內收到狀態爲[不允許],OCR狀態[完成]和匹配狀態[N/A]」的鍵的值爲11。 – ASPR
其實我懷疑,關鍵應該是一個字不一樣的空間: 「Receiptcountinlast24hourswithstatus [不允許],OCRstatus [CompleteandMatchingstatus [N/A]」 這個插件無法讀取特定鍵和確認其有效性正如我前面提到在我的問題描述中。 – ASPR