Page 2 of 2
Re: Nagios Core - LogFile Monitoring in Unix server
Posted: Wed Jul 03, 2019 11:03 pm
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
Re: Nagios Core - LogFile Monitoring in Unix server
Posted: Tue Jul 09, 2019 3:17 pm
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"
Re: Nagios Core - LogFile Monitoring in Unix server
Posted: Tue Jul 09, 2019 9:01 pm
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
Re: Nagios Core - LogFile Monitoring in Unix server
Posted: Wed Jul 10, 2019 3:50 pm
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
Re: Nagios Core - LogFile Monitoring in Unix server
Posted: Thu Jul 11, 2019 8:40 pm
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
Re: Nagios Core - LogFile Monitoring in Unix server
Posted: Fri Jul 12, 2019 3:45 pm
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
Re: Nagios Core - LogFile Monitoring in Unix server
Posted: Fri Jul 19, 2019 4:28 am
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
Re: Nagios Core - LogFile Monitoring in Unix server
Posted: Fri Jul 19, 2019 3:58 pm
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.