lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 1 Jul 2019 13:52:44 +0200
From:   Tomasz Torcz <tomasz.torcz@...dea.com>
To:     <dsahern@...il.com>
CC:     <netdev@...r.kernel.org>, Tomasz Torcz <tomasz.torcz@...dea.com>
Subject: [PATCH v3] ss: introduce switch to print exact value of data rates

  Introduce -X/--exact switch to disable human-friendly printing
 of data rates. Without the switch (default), data is presented as MBps/Kbps.

  Signed-off-by: Tomasz Torcz <tomasz.torcz@...dea.com>
---
 man/man8/ss.8 |  3 +++
 misc/ss.c     | 12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

 Changes in v3:
  - updated ss man page with new option

diff --git a/man/man8/ss.8 b/man/man8/ss.8
index 9054fab9..2ba5fda2 100644
--- a/man/man8/ss.8
+++ b/man/man8/ss.8
@@ -290,6 +290,9 @@ that parsing /proc/net/tcp is painful.
 .B \-E, \-\-events
 Continually display sockets as they are destroyed
 .TP
+.B \-X, \-\-exact
+Show exact bandwidth values, instead of human-readable
+.TP
 .B \-Z, \-\-context
 As the
 .B \-p
diff --git a/misc/ss.c b/misc/ss.c
index 99c06d31..ba1bfff6 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -110,6 +110,7 @@ static int resolve_services = 1;
 int preferred_family = AF_UNSPEC;
 static int show_options;
 int show_details;
+static int show_human_readable = 1;
 static int show_users;
 static int show_mem;
 static int show_tcpinfo;
@@ -2361,7 +2362,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 (!show_human_readable)
+		sprintf(buf, "%.0f", bw);
+	else if (bw > 1000000.)
 		sprintf(buf, "%.1fM", bw / 1000000.);
 	else if (bw > 1000.)
 		sprintf(buf, "%.1fK", bw / 1000.);
@@ -4883,6 +4886,7 @@ static void _usage(FILE *dest)
 "       --tos           show tos and priority information\n"
 "   -b, --bpf           show bpf filter socket information\n"
 "   -E, --events        continually display sockets as they are destroyed\n"
+"   -X, --exact         show exact bandwidth values, instead of human-readable\n"
 "   -Z, --context       display process SELinux security contexts\n"
 "   -z, --contexts      display process and socket SELinux security contexts\n"
 "   -N, --net           switch to the specified network namespace name\n"
@@ -5031,6 +5035,7 @@ static const struct option long_opts[] = {
 	{ "no-header", 0, 0, 'H' },
 	{ "xdp", 0, 0, OPT_XDPSOCK},
 	{ "oneline", 0, 0, 'O' },
+	{ "exact", 0, 0, 'X' },
 	{ 0 }
 
 };
@@ -5046,7 +5051,7 @@ int main(int argc, char *argv[])
 	int state_filter = 0;
 
 	while ((ch = getopt_long(argc, argv,
-				 "dhaletuwxnro460spbEf:miA:D:F:vVzZN:KHSO",
+				 "dhaletuwxXnro460spbEf:miA:D:F:vVzZN:KHSO",
 				 long_opts, NULL)) != EOF) {
 		switch (ch) {
 		case 'n':
@@ -5097,6 +5102,9 @@ int main(int argc, char *argv[])
 		case 'x':
 			filter_af_set(&current_filter, AF_UNIX);
 			break;
+		case 'X':
+			show_human_readable = 0;
+			break;
 		case OPT_VSOCK:
 			filter_af_set(&current_filter, AF_VSOCK);
 			break;
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ