3 changed files with 7 additions and 10 deletions
@ -1,15 +1,12 @@
|
||||
#!/bin/sh |
||||
|
||||
metric="$1" |
||||
name="$1" |
||||
value="$2" |
||||
txtdir=/var/lib/prometheus/textfile_collector |
||||
time="$(date +%s)" |
||||
|
||||
cat << EOF > "$txtdir/$metric.prom.$$" |
||||
${metric}_last_run_seconds $time |
||||
EOF |
||||
printf "$name $value" > "$txtdir/$name.prom.$$" |
||||
|
||||
# Rename the temporary file atomically. |
||||
# This avoids the node exporter seeing half a file. |
||||
mv "$txtdir/$metric.prom.$$" \ |
||||
"$txtdir/$metric.prom" |
||||
|
||||
mv "$txtdir/$name.prom.$$" \ |
||||
"$txtdir/$name.prom" |
||||
|
Loading…
Reference in new issue