diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2018-11-30 17:56:42 +0100 |
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2018-12-06 23:05:45 +0100 |
| commit | af568444cba565370a978bdc61a43c024df913fd (patch) | |
| tree | 2738f123424c04ccfa229370e6390c734aa5d574 /watchfrr/watchfrr.c | |
| parent | 75f8b0e41b500b02675222515f3173c4effebdfe (diff) | |
watchfrr: add status command
Just to see WTF is going on inside watchfrr...
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'watchfrr/watchfrr.c')
| -rw-r--r-- | watchfrr/watchfrr.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c index 35a633b158..e28da6db8c 100644 --- a/watchfrr/watchfrr.c +++ b/watchfrr/watchfrr.c @@ -73,7 +73,7 @@ typedef enum { } restart_phase_t; static const char *phase_str[] = { - "None", + "Idle", "Startup", "Stop jobs running", "Waiting for other daemons to come down", @@ -970,6 +970,31 @@ bool check_all_up(void) return true; } +void watchfrr_status(struct vty *vty) +{ + struct daemon *dmn; + struct timeval delay; + + vty_out(vty, "watchfrr global phase: %s\n", phase_str[gs.phase]); + if (gs.restart.pid) + vty_out(vty, " global restart running, pid %ld\n", + (long)gs.restart.pid); + + for (dmn = gs.daemons; dmn; dmn = dmn->next) { + vty_out(vty, " %-20s %s\n", dmn->name, state_str[dmn->state]); + if (dmn->restart.pid) + vty_out(vty, " restart running, pid %ld\n", + (long)dmn->restart.pid); + else if (dmn->state == DAEMON_DOWN && + time_elapsed(&delay, &dmn->restart.time)->tv_sec + < dmn->restart.interval) + vty_out(vty, " restarting in %ld seconds" + " (%lds backoff interval)\n", + dmn->restart.interval - delay.tv_sec, + dmn->restart.interval); + } +} + static void sigint(void) { zlog_notice("Terminating on signal"); |
