Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Feb 2026 12:41:53 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        Warner Losh <imp@freebsd.org>, src-committers <src-committers@freebsd.org>,  "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>,  "<dev-commits-src-main@freebsd.org>" <dev-commits-src-main@freebsd.org>
Subject:   Re: git: 8e593a1f1432 - main - fortune: fix netstat tip
Message-ID:  <CANCZdfpsafyDVhMA84PyGiVNonDP8Vd8_hXTx7W_WpH9Sw7ceA@mail.gmail.com>
In-Reply-To: <06f7c9c0-a681-4573-8b1d-83b65f825d5b@FreeBSD.org>
References:  <6995eeee.37508.1de1224c@gitrepo.freebsd.org> <06f7c9c0-a681-4573-8b1d-83b65f825d5b@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Wed, Feb 18, 2026, 11:51 AM John Baldwin <jhb@freebsd.org> wrote:

> On 2/18/26 11:55, Warner Losh wrote:
> > The branch main has been updated by imp:
> >
> > URL:
> https://cgit.FreeBSD.org/src/commit/?id=8e593a1f143203cace2e14bd6629a8ebdf9b47dc
> >
> > commit 8e593a1f143203cace2e14bd6629a8ebdf9b47dc
> > Author:     Warner Losh <imp@FreeBSD.org>
> > AuthorDate: 2026-02-10 14:59:58 +0000
> > Commit:     Warner Losh <imp@FreeBSD.org>
> > CommitDate: 2026-02-18 16:39:28 +0000
> >
> >      fortune: fix netstat tip
> >
> >      netstati <mumble> 8 reports in bytes per second (averaged over 8
> >      seconds) rather than bits per second because it reports the total
> >      in bits over the 8 seconds...
> >
> >      Sponsored by:           Netflix
>
> Eh, I originally thought this too, but the original hint is right.  netstat
> doesn't report a per-second average, just the delta, so when using '8' it
> is showing the number of bytes sent/received in the 8 second interval which
> effectively multiplies the per-second rate by 8, so if it is a constant
> rate you get the bits-per-second as the output.
>
> Relevant code from sidewaysintpr() in if.c:
>
>         fill_iftot(new);
>
>         xo_open_instance("stats");
>         show_stat("lu", 10, "received-packets",
>             new->ift_ip - old->ift_ip, 1, 1);
>         show_stat("lu", 5, "received-errors",
>             new->ift_ie - old->ift_ie, 1, 1);
>         show_stat("lu", 5, "dropped-packets",
>             new->ift_id - old->ift_id, 1, 1);
>         show_stat("lu", 10, "received-bytes",
>             new->ift_ib - old->ift_ib, 1, 0);
>         show_stat("lu", 10, "sent-packets",
>             new->ift_op - old->ift_op, 1, 1);
>         show_stat("lu", 5, "send-errors",
>             new->ift_oe - old->ift_oe, 1, 1);
>         show_stat("lu", 10, "sent-bytes",
>             new->ift_ob - old->ift_ob, 1, 0);
>         show_stat("NRSlu", 5, "collisions",
>             new->ift_co - old->ift_co, 1, 1);
>         if (dflag)
>                 show_stat("LSlu", 5, "dropped-packets",
>                     new->ift_od - old->ift_od, 1, 1);
>         xo_close_instance("stats");
>         xo_emit("\n");
>         xo_flush();
>
> (Note no scaling, just 'new - old')
>

Oh. Damn. I'll revert

-- 
> John Baldwin
>
>

[-- Attachment #2 --]
<div dir="auto"><div><br><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Feb 18, 2026, 11:51 AM John Baldwin &lt;<a href="mailto:jhb@freebsd.org">jhb@freebsd.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2/18/26 11:55, Warner Losh wrote:<br>
&gt; The branch main has been updated by imp:<br>
&gt; <br>
&gt; URL: <a href="https://cgit.FreeBSD.org/src/commit/?id=8e593a1f143203cace2e14bd6629a8ebdf9b47dc" rel="noreferrer noreferrer" target="_blank">https://cgit.FreeBSD.org/src/commit/?id=8e593a1f143203cace2e14bd6629a8ebdf9b47dc</a><br>;
&gt; <br>
&gt; commit 8e593a1f143203cace2e14bd6629a8ebdf9b47dc<br>
&gt; Author:     Warner Losh &lt;imp@FreeBSD.org&gt;<br>
&gt; AuthorDate: 2026-02-10 14:59:58 +0000<br>
&gt; Commit:     Warner Losh &lt;imp@FreeBSD.org&gt;<br>
&gt; CommitDate: 2026-02-18 16:39:28 +0000<br>
&gt; <br>
&gt;      fortune: fix netstat tip<br>
&gt;      <br>
&gt;      netstati &lt;mumble&gt; 8 reports in bytes per second (averaged over 8<br>
&gt;      seconds) rather than bits per second because it reports the total<br>
&gt;      in bits over the 8 seconds...<br>
&gt;      <br>
&gt;      Sponsored by:           Netflix<br>
<br>
Eh, I originally thought this too, but the original hint is right.  netstat<br>
doesn&#39;t report a per-second average, just the delta, so when using &#39;8&#39; it<br>
is showing the number of bytes sent/received in the 8 second interval which<br>
effectively multiplies the per-second rate by 8, so if it is a constant<br>
rate you get the bits-per-second as the output.<br>
<br>
Relevant code from sidewaysintpr() in if.c:<br>
<br>
        fill_iftot(new);<br>
<br>
        xo_open_instance(&quot;stats&quot;);<br>
        show_stat(&quot;lu&quot;, 10, &quot;received-packets&quot;,<br>
            new-&gt;ift_ip - old-&gt;ift_ip, 1, 1);<br>
        show_stat(&quot;lu&quot;, 5, &quot;received-errors&quot;,<br>
            new-&gt;ift_ie - old-&gt;ift_ie, 1, 1);<br>
        show_stat(&quot;lu&quot;, 5, &quot;dropped-packets&quot;,<br>
            new-&gt;ift_id - old-&gt;ift_id, 1, 1);<br>
        show_stat(&quot;lu&quot;, 10, &quot;received-bytes&quot;,<br>
            new-&gt;ift_ib - old-&gt;ift_ib, 1, 0);<br>
        show_stat(&quot;lu&quot;, 10, &quot;sent-packets&quot;,<br>
            new-&gt;ift_op - old-&gt;ift_op, 1, 1);<br>
        show_stat(&quot;lu&quot;, 5, &quot;send-errors&quot;,<br>
            new-&gt;ift_oe - old-&gt;ift_oe, 1, 1);<br>
        show_stat(&quot;lu&quot;, 10, &quot;sent-bytes&quot;,<br>
            new-&gt;ift_ob - old-&gt;ift_ob, 1, 0);<br>
        show_stat(&quot;NRSlu&quot;, 5, &quot;collisions&quot;,<br>
            new-&gt;ift_co - old-&gt;ift_co, 1, 1);<br>
        if (dflag)<br>
                show_stat(&quot;LSlu&quot;, 5, &quot;dropped-packets&quot;,<br>
                    new-&gt;ift_od - old-&gt;ift_od, 1, 1);<br>
        xo_close_instance(&quot;stats&quot;);<br>
        xo_emit(&quot;\n&quot;);<br>
        xo_flush();<br>
<br>
(Note no scaling, just &#39;new - old&#39;)<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Oh. Damn. I&#39;ll revert</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-- <br>
John Baldwin<br>
<br>
</blockquote></div></div></div>
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfpsafyDVhMA84PyGiVNonDP8Vd8_hXTx7W_WpH9Sw7ceA>