0

I've been trying for quite a while to figure out if there's a way to make the check_http plugin for Nagios scan for a certain number of instances of a string on a web page and notify me once it passes that number.

For example, if I'm outputting a log file to a web page and want Nagios to notify me if the text "error" comes up on the page more than, say, 3 times, how would I phrase the command? There might even be a different plugin altogether that allows me to bypass the webpage and look for those 3 instances of "error" directly in the log file. If anyone knows of such a plugin, that information would be appreciated, too.

If it matters, I'm running CentOS 6.4.

4

1 回答 1

0

您可以通过巧妙构造的正则表达式来实现这一点。但是,您会遇到一个问题,即您必须否定响应,因为 check_http 没有提供“非正则表达式”选项(我觉得应该,但事实并非如此)。

因此,如果您想对 >3 个“错误”实例发出警报,请使用以下内容:

negate "check_http www.myserver.co.nz -r '(error.*){4}'"

不过,您可能需要进行单独检查以识别缓慢的响应,并且返回的信息字符串可能有点误导。

如果您可以直接(或通过 NRPE)检查文件,那么您可以编写一个脚本来使用 egrep 和类似的正则表达式。

于 2013-07-28T22:41:25.967 回答