Page 1 of 2

Nagios Core - LogFile Monitoring in Unix server

Posted: Mon Jun 24, 2019 11:46 pm
by pbachu2
Hi All,

We are using Nagios Core 4.0.8 and we got a request to monitor for "Error" word in the log file on Unix server.
We tried configuring this service using check_log plugin .
=============================================
Check command in Service definition on host.cfg is as below:

check_command check_log_dc1uat163_oldone!-F /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20 -O /apps/wildfly-11.0.0/standalone/log/server.log -q "ERROR"
=======================================================
commands.cfg is below:

define command{
command_name check_log_dc1uat163_oldone
command_line $USER2$/check_log $ARG1$ $ARG2$ $ARG3$
}

=========================
However it is giving error as below:

Log check error: Log file /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20 does not exist!


Can someone pls suggest how to configure for this kind of monitoring.

Thanks,
Priyanka
[email protected]
=======================================================

Re: Nagios Core - LogFile Monitoring in Unix server

Posted: Tue Jun 25, 2019 1:45 pm
by benjaminsmith
Hi Priyanka,

Are your sure you have the correct file path as it cannot find it. Does the Nagios user on the server have permissions to access the log file?

Code: Select all

su nagios
ls -l /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20 
Let me know. Thanks.

Re: Nagios Core - LogFile Monitoring in Unix server

Posted: Wed Jun 26, 2019 2:12 am
by pbachu2
Hi Smith,

Thanks for your prompt response.
Yes we are able to perform steps you provided.

[root@dc1uat163 ~]# su nagios
[nagios@dc1uat163 root]$ ls -l /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20
-rw-r--r-- 1 root root 30182209 Jun 20 23:59 /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20

===================
Please suggest how to proceed further.

Re: Nagios Core - LogFile Monitoring in Unix server

Posted: Wed Jun 26, 2019 4:34 pm
by benjaminsmith
Hi,

If the file is there, then you'll need to change the permissions to allow access by the nagios user account. For the check_log plugin, do this for both files in your check command.

For example,

Code: Select all

chgrp nagios /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20
chmod 770 /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20

Re: Nagios Core - LogFile Monitoring in Unix server

Posted: Thu Jun 27, 2019 1:28 am
by pbachu2
Hi Smith,

Yes we did tried changing permissions for the file as per your suggestion.But we are getting same error.
Could you please help us know if any other way to configure similar kind of monitoring.
Please suggest.

Regards,
Priyanka
[email protected]

Re: Nagios Core - LogFile Monitoring in Unix server

Posted: Thu Jun 27, 2019 4:07 pm
by benjaminsmith
Hello,

Log into /usr/local/nagios/libexec on the Nagios server and running the following command:

Code: Select all

./check_log -F /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20 -O /apps/wildfly-11.0.0/standalone/log/server.log -q "error"
and provide a screenshot or post the output. If the file exists and Nagios has access to the file it should work.

Re: Nagios Core - LogFile Monitoring in Unix server

Posted: Thu Jun 27, 2019 8:11 pm
by pbachu2
Hi Smith,

I am getting below error.

./check_log: line 76: ./utils.sh: No such file or directory

Also attaching check_log plugin which we are using. PFA and suggest.

Thanks & Regards,
Priyanka Bachu

Re: Nagios Core - LogFile Monitoring in Unix server

Posted: Fri Jun 28, 2019 1:45 pm
by ssax
It needs to be run from within the directory that contains utils.sh, please do it this way:

Code: Select all

su - nagios
cd /usr/local/nagios/libexec/
./check_log -F /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20 -O /apps/wildfly-11.0.0/standalone/log/server.log -q "error"

Re: Nagios Core - LogFile Monitoring in Unix server

Posted: Tue Jul 02, 2019 8:19 pm
by pbachu2
Hi ,

Please check the output below and please suggest.
I have run this command on the remote server.

[root@dc1uat163 ~]# su - nagios
[nagios@dc1uat163 ~]$ cd /usr/local/nagios/libexec/
[nagios@dc1uat163 libexec]$ ./check_log -F /apps/wildfly-11.0.0/standalone/log/server.log.2019-06-20 -O /apps/wildfly-11.0.0/standalone/log/server.log -q "error"
./check_log: line 209: /apps/wildfly-11.0.0/standalone/log/server.log: Permission denied
(59) < at bravura.sonata.application.useragent.UserAgent.errorDialog(UserAgent.java:105)[nagios@dc1uat163 libexec]$

Regards,
Priyanka

Re: Nagios Core - LogFile Monitoring in Unix server

Posted: Wed Jul 03, 2019 4:36 pm
by ssax
It tells you the issue:

Code: Select all

./check_log: line 209: /apps/wildfly-11.0.0/standalone/log/server.log: Permission denied
The nagios user doesn't have access to write to this file:

Code: Select all

/apps/wildfly-11.0.0/standalone/log/server.log
What are the permissions on there?

Code: Select all

ls -l /apps/wildfly-11.0.0/standalone/log/server.log