#include "unit-def.h"
#include "unit.h"
#include "varlink-metrics.h"
+#include "version.h"
static int active_timestamp_build_json(const MetricFamily *mf, sd_varlink *vl, void *userdata) {
Manager *manager = ASSERT_PTR(userdata);
return 0;
}
+static int version_build_json(const MetricFamily *mf, sd_varlink *vl, void *userdata) {
+ assert(mf && mf->name);
+ assert(vl);
+
+ return metric_build_send_string(
+ mf,
+ vl,
+ /* object= */ NULL,
+ GIT_VERSION,
+ /* fields= */ NULL);
+}
+
static int state_change_timestamp_build_json(const MetricFamily *mf, sd_varlink *vl, void *userdata) {
Manager *manager = ASSERT_PTR(userdata);
Unit *unit;
.type = METRIC_FAMILY_TYPE_GAUGE,
.generate = units_total_build_json,
},
+ {
+ .name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "Version",
+ .description = "Version of systemd",
+ .type = METRIC_FAMILY_TYPE_STRING,
+ .generate = version_build_json,
+ },
{}
};
swap_expected=$(( $(awk '/^SwapTotal:/ { print $2; found=1 } END { if (!found) print 0 }' /proc/meminfo) * 1024 ))
[ "$swap_reported" = "$swap_expected" ]
+# io.systemd.Manager.Version should be non-empty and match what `systemctl --version` reports
+metrics_version="$(varlinkctl call --more /run/systemd/report/io.systemd.Manager io.systemd.Metrics.List {} | jq --seq -r 'select(.name == "io.systemd.Manager.Version") | .value')"
+[ -n "$metrics_version" ]
+systemctl --version | grep -F "($metrics_version)" >/dev/null
+
# test io.systemd.Basic.MachineInfo.* metrics, sourced from /etc/machine-info
if [ -e /etc/machine-info ]; then
MACHINE_INFO_BACKUP="$(mktemp)"