diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2010-06-02 22:20:40 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2010-06-02 22:20:40 +0200 |
commit | acb60628f53ba1fc29d1a554683acdb03f961c6f (patch) | |
tree | be767e6d7995dee6708b7530b7dabe74d23b491e /nest/cmds.c | |
parent | 4461b8979143bd13024663622c419646a1db0c85 (diff) |
Implements command that shows memory usage.
Diffstat (limited to 'nest/cmds.c')
-rw-r--r-- | nest/cmds.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/nest/cmds.c b/nest/cmds.c index 16fbba61..8ac32096 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, ""); +} |