Cannot open log file '/usr/local/nagios/var/ for reading!

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
chivakaa
Posts: 2
Joined: Mon Jul 02, 2018 10:21 am

Cannot open log file '/usr/local/nagios/var/ for reading!

Post by chivakaa »

Hi everyone!

ON console, when i try to see Service Alert History for whatever service, i can see only events for present log file

File: /var/log/nagios/nagios.log

My nagios core is configured to log files under non default path (/usr/local/nagios/var/archives/). Logs are saved on custom folder: /var/log/nagios

But my problem is when i try to browse on console view for previos log history (whith the arrows backwarding), following error appears!

Error: Cannot open log file '/usr/local/nagios/var/archives/nagios-07-02-2018-00.log' for reading!


But from my view that has no sense, because rotation logs are under /var/log/nagios, not under /usr/local/nagios/var/archives/nagios!

Code: Select all

root@emonpi(ro):nagios# ls -l /var/log/nagios/nagios.*
-rw-rw-r-- 1 nagios nagios 1052755 Jul  2 17:32 /var/log/nagios/nagios.log
-rw-rw-r-- 1 nagios nagios 1073833 Jul  2 08:17 /var/log/nagios/nagios.log.1
-rw-rw-r-- 1 nagios nagios 1214014 Jul  2 00:17 /var/log/nagios/nagios.log.2

My nagios.cfg
nagios.cfg
-------------------------

# LOG FILE
# This is the main log file where service and host events are logged
# for historical purposes. This should be the first option specified
# in the config file!!!

log_file=/var/log/nagios/nagios.log
#log_file=/usr/local/nagios/var/nagios.log
permissions seems to be ok for nagios and apache:

Code: Select all

root@emonpi(ro):nagios# ls -l /usr/local/nagios/var
total 428
-rw-r--r-- 1 nagios nagios   110407 Jul  2 17:15 objects.cache
-rw------- 1 nagios nagios   153642 Jul  2 17:15 retention.dat
drwxr-xr-x 2 nagios www-data   4096 Jul  2 17:15 rw
drwxr-xr-x 3 root   root       4096 Jun 25 22:22 spool
-rw-rw-r-- 1 nagios nagios   156396 Jul  2 17:29 status.dat
drwxr-xr-x 2 root   root       4096 Jun 25 22:24 tmp

Where is my mistake? My nagios core is in the last release (Version 4.4.0
) Thanks in advance
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Cannot open log file '/usr/local/nagios/var/ for reading

Post by tgriep »

When ever you want to view the previous history in the GUI, it looks at the archived log files.
For your custom path, you need to adjust the log_archice_path to match.
Edit the nagios.cfg file and change the following option to this.

Code: Select all

log_archive_path=/var/log/nagios/archives
Make sure this path exist and is writable be Nagios

Code: Select all

/var/log/nagios/archives
Save the settings and when the log file gets archived, (Daily, Midnight) it will be written to that folder and tomorrow it should be there.
Be sure to check out our Knowledgebase for helpful articles and solutions!
chivakaa
Posts: 2
Joined: Mon Jul 02, 2018 10:21 am

Re: Cannot open log file '/usr/local/nagios/var/ for reading

Post by chivakaa »

My greetings tgriep!

Thats the solution! After config nagios.cfg and restart service, now Nagios Console shows message of rotation pointing to new source:
/var/log/nagios/archives
So, as you comment before, lets wait to normal rotation of files. Thanks for your excelent support! :)
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Cannot open log file '/usr/local/nagios/var/ for reading

Post by lmiltchev »

I am glad your issue has been resolved! I will be locking this topic how. If you have any more questions/issues, please start a new thread.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked