我在我的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