Skip to content

Commit

Permalink
fix: prevent metrics file to grow by replacing old values
Browse files Browse the repository at this point in the history
Signed-off-by: Zadkiel Aharonian <[email protected]>
  • Loading branch information
aslafy-z committed Aug 3, 2023
1 parent e401c32 commit e142f5b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions buffer-size.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh

while true; do

echo "# HELP node_buffer_size_bytes Disk space used" > /prometheus/node_exporter/textfile_collector/buffer_size.prom
echo "# TYPE node_buffer_size_bytes gauge" >> /prometheus/node_exporter/textfile_collector/buffer_size.prom

[ -z "$BUFFER_PATH" ] && BUFFER_PATH=/buffers
du -ab ${BUFFER_PATH} | sed -ne 's/\\/\\\\/;s/"/\\"/g;s/^\([0-9]\+\)\t\(.*\)$/node_buffer_size_bytes{entity="\2"} \1/p' >> /prometheus/node_exporter/textfile_collector/buffer_size.prom

sleep 60
while true; do
echo "# HELP node_buffer_size_bytes Disk space used" > /prometheus/node_exporter/textfile_collector/buffer_size.prom
echo "# TYPE node_buffer_size_bytes gauge" >> /prometheus/node_exporter/textfile_collector/buffer_size.prom
du -ab ${BUFFER_PATH} | sed -ne 's/\\/\\\\/;s/"/\\"/g;s/^\([0-9]\+\)\t\(.*\)$/node_buffer_size_bytes{entity="\2"} \1/p' >> /prometheus/node_exporter/textfile_collector/buffer_size.prom.$$
mv /prometheus/node_exporter/textfile_collector/buffer_size.prom.$$ /prometheus/node_exporter/textfile_collector/buffer_size.prom

sleep 60
done

0 comments on commit e142f5b

Please sign in to comment.