#!/bin/sh
# ZeroBehind metrics for the textfile collector of node_exporter (read only).
# "zerobehind metrics" asks the local agent about its replication pairs (also
# the ones this node only observes) and the license. When the agent does not
# answer it prints zerobehind_up 0, so an alert sees a state, not missing data.
# Output: /var/lib/node_exporter/textfile/zerobehind.prom (atomic). Timer: 30 s.
DIR=/var/lib/node_exporter/textfile
TMP=$(mktemp "$DIR/.zerobehind.XXXXXX") || exit 1
/usr/local/bin/zerobehind metrics > "$TMP" 2>/dev/null
chmod 644 "$TMP"
mv "$TMP" "$DIR/zerobehind.prom"
