Ignore changes in selected systemd units
This commit implements a possibility of ignoring changes in specified
systemd unit as proposed by [1]. This can be useful in cases where
some of the units are behaving badly (but not affecting the health
of a whole system).
Add a CLI option `--systemd-ignore-unit` to let user specify which units
should be ignored.
[1]: https://github.com/CESNET/velia/issues/1
Change-Id: I5902151b4ac95bdcd9aacf29c0189fb62537497f
diff --git a/src/main.cpp b/src/main.cpp
index b5e5a13..7261f36 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,6 +37,7 @@
Usage:
veliad
[--log-level=<Level>]
+ [--systemd-ignore-unit=<Unit>]...
veliad (-h | --help)
veliad --version
@@ -46,6 +47,7 @@
--log-level=<N> Log level for everything [default: 3]
(0 -> critical, 1 -> error, 2 -> warning, 3 -> info,
4 -> debug, 5 -> trace)
+ --systemd-ignore-unit=<Unit> Ignore state of systemd's unit in systemd state tracker. Can be specified multiple times.
)";
std::unique_ptr<sdbus::IConnection> g_dbusConnection;
@@ -93,8 +95,12 @@
spdlog::get("main")->debug("All outputs initialized.");
// input configuration
+ std::set<std::string> ignoredUnits(args["--systemd-ignore-unit"].asStringList().begin(), args["--systemd-ignore-unit"].asStringList().end());
spdlog::get("main")->debug("Starting DBus systemd watcher");
- auto inputSystemdDbus = std::make_shared<velia::DbusSystemdInput>(manager, *g_dbusConnection);
+ if (!ignoredUnits.empty()) {
+ spdlog::get("main")->debug("Systemd input will ignore changes of the following units: {}", args["--systemd-ignore-unit"]);
+ }
+ auto inputSystemdDbus = std::make_shared<velia::DbusSystemdInput>(manager, ignoredUnits, *g_dbusConnection);
spdlog::get("main")->debug("All inputs initialized.");