nagios监控日志脚本check_logfile
tar xf check_logfiles-3.4.7.1.tar.gz
cd check_logfiles-3.4.7.1
./configure --prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-seekfiles-dir=/usr/local/nagios/var/tmp/ --with-protocols-dir=/usr/local/nagios/var/tmp/ --with-perl=/usr/bin/perl --with-gzip=/bin/gzip
make && make install
###########################
#我们利用调用文件来监控,这样方便些
#创建log.conf
vim /usr/local/nagiso/etc/log.conf
@searches = (
{
tag => 'test_http',
logfile => '/var/log/httpd/access_log',
rotation => 'CentOs',
criticalpatterns => [
'.*401\s*571.*',
],
warningpatterns => [
'404'
]
},
);
#具体的详细配置可以看下官方介绍
在nrpe添加
command[check_logfiles]=/usr/local/nagios/libexec/check_logfiles --config=/usr/local/nagios/etc/log.cfg
#执行
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d好了被监控端配置完成了
被监控端services.cfg
define service {
host_name nagios_test
service_description chech_sanlogs
use generic-service,srv-pnp
check_period24x7
max_check_attempts4
normal_check_interval 1
retry_check_interval 1
contact_groupsnagcmd
notification_interval 10
notification_period 24x7
notification_optionsw,u,c,r
check_commandcheck_log!20!check_logfiles
}
vim etc/objects/commands.cfg
define command{
command_name check_log
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t $ARG1$ -c $ARG2$
}
##重启下nagios,就OK了正常状态:告警状态
配合下图表看起来更方便
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。