]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Made `show status' show uptime and time of last reconfiguration.
authorMartin Mares <mj@ucw.cz>
Sun, 12 Mar 2000 22:44:54 +0000 (22:44 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 12 Mar 2000 22:44:54 +0000 (22:44 +0000)
conf/conf.c
conf/conf.h
doc/reply_codes
nest/cmds.c

index 21413e50ed27f5e3fad7fd031c0d55a015bf4aba..a4e0363577df09c92856e66644cd7141a09b277d 100644 (file)
@@ -18,6 +18,7 @@
 #include "lib/resource.h"
 #include "lib/string.h"
 #include "lib/event.h"
+#include "lib/timer.h"
 #include "conf/conf.h"
 #include "filter/filter.h"
 
@@ -26,6 +27,7 @@ static jmp_buf conf_jmpbuf;
 struct config *config, *new_config, *old_config, *future_config;
 static event *config_event;
 int shutting_down;
+bird_clock_t boot_time;
 
 struct config *
 config_alloc(byte *name)
@@ -37,6 +39,9 @@ config_alloc(byte *name)
   c->pool = p;
   cfg_mem = c->mem = l;
   c->file_name = cfg_strdup(name);
+  c->load_time = now;
+  if (!boot_time)
+    boot_time = now;
   return c;
 }
 
index 78ab04a982579d04e57a614e387b76d8ed2e8a1b..5abca7dae7e1a87cff70ed042265446a10ec4b89 100644 (file)
@@ -10,6 +10,7 @@
 #define _BIRD_CONF_H_
 
 #include "lib/resource.h"
+#include "lib/timer.h"
 
 /* Configuration structure */
 
@@ -29,6 +30,7 @@ struct config {
   struct symbol **sym_fallback;                /* Lexer: fallback symbol hash table */
   int obstacle_count;                  /* Number of items blocking freeing of this config */
   int shutdown;                                /* This is a pseudo-config for daemon shutdown */
+  bird_clock_t load_time;              /* When we've got this configuration */
 };
 
 /* Please don't use these variables in protocols. Use proto_config->global instead. */
@@ -38,6 +40,7 @@ extern struct config *old_config;     /* Old configuration when reconfiguration is i
 extern struct config *future_config;   /* New config held here if recon requested during recon */
 
 extern int shutting_down;
+extern bird_clock_t boot_time;
 
 struct config *config_alloc(byte *name);
 int config_parse(struct config *);
index 711c6342ad0587d27b04e8d27aca096d487bdb79..140de95afaa6bee57dedf458905e505708f0f0ed 100644 (file)
@@ -21,6 +21,7 @@ Reply codes of BIRD command-line interface
 0010   Already enabled
 0011   Enabled
 0012   Restarted
+0013   Status report
 
 1000   BIRD version
 1001   Interface list
@@ -33,6 +34,7 @@ Reply codes of BIRD command-line interface
 1008   Route details
 1009   Static route list
 1010   Symbol list
+1011   Uptime
 
 8000   Reply too long
 8001   Route not found
index c4443f93ef75518b53403f3c187730bec42d29e4..ac537c88ec6a1feeed7d177ca1d451e78a0d43f2 100644 (file)
 void
 cmd_show_status(void)
 {
-  cli_msg(1000, "BIRD " BIRD_VERSION);
-  /* FIXME: Should include uptime, shutdown flag et cetera */
+  byte tim[TM_DATETIME_BUFFER_SIZE];
+
+  cli_msg(-1000, "BIRD " BIRD_VERSION);
+  tm_format_datetime(tim, now);
+  cli_msg(-1011, "Current server time is %s", tim);
+  tm_format_datetime(tim, boot_time);
+  cli_msg(-1011, "Last reboot on %s", tim);
+  tm_format_datetime(tim, config->load_time);
+  cli_msg(-1011, "Last reconfiguration on %s", tim);
+  if (shutting_down)
+    cli_msg(13, "Shutdown in progress");
+  else if (old_config)
+    cli_msg(13, "Reconfiguration in progress");
+  else
+    cli_msg(13, "Daemon is up and running");
 }
 
 void