Hi,
I have a temporary installation of Nagios in a virtual machine, on a computer that I turn off for the night. After turning it on, a message appears in the logs
[1687278386] Warning: A system time change of 7880 seconds (0d 2h 11m 20s forwards in time) has been detected. Compensating...
So it would seem that Nagios has understood that the time has changed and should work. Unfortunately, the service monitoring freezes. Only a restart of Nagios helps. Is this standard behaviour or a bug? On the production server I have never had a similar problem with monitoring freezing.
In summary, the web interface works, but the 'last check' of the services is from the previous day. I waited an hour and nothing.
Monitoring freeze after time change
Re: Monitoring freeze after time change
I temporarily solved the problem through a small program in C
then
and add to /etc/crontab
Code: Select all
vim /root/timechange.c
Code: Select all
#include <sys/timerfd.h>
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
while(1) {
int fd = timerfd_create(CLOCK_REALTIME, 0);
timerfd_settime(fd, TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET,
&(struct itimerspec){ .it_value = { .tv_sec = INT_MAX } },
NULL);
printf("Waiting\n");
char buffer[10];
if (-1 == read(fd, &buffer, 10)) {
if (errno == ECANCELED) {
printf("Timer cancelled - system clock changed\n");
system("systemctl reload nagios");
}
else
perror("error");
}
close(fd);
}
return(0);
}
Code: Select all
# gcc timechange.c -o timechange; chmod +x timechange
Code: Select all
@reboot root /root/timechange &