summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2021-12-21 18:14:55 +0100
committerBenBE <BenBE@geshi.org>2022-08-09 22:05:21 +0200
commit423eff6267ca860fa70a5f222a660fc6e784dc92 (patch)
tree555f065ddf1bec9529311933ca81b7d9a1e50184
parentfc228246665ce925e5027e4d1ff27ee9160a5424 (diff)
linux/SystemdMeter: use warning for some states
Searching man systemd(1) for "is-system-running" we see these states: initializing starting running degraded maintenance stopping offline unknown Let's differentiate some more: green (ok) if state is "running", red (error) if the state is unknown to htop or "degraded", yellow (warning) for everything else (incl. "initializing", "starting", "maintenance" & "stopping").
-rw-r--r--linux/SystemdMeter.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/linux/SystemdMeter.c b/linux/SystemdMeter.c
index 53ae2d28..cee32318 100644
--- a/linux/SystemdMeter.c
+++ b/linux/SystemdMeter.c
@@ -310,8 +310,12 @@ static int valueDigitColor(unsigned int value) {
static void SystemdMeter_display(ATTR_UNUSED const Object* cast, RichString* out) {
char buffer[16];
int len;
+ int color = METER_VALUE_ERROR;
- int color = (systemState && String_eq(systemState, "running")) ? METER_VALUE_OK : METER_VALUE_ERROR;
+ if (systemState) {
+ color = String_eq(systemState, "running") ? METER_VALUE_OK :
+ String_eq(systemState, "degraded") ? METER_VALUE_ERROR : METER_VALUE_WARN;
+ }
RichString_writeAscii(out, CRT_colors[color], systemState ? systemState : "N/A");
RichString_appendAscii(out, CRT_colors[METER_TEXT], " (");

© 2014-2024 Faster IT GmbH | imprint | privacy policy