Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Nurlan199206/87e9a2c1236abf5fdb6ce397d4d09eb2 to your computer and use it in GitHub Desktop.
Save Nurlan199206/87e9a2c1236abf5fdb6ce397d4d09eb2 to your computer and use it in GitHub Desktop.
Кастомная метрика
#!/bin/bash
# Adjust as needed.
#https://www.robustperception.io/using-the-textfile-collector-from-a-shell-script
TEXTFILE_COLLECTOR_DIR=/var/lib/node_exporter/textfile_collector/
# Note the start time of the script.
# Your code goes here.
sleep 10
# Write out metrics to a temporary file.
END="$(cat /var/log/cron | wc -l)"
cat << EOF > "$TEXTFILE_COLLECTOR_DIR/test.prom.$$"
test $END
EOF
# Rename the temporary file atomically.
# This avoids the node exporter seeing half a file.
mv "$TEXTFILE_COLLECTOR_DIR/test.prom.$$" \
"$TEXTFILE_COLLECTOR_DIR/test.prom"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment