bab9bb6b69
Create new directories: ceph config config-files filesystem kernel kernel/kernel-modules ldap logging strorage-drivers tools utilities virt Retire directories: connectivity core devtools support extended Delete two packages: tgt irqbalance Relocated packages: base/ dhcp initscripts libevent lighttpd linuxptp memcached net-snmp novnc ntp openssh pam procps sanlock shadow sudo systemd util-linux vim watchdog ceph/ python-cephclient config/ facter puppet-4.8.2 puppet-modules filesystem/ e2fsprogs nfs-utils nfscheck kernel/ kernel-std kernel-rt kernel/kernel-modules/ mlnx-ofa_kernel ldap/ nss-pam-ldapd openldap logging/ syslog-ng logrotate networking/ lldpd iproute mellanox python-ryu mlx4-config python/ python-2.7.5 python-django python-gunicorn python-setuptools python-smartpm python-voluptuous security/ shim-signed shim-unsigned tboot strorage-drivers/ python-3parclient python-lefthandclient virt/ cloud-init libvirt libvirt-python qemu tools/ storage-topology vm-topology utilities/ tis-extensions namespace-utils nova-utils update-motd Change-Id: I37ade764d873c701b35eac5881eb40412ba64a86 Story: 2002801 Task: 22687 Signed-off-by: Scott Little <scott.little@windriver.com>
80 lines
2.7 KiB
Diff
80 lines
2.7 KiB
Diff
From 08353c7cc596d2d09fd7f22a9bfde4d83bd9ebda Mon Sep 17 00:00:00 2001
|
|
From: systemd team <systemd-maint@redhat.com>
|
|
Date: Tue, 8 Nov 2016 17:06:01 -0500
|
|
Subject: [PATCH 1/1] inject millisec in syslog date
|
|
|
|
---
|
|
src/journal/journald-syslog.c | 48 +++++++++++++++++++++++++++++++++++++------
|
|
1 file changed, 42 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
|
|
index 4e118aa..85cdeb9 100644
|
|
--- a/src/journal/journald-syslog.c
|
|
+++ b/src/journal/journald-syslog.c
|
|
@@ -35,6 +35,44 @@
|
|
/* Warn once every 30s if we missed syslog message */
|
|
#define WARN_FORWARD_SYSLOG_MISSED_USEC (30 * USEC_PER_SEC)
|
|
|
|
+/* internal function that builds a formatted time str of the
|
|
+ * tv parameter into the passed buffer. (ie Nov 7 16:28:38.109)
|
|
+ * If tv is NULL, then the clock function is used to build the formatted time
|
|
+ * returns (same as snprintf) - number of characters written to buffer.
|
|
+ */
|
|
+static int formatSyslogDate(char * buffer, int bufLen, const struct timeval *tv) {
|
|
+ struct timeval tv_tmp;
|
|
+ long int millisec;
|
|
+ char tmpbuf[64];
|
|
+ struct tm *tm;
|
|
+ time_t t;
|
|
+
|
|
+ if (!tv) {
|
|
+ // no timeval input so get time data from clock
|
|
+ usec_t now_usec = now(CLOCK_REALTIME);
|
|
+ time_t now_sec = ((time_t) now_usec / USEC_PER_SEC);
|
|
+ long int now_fraction_secs = now_usec % USEC_PER_SEC;
|
|
+ tv_tmp.tv_sec = now_sec;
|
|
+ tv_tmp.tv_usec = now_fraction_secs;
|
|
+ tv = &tv_tmp;
|
|
+ }
|
|
+
|
|
+ t = tv->tv_sec;
|
|
+ tm = localtime(&t);
|
|
+ if (!tm)
|
|
+ return 0;
|
|
+
|
|
+ // format time to the second granularity - ie Nov 7 16:28:38
|
|
+ if (strftime(tmpbuf,sizeof(tmpbuf),"%h %e %T", tm) <= 0)
|
|
+ return 0;
|
|
+
|
|
+ millisec = tv->tv_usec / 1000;
|
|
+ // now append millisecond granularity (ie Nov 7 16:28:38.109) to
|
|
+ // the formatted string.
|
|
+ return snprintf(buffer, bufLen, "%s.%03lu", tmpbuf, millisec);
|
|
+}
|
|
+
|
|
+
|
|
static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned n_iovec, const struct ucred *ucred, const struct timeval *tv) {
|
|
|
|
static const union sockaddr_union sa = {
|
|
@@ -143,13 +181,11 @@ void server_forward_syslog(Server *s, int priority, const char *identifier, cons
|
|
xsprintf(header_priority, "<%i>", priority);
|
|
IOVEC_SET_STRING(iovec[n++], header_priority);
|
|
|
|
+
|
|
/* Second: timestamp */
|
|
- t = tv ? tv->tv_sec : ((time_t) (now(CLOCK_REALTIME) / USEC_PER_SEC));
|
|
- tm = localtime(&t);
|
|
- if (!tm)
|
|
- return;
|
|
- if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)
|
|
- return;
|
|
+ if (formatSyslogDate(header_time, sizeof(header_time), tv) <=0 )
|
|
+ return;
|
|
+
|
|
IOVEC_SET_STRING(iovec[n++], header_time);
|
|
|
|
/* Third: identifier and PID */
|
|
--
|
|
1.9.1
|
|
|