ss: in --numeric mode, print raw numbers for data rates

ss by default shows data rates in human-readable form - as Mbps/Gbps etc.
 Enhance --numeric mode to show raw values in bps, without conversion.

  Signed-of-by: Tomasz Torcz <tomasz.torcz@nordea.com>

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Tomasz Torcz 2019-07-02 08:53:39 +02:00 committed by Stephen Hemminger
parent c95e17dcba
commit d791e75d74
2 changed files with 4 additions and 2 deletions

View File

@ -28,7 +28,7 @@ Suppress header line.
Print each socket's data on a single line.
.TP
.B \-n, \-\-numeric
Do not try to resolve service names.
Do not try to resolve service names. Show exact bandwidth values, instead of human-readable.
.TP
.B \-r, \-\-resolve
Try to resolve numeric address/ports.

View File

@ -2361,7 +2361,9 @@ static int proc_inet_split_line(char *line, char **loc, char **rem, char **data)
static char *sprint_bw(char *buf, double bw)
{
if (bw > 1000000.)
if (!resolve_services)
sprintf(buf, "%.0f", bw);
else if (bw > 1000000.)
sprintf(buf, "%.1fM", bw / 1000000.);
else if (bw > 1000.)
sprintf(buf, "%.1fK", bw / 1000.);