Monitoring freeze after time change

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.
Post Reply
ELger
Posts: 2
Joined: Wed Jun 21, 2023 5:50 am

Monitoring freeze after time change

Post by ELger »

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.
ELger
Posts: 2
Joined: Wed Jun 21, 2023 5:50 am

Re: Monitoring freeze after time change

Post by ELger »

I temporarily solved the problem through a small program in C

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);
}

then

Code: Select all

# gcc timechange.c -o timechange; chmod +x timechange
and add to /etc/crontab

Code: Select all

@reboot root /root/timechange &
bv406
Posts: 31
Joined: Tue Apr 11, 2023 11:45 am

Re: Monitoring freeze after time change

Post by bv406 »

Maybe refer to this post to see if it helps.

viewtopic.php?p=232597
Post Reply