<div dir="ltr">On 12 September 2013 14:23, Lennart Poettering <span dir="ltr"><<a href="mailto:lennart@poettering.net" target="_blank">lennart@poettering.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thu, 12.09.13 11:44, Lars Gullik Bjønnes (<a href="mailto:larsbj@gullik.org">larsbj@gullik.org</a>) wrote:<br>

<br>
><br>
> Also pass fractional seconds to syslog. This allows the syslog<br>
> daemon to show the fractional seconds at its own choosing.<br>
> ---<br>
><br>
> This has so far only been compile tested, and I am not sure if<br>
> other syslog deamons than syslog-ng will work with this.<br>
<br>
</div>When passing native data on to a syslog daemon we currently generate the<br>
exact format glibc generates on the /dev/syslog socket.<br>
<br>
Also note that for the case where we receieved a message via the syslog<br>
protocol we actually pass the bytewise identical message on<br>
(forward_syslog_raw() does that). Since most traffic still comes in via<br>
the syslog protocol your change won't affect most of the traffic<br>
hence. This means: to make this fully useful you'd have to patch glibc<br>
too, to generate the precise format. However, systemd is currently not<br>
capable of parsing that precise format, so you'd have to add that too...<br></blockquote><div><br></div><div>I do not see the need for patching glibc, that will work like it has always done.</div><div>I agree that systemd must learn how to read the fractional seconds.</div>
<div>(after all part of both new and old syslog RFC's)</div><div> </div><div>Current status in our environment is that we don't use syslog(3) for this, especially to get fractions.</div><div>We want to use sd_journal_* instead, but we do not want to loose the fractional seconds that</div>
<div>we have to day.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Then, we can only merge this if the three big syslog implementations,<br>
rsyslog, syslog-ng, sysklogd are known to understand this formatting in<br>
their default configuration<br></blockquote><div><br></div><div>syslog-ng certainly both reads and writes this format.</div><div>I will have to check the tow others (but if they implement the old (and new) RFC</div><div>
they should undertand it already.)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Lennart<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
><br>
> [Sorry if you see this twice on list.]<br>
><br>
>  src/journal/journald-syslog.c | 11 +++++++++--<br>
>  1 file changed, 9 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c<br>
> index c2770a5..2233416 100644<br>
> --- a/src/journal/journald-syslog.c<br>
> +++ b/src/journal/journald-syslog.c<br>
> @@ -125,6 +125,8 @@ void server_forward_syslog(Server *s, int priority, const char *identifier, cons<br>
>          char header_priority[6], header_time[64], header_pid[16];<br>
>          int n = 0;<br>
>          time_t t;<br>
> +        usec_t realtime;<br>
> +        suseconds_t us;<br>
>          struct tm *tm;<br>
>          char *ident_buf = NULL;<br>
><br>
> @@ -142,12 +144,17 @@ void server_forward_syslog(Server *s, int priority, const char *identifier, cons<br>
>          IOVEC_SET_STRING(iovec[n++], header_priority);<br>
><br>
>          /* Second: timestamp */<br>
> -        t = tv ? tv->tv_sec : ((time_t) (now(CLOCK_REALTIME) / USEC_PER_SEC));<br>
> +        realtime = now(CLOCK_REALTIME);<br>
> +        t = tv ? tv->tv_sec : ((time_t) (realtime / USEC_PER_SEC));<br>
> +        us = tv ? tv->tv_usec : ((suseconds_t)(realtime % USEC_PER_SEC));<br>
>          tm = localtime(&t);<br>
>          if (!tm)<br>
>                  return;<br>
> -        if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)<br>
> +        if (strftime(header_time, sizeof(header_time), "%h %e %T", tm) <= 0)<br>
>                  return;<br>
> +        snprintf(header_time + strlen(header_time), sizeof(header_time) - strlen(header_time),<br>
> +                 ".%06lu ", us);<br>
> +<br>
>          IOVEC_SET_STRING(iovec[n++], header_time);<br>
><br>
>          /* Third: identifier and PID */<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">Lennart<br>
<br>
--<br>
Lennart Poettering - Red Hat, Inc.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>        Lgb
</div></div>