From 4cd2956f18470e4eda7f884a291016c9a5dd5724 Mon Sep 17 00:00:00 2001 From: "s0wlz (Matthias Puchstein)" Date: Wed, 22 Apr 2026 01:20:42 +0200 Subject: [PATCH] fix: k8s-metrics exit code and CPU label format --- .../quickshell/scripts/executable_k8s-metrics.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/dot_config/quickshell/scripts/executable_k8s-metrics.sh b/dot_config/quickshell/scripts/executable_k8s-metrics.sh index 6a7187f..24ffe88 100644 --- a/dot_config/quickshell/scripts/executable_k8s-metrics.sh +++ b/dot_config/quickshell/scripts/executable_k8s-metrics.sh @@ -35,14 +35,10 @@ normalize_mem() { fi } -# Format millicores for display ("420m" or "1.5c") +# Format millicores for display (always "Xm") fmt_cpu() { local m="$1" - if [[ $m -lt 1000 ]]; then - echo "${m}m" - else - awk "BEGIN { printf \"%.1fc\", $m / 1000 }" - fi + echo "${m}m" } # Format MiB for display ("343Mi" or "1.50Gi") @@ -57,9 +53,9 @@ fmt_mem() { # ── Fetch data ─────────────────────────────────────────────────────────────── -pods_json=$(kubectl get pods -n "$NS" -o json 2>/dev/null) || exit 0 +pods_json=$(kubectl get pods -n "$NS" -o json 2>/dev/null) || exit 1 top_output=$(kubectl top pods -n "$NS" --no-headers 2>/dev/null) || top_output="" -quota_json=$(kubectl get resourcequota -n "$NS" -o json 2>/dev/null) || exit 0 +quota_json=$(kubectl get resourcequota -n "$NS" -o json 2>/dev/null) || exit 1 # ── Build podName → app map ──────────────────────────────────────────────────