satisfy shellcheck
[log-quiet] / sysd-prom-fail
index 20e7c9b588cf69c17ca57fda652232934a064b0c..d8a2c0a0d9f97c5976b6583d5c6cd04ba753f2f4 100755 (executable)
@@ -1,5 +1,12 @@
 #!/bin/bash
-# Copyright (C) 2022 Ian Kelling
+# I, Ian Kelling, follow the GNU license recommendations at
+# https://www.gnu.org/licenses/license-recommendations.en.html. They
+# recommend that small programs, < 300 lines, be licensed under the
+# Apache License 2.0. This file contains or is part of one or more small
+# programs. If a small program grows beyond 300 lines, I plan to switch
+# its license to GPL.
+
+# Copyright 2024 Ian Kelling
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+
+
+# requires 1.4.0 to run with multiple units due to bug before that:
+# https://github.com/prometheus/node_exporter/pull/2475
+
 set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
@@ -33,13 +45,7 @@ if [[ ! -e $dir  ]]; then
   exit 0
 fi
 
-# we have to merge files due to this:
-# https://github.com/prometheus/node_exporter/issues/1885
-# or else we could put the label in the metric name, but that
-# is a bad practice.
-# Note, i found this https://github.com/hansmi/prometheus-textformat-merge
-# but it seems overkill.
-f=$dir/${ser_name}-result-fail.premerge
+f=$dir/${ser_name}-result.prom
 ftmp=$f.$$
 
 
@@ -67,7 +73,3 @@ if $write_count; then
   printf 'node_systemd_unit_result_fail_count{name="%s"} %s\n' "$ser_name" "$count" >$ftmp
   mv $ftmp $f
 fi
-
-finaltmp=$dir/sysd-result-fail.prom.$$
-cat $dir/*-result-fail.premerge >$finaltmp
-mv $finaltmp $dir/sysd-result-fail.prom