check_logfiles plugin log rotation

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
maryo87
Posts: 2
Joined: Mon May 20, 2019 3:21 pm

check_logfiles plugin log rotation

Post 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
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: check_logfiles plugin log rotation

Post 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...
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
maryo87
Posts: 2
Joined: Mon May 20, 2019 3:21 pm

Re: check_logfiles plugin log rotation

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_logfiles plugin log rotation

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked