]>
Commit | Line | Data |
---|---|---|
27a9d69f ER |
1 | set sane format for archived logs, so the files would be sortable |
2 | ideally this should came from config (date_format=iso8601) | |
3 | ||
2a5edde2 AM |
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 | |
8 | close_log_file(); | |
27a9d69f ER |
9 | |
10 | /* get the archived filename to use */ | |
4ad96cc5 | 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); |
768681e9 | 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); |
4ad96cc5 | 13 | |
2a5edde2 AM |
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, | |
f9ffdd32 | 20 | t = localtime(&this_scheduled_log_rotation); |
27a9d69f ER |
21 | |
22 | /* use the time that the log rotation occurred to figure out the name of the log file */ | |
f9ffdd32 | 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); | |
4ad96cc5 | 25 | buffer[buffer_length - 1] = '\x0'; |
27a9d69f ER |
26 | |
27 | return; |