From 504e7b995913956f71fe76c93e439df63701c0b3 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Mon, 30 Nov 2015 14:06:07 +0300 Subject: cli: show sesisons: introduced rx-bytes-raw,tx-bytes-raw fields --- accel-pppd/cli/show_sessions.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c index d64a6b56..fd2f2b43 100644 --- a/accel-pppd/cli/show_sessions.c +++ b/accel-pppd/cli/show_sessions.c @@ -476,7 +476,7 @@ static void format_bytes(char *buf, unsigned long long bytes) double d; if (bytes < 1024) { - sprintf(buf, "%u (%u B)", (unsigned)bytes, (unsigned)bytes); + sprintf(buf, "%u B", (unsigned)bytes); return; } @@ -492,7 +492,7 @@ static void format_bytes(char *buf, unsigned long long bytes) } d = (double)bytes/m; - sprintf(buf, "%llu (%.1f %s)", bytes, d, suffix); + sprintf(buf, "%.1f %s", d, suffix); } static void print_rx_bytes(struct ap_session *ses, char *buf) @@ -513,6 +513,24 @@ static void print_tx_bytes(struct ap_session *ses, char *buf) format_bytes(buf, 4294967296ll*ses->acct_output_gigawords + stats.tx_bytes); } +static void print_rx_bytes_raw(struct ap_session *ses, char *buf) +{ + if (!stats_set) { + ap_session_read_stats(ses, &stats); + stats_set = 1; + } + sprintf(buf, "%llu", 4294967296ll*ses->acct_input_gigawords + stats.rx_bytes); +} + +static void print_tx_bytes_raw(struct ap_session *ses, char *buf) +{ + if (!stats_set) { + ap_session_read_stats(ses, &stats); + stats_set = 1; + } + sprintf(buf, "%llu", 4294967296ll*ses->acct_output_gigawords + stats.tx_bytes); +} + static void print_rx_pkts(struct ap_session *ses, char *buf) { if (!stats_set) { @@ -568,8 +586,10 @@ static void init(void) cli_show_ses_register("called-sid", "called station id", print_called_sid); cli_show_ses_register("sid", "session id", print_sid); cli_show_ses_register("comp", "compression/ecnryption method", print_comp); - cli_show_ses_register("rx-bytes", "received bytes", print_rx_bytes); - cli_show_ses_register("tx-bytes", "transmitted bytes", print_tx_bytes); + cli_show_ses_register("rx-bytes", "received bytes (human readable)", print_rx_bytes); + cli_show_ses_register("tx-bytes", "transmitted bytes (human readable)", print_tx_bytes); + cli_show_ses_register("rx-bytes-raw", "received bytes", print_rx_bytes_raw); + cli_show_ses_register("tx-bytes-raw", "transmitted bytes", print_tx_bytes_raw); cli_show_ses_register("rx-pkts", "received packets", print_rx_pkts); cli_show_ses_register("tx-pkts", "transmitted packets", print_tx_pkts); -- cgit v1.2.3