Cannot open log file '/usr/local/nagios/var/archives/nagios

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.
Philix
Posts: 10
Joined: Mon Aug 12, 2019 11:23 am

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by Philix »

scottwilkerson wrote:That is strange, it doesn't even seem to have attempted the rotation since 8/25

what is the output of the following

Code: Select all

ps -ef|grep nagios.cfg

root@debian:~# ps -ef|grep nagios.cfg
nagios 719 1 0 08:07 ? 00:00:02 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
nagios 776 719 0 08:07 ? 00:00:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
root 4413 2940 0 08:21 pts/0 00:00:00 vi nagios.cfg
root 7813 5108 0 09:19 pts/1 00:00:00 grep nagios.cfg
root@debian:~#
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by scottwilkerson »

If you click "Process Info" from the left menu, what does it say in the "Last Log File Rotation:"?

Also, what do you get when running the following?

Code: Select all

date
date +%s
grep last_log_rotation /usr/local/nagios/var/status.dat
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Philix
Posts: 10
Joined: Mon Aug 12, 2019 11:23 am

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by Philix »

scottwilkerson wrote:If you click "Process Info" from the left menu, what does it say in the "Last Log File Rotation:"?

Also, what do you get when running the following?

Code: Select all

date
date +%s
grep last_log_rotation /usr/local/nagios/var/status.dat
Last Log File Rotation: N/A

root@debian:/usr/local/nagios/etc# date
Tue 03 Sep 2019 02:57:26 PM MDT
root@debian:/usr/local/nagios/etc# date +%s
1567544260
root@debian:/usr/local/nagios/etc# grep last_log_rotation /usr/local/nagios/var/status.dat
last_log_rotation=0
root@debian:/usr/local/nagios/etc#
root@debian:/usr/local/nagios/etc# date
Tue 03 Sep 2019 02:57:26 PM MDT
root@debian:/usr/local/nagios/etc# date +%s
1567544260
root@debian:/usr/local/nagios/etc# grep last_log_rotation /usr/local/nagios/var/status.dat
last_log_rotation=0
root@debian:/usr/local/nagios/etc#
User avatar
swolf
Developer
Posts: 301
Joined: Tue Jun 06, 2017 9:48 am

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by swolf »

Hi @Philix,

We haven't figured out what the issue is yet, but I've set up several test machines running 4.4.3 and 4.4.5 to see if we can reproduce.

There are a couple of other things we can take a look at, though they probably won't lead to resolution.

1. I'm curious to see the permissions for the two directories where these files are stored. Could you run:

Code: Select all

ls -l -d /usr/local/nagios/var
ls -l -d /usr/local/nagios/var/archives
2. When was the last time you restarted Nagios Core? If you haven't restarted between 8-25 and now, can you try that:

Code: Select all

service nagios restart
and then verify that log rotation is still broken?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy
Philix
Posts: 10
Joined: Mon Aug 12, 2019 11:23 am

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by Philix »

swolf wrote:Hi @Philix,

We haven't figured out what the issue is yet, but I've set up several test machines running 4.4.3 and 4.4.5 to see if we can reproduce.

There are a couple of other things we can take a look at, though they probably won't lead to resolution.

1. I'm curious to see the permissions for the two directories where these files are stored. Could you run:

Code: Select all

ls -l -d /usr/local/nagios/var
ls -l -d /usr/local/nagios/var/archives
drwxr-xr-x 5 nagios nagios 4096 Sep 4 11:10 /usr/local/nagios/var
root@debian:~# ls -l -d /usr/local/nagios/var/archives
drwxrwxr-x 2 nagios nagios 4096 Sep 3 13:12 /usr/local/nagios/var/archives


2. When was the last time you restarted Nagios Core? If you haven't restarted between 8-25 and now, can you try that:

Code: Select all

service nagios restart
and then verify that log rotation is still broken?
root@debian:~# service nagios restart
root@debian:~#
root@debian:~# grep last_log_rotation /usr/local/nagios/var/status.dat
last_log_rotation=0
root@debian:~# grep ROT -5 /usr/local/nagios/var/nagios.log
[1566712800] LOG ROTATION: DAILY
[1566712800] LOG VERSION: 2.0
[1566712800] CURRENT HOST STATE: localhost;UP;HARD;1;PING OK - Packet loss = 0%, RTA = 0.13 ms
[1566712800] CURRENT SERVICE STATE: localhost;Current Load;OK;HARD;1;OK - load average: 1.01, 0.82, 0.79
[1566712800] CURRENT SERVICE STATE: localhost;Current Users;OK;HARD;1;USERS OK - 1 users currently logged in
[1566712800] CURRENT SERVICE STATE: localhost;HTTP;OK;HARD;1;HTTP OK: HTTP/1.1 200 OK - 10975 bytes in 0.002 second response time

FYI
I installed PNP4Nagios and Postfix on the Nagios server on 8-25, and I restarted the Nagios process on a regular interval, using the command systemctl restart Nagios. Also, I am able to see the notification and event log files, however when clicking on the Latest Archive for both Notification and Event Log, getting the error message.
User avatar
swolf
Developer
Posts: 301
Joined: Tue Jun 06, 2017 9:48 am

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by swolf »

Okay, the directory permissions look fine.

I haven't reproduced your issue so far - though we're on day 2 so far, and yours hadn't failed by then.

When you say
I restarted the Nagios process on a regular interval, using the command systemctl restart Nagios
do you mean that you have a cron job that restarts nagios? If it runs on the hour, or close to it, or at midnight, nagios may not be running during the time it handles log rotation. If this is the case, you could try changing the command to restart at 2am or some other time that doesn't exactly match up with log rotation.

If that doesn't work, we may want to move this to the GitHub issues for this project.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy
Philix
Posts: 10
Joined: Mon Aug 12, 2019 11:23 am

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by Philix »

swolf wrote:Okay, the directory permissions look fine.

I haven't reproduced your issue so far - though we're on day 2 so far, and yours hadn't failed by then.

When you say
I restarted the Nagios process on a regular interval, using the command systemctl restart Nagios
do you mean that you have a cron job that restarts nagios? If it runs on the hour, or close to it, or at midnight, nagios may not be running during the time it handles log rotation. If this is the case, you could try changing the command to restart at 2am or some other time that doesn't exactly match up with log rotation.

If that doesn't work, we may want to move this to the GitHub issues for this project.
I didn't create a corn job, and I think, I found the reason Ngaios was not producing Archives. The Ngaios server on a virtual box, every day at the end of my shift I shut down the computer Ngaios server residing. The log rotation method is set to daily, and I assume it will take effect only after 23 pm. Yesterday I didn't shut down the system and got all the Archive logs for yesterday. Correct me if I am wrong.
User avatar
swolf
Developer
Posts: 301
Joined: Tue Jun 06, 2017 9:48 am

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by swolf »

The situation you describe would absolutely cause those issues.

If possible, you should allow the nagios server to run continuously. This way you can detect outages or other issues which would occur off-shift for you (even if you don't handle them until coming in the next day).

If that's not possible, I would recommend editing your nagios.cfg file to have log_rotation_method=h.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy
Philix
Posts: 10
Joined: Mon Aug 12, 2019 11:23 am

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by Philix »

swolf wrote:The situation you describe would absolutely cause those issues.

If possible, you should allow the nagios server to run continuously. This way you can detect outages or other issues which would occur off-shift for you (even if you don't handle them until coming in the next morning).

If that's not possible, I would recommend editing your nagios.cfg file to have log_rotation_method=h.
This is only in a test environment when it moves to production the Nagios server runs continuously. Thank you for your prompt support and I appreciate your time.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Cannot open log file '/usr/local/nagios/var/archives/nag

Post by scottwilkerson »

Philix wrote:
swolf wrote:The situation you describe would absolutely cause those issues.

If possible, you should allow the nagios server to run continuously. This way you can detect outages or other issues which would occur off-shift for you (even if you don't handle them until coming in the next morning).

If that's not possible, I would recommend editing your nagios.cfg file to have log_rotation_method=h.
This is only in a test environment when it moves to production the Nagios server runs continuously. Thank you for your prompt support and I appreciate your time.
Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked