| python编写的check_log插件检查日志关键词for nagios,供大家学习参考。 
	基于 python-2.5.2 版本写的一个小插件,巡检日志里的关键词,可以设置阀值,超过阀值报警! 
	下面看脚本,实现的功能为:检测nginx日志有多少个 No such file or directory 
	复制代码代码如下: 
		# -*- coding: utf-8 -*- 
		def usage(): Usage: check_log [-h|--help][-l|--log][-s|--string][-w|warning][-c|critical] 
		    Options: 
		try: 
		for n,v in options: 
		if 'log' in dir() and 'string' in dir(): 
		if 'warning' in dir() and 'critical' in dir(): 
	调用示例: 
	复制代码代码如下: 
	nagios $> python check_log -l /usr/local/nginx/logs/error.log -s "No such file or directory" -w 2 -c 3 CRITICAL - No such file or directory views 3 
	添加到 commands.cfg: 
	复制代码代码如下: 
	define command{ command_name check_log command_line $USER1$/check_log -l $ARG1$ -s $ARG2$ -w $ARG3$ -c $ARG4$ } 
	然后在客户端 nrpe.cfg 添加: 
	复制代码代码如下: 
	command[check_log]=/usr/local/nagios/libexec/check_log -l /var/logs/nginx.log -s "No such file or directory" -w 2 -c 5 
	然后在服务端的 services.cfg 添加: 
	复制代码代码如下: 
	define service{(责任编辑:IT) use local-service,srv-pnp host_name web service_description nginx log check_command check_nrpe!check_log } | 
