summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/systemd.c9
-rw-r--r--lib/systemd.h5
-rw-r--r--watchfrr/watchfrr.c12
3 files changed, 26 insertions, 0 deletions
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);
+}
diff --git a/lib/systemd.h b/lib/systemd.h
index 6e43df527d..1f730720ce 100644
--- a/lib/systemd.h
+++ b/lib/systemd.h
@@ -42,6 +42,11 @@ void systemd_send_stopping(void);
*/
void systemd_send_started(struct thread_master *master, int the_process);
+/*
+ * status - A status string to send to systemd
+ */
+void systemd_send_status(const char *status);
+
#ifdef __cplusplus
}
#endif
diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c
index a6a910a1db..ea59655824 100644
--- a/watchfrr/watchfrr.c
+++ b/watchfrr/watchfrr.c
@@ -460,12 +460,20 @@ static int run_job(struct restart_info *restart, const char *cmdtype,
return -1;
}
+#if defined HAVE_SYSTEMD
+ char buffer[512];
+
+ snprintf(buffer, sizeof(buffer), "restarting %s", restart->name);
+ systemd_send_status(buffer);
+#endif
+
/* Note: time_elapsed test must come before the force test, since we
need
to make sure that delay is initialized for use below in updating the
restart interval. */
if ((time_elapsed(&delay, &restart->time)->tv_sec < restart->interval)
&& !force) {
+
if (gs.loglevel > LOG_DEBUG + 1)
zlog_debug(
"postponing %s %s: "
@@ -490,6 +498,9 @@ static int run_job(struct restart_info *restart, const char *cmdtype,
restart->pid = 0;
}
+#if defined HAVE_SYSTEMD
+ systemd_send_status("FRR Operational");
+#endif
/* Calculate the new restart interval. */
if (update_interval) {
if (delay.tv_sec > 2 * gs.max_restart_interval)
@@ -707,6 +718,7 @@ static void daemon_send_ready(int exitcode)
fclose(fp);
#if defined HAVE_SYSTEMD
systemd_send_started(master, 0);
+ systemd_send_status("FRR Operational");
#endif
sent = 1;
}