From b3ee8bcc615d6b51214f37b1e48f92965812d63e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 3 Oct 2019 21:09:28 -0400 Subject: lib, watchfrr: Add some additional status messages to systemd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow systemd to be informed about operational state so operators can infer a bit about what is going on with FRR from the systemd status cli. sharpd@robot ~/frr4> systemctl status frr ● frr.service - FRRouting Loaded: loaded (/usr/lib/systemd/system/frr.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2019-10-03 21:09:04 EDT; 7s ago Docs: https://frrouting.readthedocs.io/en/latest/setup.html Process: 32455 ExecStart=/usr/lib/frr/frrinit.sh start (code=exited, status=0/SUCCESS) Status: "FRR Operational" Tasks: 12 (limit: 4915) Memory: 76.5M CGroup: /system.slice/frr.service ├─32468 /usr/lib/frr/watchfrr -d zebra bgpd staticd ├─32487 /usr/lib/frr/zebra -d -A 127.0.0.1 -s 90000000 ├─32492 /usr/lib/frr/bgpd -d -A 127.0.0.1 └─32500 /usr/lib/frr/staticd -d -A 127.0.0.1 Please note the `Status: ...` line above. Signed-off-by: Donald Sharp --- lib/systemd.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/systemd.c') diff --git a/lib/systemd.c b/lib/systemd.c index 8a2a5eeac3..44db48d006 100644 --- a/lib/systemd.c +++ b/lib/systemd.c @@ -86,6 +86,7 @@ static int systemd_get_watchdog_time(int the_process) void systemd_send_stopping(void) { + systemd_send_information("STATUS="); systemd_send_information("STOPPING=1"); } @@ -116,3 +117,11 @@ void systemd_send_started(struct thread_master *m, int the_process) if (wsecs != 0) thread_add_timer(m, systemd_send_watchdog, m, wsecs, NULL); } + +void systemd_send_status(const char *status) +{ + char buffer[1024]; + + snprintf(buffer, sizeof(buffer), "STATUS=%s", status); + systemd_send_information(buffer); +} -- cgit v1.2.3