]>
Commit | Line | Data |
---|---|---|
4b87e256 MM |
1 | /* |
2 | * BIRD Internet Routing Daemon -- CLI Commands Which Don't Fit Anywhere Else | |
3 | * | |
4 | * (c) 2000 Martin Mares <mj@ucw.cz> | |
5 | * | |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | #include "nest/bird.h" | |
0c791f87 | 10 | #include "nest/protocol.h" |
0f808c06 | 11 | #include "nest/route.h" |
4b87e256 MM |
12 | #include "nest/cli.h" |
13 | #include "conf/conf.h" | |
14 | #include "nest/cmds.h" | |
15 | #include "lib/string.h" | |
acb60628 | 16 | #include "lib/resource.h" |
508d9360 | 17 | #include "filter/filter.h" |
4b87e256 | 18 | |
a92cf57d OZ |
19 | extern int shutting_down; |
20 | extern int configuring; | |
21 | ||
4b87e256 MM |
22 | void |
23 | cmd_show_status(void) | |
24 | { | |
43270902 MM |
25 | byte tim[TM_DATETIME_BUFFER_SIZE]; |
26 | ||
27 | cli_msg(-1000, "BIRD " BIRD_VERSION); | |
f047271c | 28 | tm_format_time(tim, &config->tf_base, current_time()); |
2f6483cd | 29 | cli_msg(-1011, "Router ID is %R", config->router_id); |
71423871 | 30 | cli_msg(-1011, "Hostname is %s", config->hostname); |
43270902 | 31 | cli_msg(-1011, "Current server time is %s", tim); |
f047271c | 32 | tm_format_time(tim, &config->tf_base, boot_time); |
43270902 | 33 | cli_msg(-1011, "Last reboot on %s", tim); |
f047271c | 34 | tm_format_time(tim, &config->tf_base, config->load_time); |
43270902 | 35 | cli_msg(-1011, "Last reconfiguration on %s", tim); |
a92cf57d | 36 | |
0c791f87 OZ |
37 | graceful_restart_show_status(); |
38 | ||
43270902 MM |
39 | if (shutting_down) |
40 | cli_msg(13, "Shutdown in progress"); | |
a92cf57d | 41 | else if (configuring) |
43270902 MM |
42 | cli_msg(13, "Reconfiguration in progress"); |
43 | else | |
44 | cli_msg(13, "Daemon is up and running"); | |
4b87e256 MM |
45 | } |
46 | ||
47 | void | |
0f808c06 | 48 | cmd_show_symbols(struct sym_show_data *sd) |
4b87e256 | 49 | { |
b7761af3 OZ |
50 | if (sd->sym) |
51 | cli_msg(1010, "%-8s\t%s", sd->sym->name, cf_symbol_class_name(sd->sym)); | |
4b87e256 | 52 | else |
b7761af3 OZ |
53 | { |
54 | HASH_WALK(config->sym_hash, next, sym) | |
4b87e256 | 55 | { |
b7761af3 OZ |
56 | if (!sym->scope->active) |
57 | continue; | |
58 | ||
59 | if (sd->type && (sym->class != sd->type)) | |
60 | continue; | |
61 | ||
62 | cli_msg(-1010, "%-8s\t%s", sym->name, cf_symbol_class_name(sym)); | |
4b87e256 | 63 | } |
b7761af3 OZ |
64 | HASH_WALK_END; |
65 | ||
66 | cli_msg(0, ""); | |
67 | } | |
4b87e256 | 68 | } |
acb60628 OZ |
69 | |
70 | static void | |
71 | print_size(char *dsc, size_t val) | |
72 | { | |
73 | char *px = " kMG"; | |
74 | int i = 0; | |
75 | while ((val >= 10000) && (i < 3)) | |
76 | { | |
77 | val = (val + 512) / 1024; | |
78 | i++; | |
79 | } | |
80 | ||
81 | cli_msg(-1018, "%-17s %4u %cB", dsc, (unsigned) val, px[i]); | |
82 | } | |
83 | ||
84 | extern pool *rt_table_pool; | |
85 | extern pool *rta_pool; | |
acb60628 OZ |
86 | |
87 | void | |
88 | cmd_show_memory(void) | |
89 | { | |
90 | cli_msg(-1018, "BIRD memory usage"); | |
91 | print_size("Routing tables:", rmemsize(rt_table_pool)); | |
92 | print_size("Route attributes:", rmemsize(rta_pool)); | |
93 | print_size("Protocols:", rmemsize(proto_pool)); | |
94 | print_size("Total:", rmemsize(&root_pool)); | |
95 | cli_msg(0, ""); | |
96 | } | |
508d9360 | 97 | |
508d9360 | 98 | void |
4c553c5a | 99 | cmd_eval(const struct f_line *expr) |
508d9360 | 100 | { |
52893045 MM |
101 | buffer buf; |
102 | LOG_BUFFER_INIT(buf); | |
103 | ||
104 | if (f_eval_buf(expr, this_cli->parser_pool, &buf) > F_RETURN) | |
508d9360 OZ |
105 | { |
106 | cli_msg(8008, "runtime error"); | |
107 | return; | |
108 | } | |
109 | ||
0e175f9f | 110 | cli_msg(23, "%s", buf.start); |
508d9360 | 111 | } |