Menu

#49 Incorrect Time in Log Entries - Ver 1.10

open
Alejo S
5
2003-10-13
2003-10-13
Bob Perkins
No

Following posted to msyslog-users list on 7/6/2003:

Using the current CVS HEAD revision (1.266) of
src/syslogd.c, the timestamp of log records doesn't
change for records that are not internally generated.
It starts out repeating the initial timestamp it gets
after the system is booted, but after receiving a HUP
from newsyslog, it starts repeating unprintable
characters as the timestamp.

Jul 5 20:28:41 myhost syslogd: exiting on signal 1
Jul 5 20:29:56 myhost syslogd: restart
Jul 5 20:29:56 myhost ntpd[26709]: ntpd 4.1.72@1.762-r
Thu Oct 3 05:13:14 MDT 2002 (1)
Jul 5 20:29:56 myhost cron[25352]: (CRON) STARTUP
(fork ok)
Jul 5 20:29:56 myhost ntpd[26709]: precision = 4.000 usec
Jul 5 20:29:56 myhost CRON[5019]: (root) CMD
(/usr/local/bin/check-daemons)
Jul 5 20:29:56 myhost CRON[23780]: (root) CMD
(/usr/local/bin/check-daemons)
Jul 5 20:29:56 myhost CRON[29328]: (root) CMD
(/usr/local/bin/check-daemons)
Jul 5 20:29:56 myhost ntpd[26709]: time set -0.005208 s
Jul 5 20:29:56 myhost CRON[22081]: (root) CMD
(/usr/local/bin/check-daemons)
Jul 5 20:29:56 myhost CRON[30218]: (root) CMD
(/usr/local/bin/check-daemons)
<Snip>
Jul 5 20:29:56 myhost CRON[22782]: (root) CMD
(/usr/local/bin/check-daemons)
Jul 5 20:29:56 myhost CRON[8336]: (root) CMD
(/usr/bin/newsyslog)
Jul 5 20:29:56 myhost CRON[15188]: (root) CMD
(/usr/local/bin/check-daemons)
Jul 6 00:00:01 myhost newsyslog[3021]: logfile turned over
<New Log File>
Jul 6 00:00:01 myhost newsyslog[3021]: logfile turned over
Jul 6 00:00:02 myhost syslogd: restart
č^VĐ^@^G^@^@^A^@^@^@^\Ť= myhost CRON[22230]: (root)
CMD (/usr/local/bin/check-daemons)
č^VĐ^@^G^@^@^A^@^@^@^\Ť= myhost CRON[10831]: (root)
CMD (/usr/local/bin/check-daemons)
č^VĐ^@^G^@^@^A^@^@^@^\Ť= myhost CRON[5724]: (root) CMD
(/usr/local/bin/check-daemons)

Note: /usr/local/bin/check-daemons is run by cron once
per minute. Normal
log entries should look like this:
Jul 6 01:52:01 myhost CRON[1038]: (root) CMD
(/usr/local/bin/check-daemons)
Jul 6 01:53:02 myhost CRON[2992]: (root) CMD
(/usr/local/bin/check-daemons)
Jul 6 01:54:01 myhost CRON[16041]: (root) CMD
(/usr/local/bin/check-daemons)
Jul 6 01:55:01 myhost CRON[16695]: (root) CMD
(/usr/local/bin/check-daemons)

This problem occurs in syslogd.c because m->date is not
always set in parse_lines. The following patch is one
way to solve this problem:
==========================
--- src/syslogd.c.orig Tue Jun 17 12:35:55 2003
+++ src/syslogd.c Sun Jul 6 10:37:40 2003
@@ -842,9 +842,11 @@
if ((p = strptime(&buf[b], "%b %d
%H:%M:%S %Y ", &m->tm)) == NULL)
p = strptime(&buf[b], "%b %d
%H:%M:%S ", &m->tm);

- if (p != NULL)
+ if (p != NULL) {
b = p - buf;
- else
+ strftime(m->date,
sizeof(m->date), "%b %e %H:%M:%S", &m->tm);
+ m->fields |= M_FIELD_DATE;
+ } else
set_date(m);
}

==========================

Bob

Discussion


Log in to post a comment.