• kern.msgbuf_show_timestamp=1

    From void@void@f-m.fm to muc.lists.freebsd.stable on Fri Dec 19 17:21:28 2025
    From Newsgroup: muc.lists.freebsd.stable

    Hi,

    In /etc/sysctl.conf I have

    kern.msgbuf_show_timestamp=1

    and so dmsg has things like

    [1353919] swp_pager_getswapspace(32): failed

    the [1353919] I guess being the timestamp.

    But what is it?

    Seconds since boot?

    If it's that, then where can the true boot time be
    found?

    If not, then what does the number signify?
    --


    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Jamie Landeg-Jones@jamie@catflap.org to muc.lists.freebsd.stable on Fri Dec 19 20:37:41 2025
    From Newsgroup: muc.lists.freebsd.stable

    void <void@f-m.fm> wrote:

    Hi,

    In /etc/sysctl.conf I have

    kern.msgbuf_show_timestamp=1

    and so dmsg has things like

    [1353919] swp_pager_getswapspace(32): failed

    the [1353919] I guess being the timestamp.

    But what is it?

    Seconds since boot?

    If it's that, then where can the true boot time be
    found?

    Yes! You can get the value from sysctl kern.boottime.

    Here is a small program I wrote a while back, just call it
    as a dmesg substitute.

    It uses gawk because of strftime, but now that native awk handles strftime,
    it could be converted to use that (gensub will have to be modified)

    gawk is in lang/gawk

    Incidentally, if you put the kern.msgbuf_show_timestamp=1
    in boot/loader.conf instead, it starts much earlier in the boot process,
    useful if you are anal about the format of bootup dmesg output!

    Cheers, Jamie

    #!/bin/sh -efu
    set -efu

    boottime="$(/sbin/sysctl -n kern.boottime | /usr/local/bin/gawk '{printf "%d", gensub ("^.* sec = ([1-9][0-9]*), .*$", "\\1", 1)}')"

    [ -z "$(printf '%s' "$boottime" | /usr/bin/egrep '^0$|^[1-9][0-9]*$')" ] && { printf 'Invalid boottime retrieved.\n' >& 2; exit 1; }

    /sbin/dmesg "$@" | /usr/local/bin/gawk -v boottime="$boottime" '

    {
    uptime = gensub ("^\\[([1-9][0-9]*)\\] .*$", "\\1", 1)
    if (uptime == $0) realtime = "??? ?? ??:??;??"
    else realtime = strftime ("%b %d %T", uptime + boottime)

    print realtime " " $0
    }'


    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Warner Losh@imp@bsdimp.com to muc.lists.freebsd.stable on Fri Dec 19 15:45:06 2025
    From Newsgroup: muc.lists.freebsd.stable

    --000000000000e3297a064655d4c2
    Content-Type: text/plain; charset="UTF-8"
    Content-Transfer-Encoding: quoted-printable

    On Fri, Dec 19, 2025 at 10:22=E2=80=AFAM void <void@f-m.fm> wrote:

    Hi,

    In /etc/sysctl.conf I have

    kern.msgbuf_show_timestamp=3D1

    and so dmsg has things like

    [1353919] swp_pager_getswapspace(32): failed

    the [1353919] I guess being the timestamp.

    But what is it?

    Seconds since boot?

    If it's that, then where can the true boot time be
    found?


    Seconds since boot time.

    % sysctl kern.boottime
    kern.boottime: { sec =3D 1765407044, usec =3D 678571 } Wed Dec 10 15:50:44 = 2025

    Warner



    If not, then what does the number signify?





    --



    --000000000000e3297a064655d4c2
    Content-Type: text/html; charset="UTF-8"
    Content-Transfer-Encoding: quoted-printable

    <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote g= mail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Dec 19,=
    2025 at 10:22=E2=80=AFAM void &lt;<a href=3D"mailto:void@f-m.fm">void@f-m.= fm</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margi= n:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex= ">Hi,<br>

    In /etc/sysctl.conf I have<br>

    kern.msgbuf_show_timestamp=3D1<br>

    and so dmsg has things like<br>

    [1353919] swp_pager_getswapspace(32): failed<br>

    the [1353919] I guess being the timestamp.<br>

    But what is it?<br>

    Seconds since boot?<br>

    If it&#39;s that, then where can the true boot time be <br> found?<br></blockquote><div><br></div><div>Seconds since boot time.</div><d= iv><br></div><div>% sysctl=C2=A0kern.boottime</div><div>kern.boottime: { se=
    c =3D 1765407044, usec =3D 678571 } Wed Dec 10 15:50:44 2025</div><div><br>= </div><div>Warner</div><div><br></div><div>=C2=A0</div><blockquote class=3D= "gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(2= 04,204,204);padding-left:1ex">
    If not, then what does the number signify?<br>





    -- <br>

    </blockquote></div></div>

    --000000000000e3297a064655d4c2--


    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Warner Losh@imp@bsdimp.com to muc.lists.freebsd.stable on Fri Dec 19 15:47:28 2025
    From Newsgroup: muc.lists.freebsd.stable

    --0000000000004f8519064655dd82
    Content-Type: text/plain; charset="UTF-8"
    Content-Transfer-Encoding: quoted-printable

    On Fri, Dec 19, 2025 at 1:38=E2=80=AFPM Jamie Landeg-Jones <jamie@catflap.o=

    wrote:

    void <void@f-m.fm> wrote:

    Hi,

    In /etc/sysctl.conf I have

    kern.msgbuf_show_timestamp=3D1

    and so dmsg has things like

    [1353919] swp_pager_getswapspace(32): failed

    the [1353919] I guess being the timestamp.

    But what is it?

    Seconds since boot?

    If it's that, then where can the true boot time be
    found?

    Yes! You can get the value from sysctl kern.boottime.

    Here is a small program I wrote a while back, just call it
    as a dmesg substitute.

    It uses gawk because of strftime, but now that native awk handles strftim=
    e,
    it could be converted to use that (gensub will have to be modified)

    gawk is in lang/gawk

    Incidentally, if you put the kern.msgbuf_show_timestamp=3D1
    in boot/loader.conf instead, it starts much earlier in the boot process, useful if you are anal about the format of bootup dmesg output!

    Cheers, Jamie

    #!/bin/sh -efu
    set -efu

    boottime=3D"$(/sbin/sysctl -n kern.boottime | /usr/local/bin/gawk '{print=
    f
    "%d", gensub ("^.* sec =3D ([1-9][0-9]*), .*$", "\\1", 1)}')"

    [ -z "$(printf '%s' "$boottime" | /usr/bin/egrep '^0$|^[1-9][0-9]*$')" ]
    && { printf 'Invalid boottime retrieved.\n' >& 2; exit 1; }

    /sbin/dmesg "$@" | /usr/local/bin/gawk -v boottime=3D"$boottime" '

    {
    uptime =3D gensub ("^\\[([1-9][0-9]*)\\] .*$", "\\1", 1)
    if (uptime =3D=3D $0) realtime =3D "??? ?? ??:??;??"
    else realtime =3D strftime ("%b %d %T", uptime + boottime)

    print realtime " " $0
    }'


    Very cool!

    Warner

    --0000000000004f8519064655dd82
    Content-Type: text/html; charset="UTF-8"
    Content-Transfer-Encoding: quoted-printable

    <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote g= mail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Dec 19,=
    2025 at 1:38=E2=80=AFPM Jamie Landeg-Jones &lt;<a href=3D"mailto:jamie@cat= flap.org">jamie@catflap.org</a>&gt; wrote:<br></div><blockquote class=3D"gm= ail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,= 204,204);padding-left:1ex">void &lt;<a href=3D"mailto:void@f-m.fm" target= =3D"_blank">void@f-m.fm</a>&gt; wrote:<br>

    &gt; Hi,<br>
    &gt;<br>
    &gt; In /etc/sysctl.conf I have<br>
    &gt;<br>
    &gt; kern.msgbuf_show_timestamp=3D1<br>
    &gt;<br>
    &gt; and so dmsg has things like<br>
    &gt;<br>
    &gt; [1353919] swp_pager_getswapspace(32): failed<br>
    &gt;<br>
    &gt; the [1353919] I guess being the timestamp.<br>
    &gt;<br>
    &gt; But what is it?<br>
    &gt;<br>
    &gt; Seconds since boot?<br>
    &gt;<br>
    &gt; If it&#39;s that, then where can the true boot time be <br>
    &gt; found?<br>

    Yes! You can get the value from sysctl kern.boottime.<br>

    Here is a small program I wrote a while back, just call it<br>
    as a dmesg substitute.<br>

    It uses gawk because of strftime, but now that native awk handles strftime,=

    it could be converted to use that (gensub will have to be modified)<br>

    gawk is in lang/gawk<br>

    Incidentally, if you put the kern.msgbuf_show_timestamp=3D1<br>
    in boot/loader.conf instead, it starts much earlier in the boot process,<br=

    useful if you are anal about the format of bootup dmesg output!<br>

    Cheers, Jamie<br>

    #!/bin/sh -efu<br>
    set -efu<br>

    boottime=3D&quot;$(/sbin/sysctl -n kern.boottime | /usr/local/bin/gawk &#39= ;{printf &quot;%d&quot;, gensub (&quot;^.* sec =3D ([1-9][0-9]*), .*$&quot;=
    , &quot;\\1&quot;, 1)}&#39;)&quot;<br>

    [ -z &quot;$(printf &#39;%s&#39; &quot;$boottime&quot; | /usr/bin/egrep &#3= 9;^0$|^[1-9][0-9]*$&#39;)&quot; ] &amp;&amp; { printf &#39;Invalid boottime=
    retrieved.\n&#39; &gt;&amp; 2; exit 1; }<br>

    /sbin/dmesg &quot;$@&quot; | /usr/local/bin/gawk -v boottime=3D&quot;$boott= ime&quot; &#39;<br>

    =C2=A0 =C2=A0 {<br>
    =C2=A0 =C2=A0 =C2=A0 uptime =3D gensub (&quot;^\\[([1-9][0-9]*)\\] .*$&quot=
    ;, &quot;\\1&quot;, 1)<br>
    =C2=A0 =C2=A0 =C2=A0 if (uptime =3D=3D $0) realtime =3D &quot;??? ?? ??:??;= ??&quot;<br>
    =C2=A0 =C2=A0 =C2=A0 =C2=A0else realtime =3D strftime (&quot;%b %d %T&quot;=
    , uptime + boottime)<br>

    =C2=A0 =C2=A0 =C2=A0 print realtime &quot; &quot; $0<br>
    =C2=A0 =C2=A0 }&#39;<br></blockquote><div><br></div><div>Very cool!</div><d= iv><br></div><div>Warner=C2=A0</div></div></div>

    --0000000000004f8519064655dd82--


    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Jamie Landeg-Jones@jamie@catflap.org to muc.lists.freebsd.stable on Sat Dec 20 02:10:31 2025
    From Newsgroup: muc.lists.freebsd.stable

    Warner Losh <imp@bsdimp.com> wrote:

    Very cool!

    Thanks! I always intended on adding this option to the dmesg command
    itself, but as with most things I fiddle with, the itch scratching
    stopped at the point of achieving an AWK wrapper script around the
    original command, so instead it got relegated to the ever expanding
    TODO list!

    Cheers, Jamie


    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From void@void@f-m.fm to muc.lists.freebsd.stable on Sat Dec 20 02:46:59 2025
    From Newsgroup: muc.lists.freebsd.stable

    On Fri, Dec 19, 2025 at 08:37:41PM +0000, Jamie Landeg-Jones wrote:
    Yes! You can get the value from sysctl kern.boottime.

    Here is a small program I wrote a while back, just call it
    as a dmesg substitute.

    This is great TYVM!
    --


    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.21a-Linux NewsLink 1.2