Re: git: 8e593a1f1432 - main - fortune: fix netstat tip
- In reply to: John Baldwin : "Re: git: 8e593a1f1432 - main - fortune: fix netstat tip"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 18 Feb 2026 19:41:53 UTC
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
>
>