Page 1 of 1
check_logfiles plugin log rotation
Posted: Tue Jun 11, 2019 1:55 pm
by maryo87
Hello Team,
I am trying to configure check_logfiles plugin to read specific pattern in one of my log file. The log files are generated on daily basis with the below naming convention under this path /var/log
--> bmessenger-YYYYMMDD.log
So how do I inform check_logfiles plugin to monitor only my latest log file ? Any help would be highly appreciated. I have looked at the documentation but I couldn't make anything there.
Below is the documentation.
-->
https://labs.consol.de/nagios/check_logfiles/index.html
Re: check_logfiles plugin log rotation
Posted: Tue Jun 11, 2019 3:23 pm
by cdienger
A config like this:
Code: Select all
@searches = (
{
logfile => '/var/log/bmessenger-$CL_DATE_YYYY$$CL_DATE_MM$$CL_DATE_DD$',
},
);
and running the plugin like this:
Code: Select all
/usr/local/nagios/libexec/check_logfiles --config filename.cfg
will get you started. You'll need to add the extras like pattern(s) to search for, etc...
Re: check_logfiles plugin log rotation
Posted: Tue Jun 11, 2019 11:53 pm
by maryo87
Hello cdienger,
Thank you for the reply. It is working fine.
Like to have one another clarification.
I have configured the service definition in this file '/usr/local/nagios/etc/objects/templates.cfg'
Code: Select all
define service{
name mservice
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 0
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 1
check_period 24x7
max_check_attempts 1
check_interval 3
retry_interval 2
contact_groups admins
notification_options w,u,c
notification_interval 60
notification_period 24x7
register 0
}
And in this file '/usr/local/nagios/etc/objects/node.cfg'
Code: Select all
define service {
use mservice
host_name jd.messenger.com
service_description check_logfiles
check_command check_logfiles
}
And in this file '/usr/local/nagios/etc/objects/commands.cfg'
Code: Select all
define command{
command_name check_logfiles
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_logfiles
}
Is this the recommended approach? Or do we have a better way to define the service, command, host definitions? I am asking this because I have configured service definition in template.cfg file and used the service in node.cfg. Is there a way to configure it in a single file? If yes how?
Re: check_logfiles plugin log rotation
Posted: Thu Jun 13, 2019 3:12 pm
by scottwilkerson
You could configure all the settings form the template right in the service, but using a template can reduce a lot of work if you have many checks that use the same settings.
All of these can be put in a single file, as long as the file is included with directives in the nagios.cfg