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]
Message-Id: <20180311162621.26387-2-tomasz.torcz@nordea.com>
Date:   Sun, 11 Mar 2018 17:26:21 +0100
From:   Tomasz Torcz <tomasz.torcz@...dea.com>
To:     netdev@...r.kernel.org
Cc:     Tomasz Torcz <tomasz.torcz@...dea.com>
Subject: [PATCH] ss: introduce switch to print exact value of data rates

  Introduce -X/--exact switch to disable human-friendly printing
 of datarates. With the switch, data is not presented as MBps/Kbps.

  Signed-off-by: Tomasz Torcz <tomasz.torcz@...dea.com>
---
 misc/ss.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index e087bef7..61c917e4 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -95,6 +95,7 @@ int resolve_services = 1;
 int preferred_family = AF_UNSPEC;
 int show_options;
 int show_details;
+int show_human_readable = 1;
 int show_users;
 int show_mem;
 int show_tcpinfo;
@@ -2276,7 +2277,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.);
@@ -4502,6 +4505,7 @@ static void _usage(FILE *dest)
 "   -s, --summary       show socket usage summary\n"
 "   -b, --bpf           show bpf filter socket information\n"
 "   -E, --events        continually display sockets as they are destroyed\n"
+"   -X, --exact         show exact 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"
@@ -4634,6 +4638,7 @@ static const struct option long_opts[] = {
 	{ "net", 1, 0, 'N' },
 	{ "kill", 0, 0, 'K' },
 	{ "no-header", 0, 0, 'H' },
+	{ "exact", 0, 0, 'X' },
 	{ 0 }
 
 };
@@ -4650,7 +4655,7 @@ int main(int argc, char *argv[])
 	int screen_width = 80;
 
 	while ((ch = getopt_long(argc, argv,
-				 "dhaletuwxnro460spbEf:miA:D:F:vVzZN:KHS",
+				 "dhaletuwxXnro460spbEf:miA:D:F:vVzZN:KHS",
 				 long_opts, NULL)) != EOF) {
 		switch (ch) {
 		case 'n':
@@ -4701,6 +4706,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.14.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ