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

Nagios Core - LogFile Monitoring in Unix server

Post 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
priyankabachu@gmail.com
=======================================================
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Nagios Core - LogFile Monitoring in Unix server

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
pbachu2
Posts: 27
Joined: Mon Jun 24, 2019 11:33 pm

Re: Nagios Core - LogFile Monitoring in Unix server

Post 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.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Nagios Core - LogFile Monitoring in Unix server

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
pbachu2
Posts: 27
Joined: Mon Jun 24, 2019 11:33 pm

Re: Nagios Core - LogFile Monitoring in Unix server

Post 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
priyankabachu@gmail.com
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Nagios Core - LogFile Monitoring in Unix server

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
pbachu2
Posts: 27
Joined: Mon Jun 24, 2019 11:33 pm

Re: Nagios Core - LogFile Monitoring in Unix server

Post 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
Attachments
check_log.txt
(6.13 KiB) Downloaded 175 times
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 »

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

Re: Nagios Core - LogFile Monitoring in Unix server

Post 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
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 »

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
Locked