Nagios Core - LogFile Monitoring in Unix server

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.
pbachu2
Posts: 27
Joined: Mon Jun 24, 2019 11:33 pm

Re: Nagios Core - LogFile Monitoring in Unix server

Post by pbachu2 »

Hi ,

Yes we dont have permission for server.log.User is not ready to give access for the same.

[root@dc1uat163 ~]# ls -l /apps/wildfly-11.0.0/standalone/log/server.log
-rw-r--r-- 1 root root 3630135 Jul 4 13:58 /apps/wildfly-11.0.0/standalone/log/server.log
=======================

Also user primary requirement is as below.Could you please suggest if any other way to configure such alerts.

The requirement is to check only one file every day for the ERROR/FATAL messages in the file.
Folder: /apps/wildfly-11.0.0/standalone/log/
File Name: server.log.yyyy-mm-dd (Take day - 1 file)
Eg:
Check server.log.2019-06-29 file on 2019-06-30,
Check server.log.2019-06-30 file on 2019-07-01,
Check server.log.2019-07-01 file on 2019-07-02,
Check server.log.2019-07-02 file on 2019-07-03 and so on


Thanks,
Priyanka
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Nagios Core - LogFile Monitoring in Unix server

Post by cdienger »

Try this:

Code: Select all

./check_log -F /apps/wildfly-11.0.0/standalone/log/server.log.`date --date='yesterday' +"%Y-%m-%d"` -O /apps/wildfly-11.0.0/standalone/log/server.log -q "error"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
pbachu2
Posts: 27
Joined: Mon Jun 24, 2019 11:33 pm

Re: Nagios Core - LogFile Monitoring in Unix server

Post by pbachu2 »

Hi ,

Thank you for the response @cdienger.

Tried the command you provided from our Nagios server and please find the output below and kindly suggest:

[root@dc2prd325 ~]# cd /usr/local/nagios/libexec
[root@dc2prd325 libexec]# ./check_log -F /apps/wildfly-11.0.0/standalone/log/server.log.`date --date='yesterday' +"%Y-%m-%d"` -O /apps/wildfly-11.0.0/standalone/log/server.log -q "error"
./check_log: line 76: ./utils.sh: No such file or directory

Regards,
Priyanka Bachu
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Nagios Core - LogFile Monitoring in Unix server

Post by cdienger »

What is the output of:

Code: Select all

cd /usr/local/nagios/libexec
ll | grep utils.sh
?

Make sure file is in there(attached here in case you are missing it), and the permissions look like:

Code: Select all

-rwxrwxr-x 1 apache nagios   2791 Jul  3 12:19 utils.sh
They can be updated with:

Code: Select all

chown apache:nagios /usr/local/nagios/libexec/utils.sh
chmod 775 /usr/local/nagios/libexec/utils.sh
Attachments
utils.sh
(2.73 KiB) Downloaded 168 times
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
pbachu2
Posts: 27
Joined: Mon Jun 24, 2019 11:33 pm

Re: Nagios Core - LogFile Monitoring in Unix server

Post by pbachu2 »

Thank you @cdienger,

Copied utils.sh in Nagios server and performed the above steps you have provided.
If i am running the command locally on the remote server I am getting output.

Butin Nagios GUI We are getting Unknown error as below.Please suggest.
===================
Log check error: Log file /apps/wildfly-11.0.0/standalone/log/server.log.2019-07-11 does not exist!\n
==========================
Also Please find service and command definition declared in the Nagios server end.

define service{
use generic-service,srv-pnp
host_name dc1uat163
service_description file:/apps/wildfly-11.0.0/standalone/log/
#servicegroups sg_app_upm
#contact_groups cg_app_upm
contacts stummala, ysivasundaram2
check_command check_log_dc1uat163file
}

command definition in commands.cfg in our Nagios server :

define command{
command_name check_log_dc1uat163file
command_line $USER1$/check_log -F /apps/wildfly-11.0.0/standalone/log/server.log.`date --date='yesterday' +"%Y-%m-%d"` -O /apps/wildfly-11.0.0/standalone/log/server.log -q "error"
}
===================================

Regards,
Priyanka Bachu
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Nagios Core - LogFile Monitoring in Unix server

Post by ssax »

What is the output of this command?

Code: Select all

ls -l /apps/wildfly-11.0.0/standalone/log/server.log.2019-07-11
pbachu2
Posts: 27
Joined: Mon Jun 24, 2019 11:33 pm

Re: Nagios Core - LogFile Monitoring in Unix server

Post by pbachu2 »

Hi All,

We have a test server and tried there creating a new testfile.log and testfile.log.2019-07-18 as previous day file.

New file:
[root@dc2drpas008 linux-nrpe-agent]#cat testfile.log
nagios
ERROR
unix
storage
WARN
ERROR
ERROR

Old file:
[root@dc2drpas008 linux-nrpe-agent]# cat testfile.log.2019-07-18
ERROR

We have used this command and plugin:

Please find the attachment for plugin script.

./check_log -F /root/linux-nrpe-agent/testfile.log.`date --date='yesterday' +"%Y-%m-%d"` -O /root/linux-nrpe-agent/testfile.log -q "ERROR"

Output when we run the command:
[root@dc2drpas008 libexec]# ./check_log -F /root/linux-nrpe-agent/testfile.log.`date --date='yesterday' +"%Y-%m-%d"` -O /root/linux-nrpe-agent/testfile.log -q "ERROR"
Log check ok - 0 pattern matches found|match=0;;;0

The old file data is copied to new file.

[root@dc2drpas008 linux-nrpe-agent]#cat testfile.log
nagios
ERROR
unix
storage
WARN
ERROR
ERROR

[root@dc2drpas008 linux-nrpe-agent]#cat testfile.log.2019-07-18
nagios
ERROR
unix
storage
WARN
ERROR
ERROR

Please help how to rectify this problem.

Regards,
Priyanka
Attachments
check_log.txt
(6.74 KiB) Downloaded 164 times
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Nagios Core - LogFile Monitoring in Unix server

Post by cdienger »

Try this instead:

Code: Select all

./check_log -F /apps/wildfly-11.0.0/standalone/log/server.log.`date --date='yesterday' +"%Y-%m-%d"` -O /apps/wildfly-11.0.0/standalone/log/server.log.o -q "error"
This should create /apps/wildfly-11.0.0/standalone/log/server.log.o instead of overwriting /apps/wildfly-11.0.0/standalone/log/server.log.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked