nagios 自帶的Plugin check_log監(jiān)控日志比較單一,對于對日志監(jiān)控比較高的生產(chǎn)環(huán)境下還是不行的。
consol.de 出的check_logfile很不錯很強大,支持正則表達式。詳細官方說明如下:
http://labs.consol.de/lang/de/nagios/check_logfiles/
我以監(jiān)控apache日志為例說明下這個怎么用。
wget http://labs.consol.de/wp-content/uploads/2012/02/check_logfiles-3.4.7.1.tar.gz
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
###########################
#我們利用調(diào)用文件來監(jiān)控,這樣方便些
#創(chuàng)建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
#執(zhí)行
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
好了被監(jiān)控端配置完成了
被監(jiān)控端services.cfg
define service {
host_name nagios_test
service_description chech_sanlogs
use generic-service,srv-pnp
check_period 24x7
max_check_attempts 4
normal_check_interval 1
retry_check_interval 1
contact_groups nagcmd
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_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了
正常狀態(tài):
告警狀態(tài)
配合下圖表看起來更方便
新聞名稱:nagios監(jiān)控日志腳本check_logfile
文章來源:
http://weahome.cn/article/goihsc.html