summaryrefslogtreecommitdiffstats
path: root/nest/cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'nest/cmds.c')
-rw-r--r--nest/cmds.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/nest/cmds.c b/nest/cmds.c
index 16fbba6..8ac3209 100644
--- a/nest/cmds.c
+++ b/nest/cmds.c
@@ -11,6 +11,7 @@
#include "conf/conf.h"
#include "nest/cmds.h"
#include "lib/string.h"
+#include "lib/resource.h"
void
cmd_show_status(void)
@@ -47,3 +48,32 @@ cmd_show_symbols(struct symbol *sym)
cli_msg(0, "");
}
}
+
+static void
+print_size(char *dsc, size_t val)
+{
+ char *px = " kMG";
+ int i = 0;
+ while ((val >= 10000) && (i < 3))
+ {
+ val = (val + 512) / 1024;
+ i++;
+ }
+
+ cli_msg(-1018, "%-17s %4u %cB", dsc, (unsigned) val, px[i]);
+}
+
+extern pool *rt_table_pool;
+extern pool *rta_pool;
+extern pool *proto_pool;
+
+void
+cmd_show_memory(void)
+{
+ cli_msg(-1018, "BIRD memory usage");
+ print_size("Routing tables:", rmemsize(rt_table_pool));
+ print_size("Route attributes:", rmemsize(rta_pool));
+ print_size("Protocols:", rmemsize(proto_pool));
+ print_size("Total:", rmemsize(&root_pool));
+ cli_msg(0, "");
+}