aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/std-formats.c
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2021-11-09 18:18:21 +0100
committerDamjan Marion <dmarion@me.com>2021-12-14 10:41:34 +0000
commit162ff5e4122572045ea7976c77ba3286fb05eeb5 (patch)
treec418c979fed4382df9246fe005b90feba81e7e41 /src/vppinfra/std-formats.c
parent83b982be86c3f27f181fb65d4392b679488af0bc (diff)
interface: Add interface monitor cli
This adds an interface CLI 'monitor interface <interface>' that periodically reports rx/tx pps & bandwidth for a given interface. Type: feature Change-Id: Ia9d59b3443913520a52b38d7bda012190be6f167 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/vppinfra/std-formats.c')
-rw-r--r--src/vppinfra/std-formats.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/vppinfra/std-formats.c b/src/vppinfra/std-formats.c
index 1616001f9c5..1a150ead7bd 100644
--- a/src/vppinfra/std-formats.c
+++ b/src/vppinfra/std-formats.c
@@ -204,6 +204,24 @@ format_time_interval (u8 * s, va_list * args)
return s;
}
+/* Format base 10 e.g. 100, 100K, 100M, 100G */
+__clib_export u8 *
+format_base10 (u8 *s, va_list *va)
+{
+ uword size = va_arg (*va, uword);
+
+ if (size < 1000)
+ s = format (s, "%d", size);
+ else if (size < 1000000)
+ s = format (s, "%.2fK", (f64) size / 1000.);
+ else if (size < 1000000000)
+ s = format (s, "%.2fM", (f64) size / 1000000.);
+ else
+ s = format (s, "%.2fG", (f64) size / 1000000000.);
+
+ return s;
+}
+
/* Unparse memory size e.g. 100, 100k, 100m, 100g. */
__clib_export u8 *
format_memory_size (u8 * s, va_list * va)