1 set sane format for archived logs, so the files would be sortable
2 ideally this should came from config (date_format=iso8601)
4 diff -urNp -x '*.orig' nagios-4.4.6.org/base/logging.c nagios-4.4.6/base/logging.c
5 --- nagios-4.4.6.org/base/logging.c 2021-04-19 12:04:00.320026000 +0200
6 +++ nagios-4.4.6/base/logging.c 2021-04-19 12:04:00.590034030 +0200
7 @@ -406,7 +406,7 @@ int rotate_log_file(time_t rotation_time
10 /* get the archived filename to use */
11 - asprintf(&log_archive, "%s%snagios-%02d-%02d-%d-%02d.log", log_archive_path, (log_archive_path[strlen(log_archive_path) - 1] == '/') ? "" : "/", t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour);
12 + asprintf(&log_archive, "%s%snagios-%04d-%02d-%02d-%02d.log", log_archive_path, (log_archive_path[strlen(log_archive_path) - 1] == '/') ? "" : "/", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour);
14 /* HACK: If the archive exists, don't overwrite it. This is a hack
15 because the real problem is that some log rotations are executed
16 diff -urNp -x '*.orig' nagios-4.4.6.org/cgi/cgiutils.c nagios-4.4.6/cgi/cgiutils.c
17 --- nagios-4.4.6.org/cgi/cgiutils.c 2021-04-19 12:04:00.296691972 +0200
18 +++ nagios-4.4.6/cgi/cgiutils.c 2021-04-19 12:04:00.590034030 +0200
19 @@ -1468,7 +1468,7 @@ void get_log_archive_to_use(int archive,
20 t = localtime(&this_scheduled_log_rotation);
22 /* use the time that the log rotation occurred to figure out the name of the log file */
23 - snprintf(buffer, buffer_length, "%snagios-%02d-%02d-%d-%02d.log", log_archive_path, t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour);
24 + snprintf(buffer, buffer_length, "%snagios-%04d-%02d-%02d-%02d.log", log_archive_path, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour);
25 buffer[buffer_length - 1] = '\x0';