Skip to content

Commit 6c93e9d

Browse files
committed
add helper script to extract timestamps from files
This is a pretty simple tool, but we've found this useful to check some diagnostics. We've also found alternatives like: https://github.com/Puppet-Finland/prometheus-file-age-metrics/blob/main/create-file-age-metrics.sh ... which gives you a metric like "out of date files", which didn't like, because the threshold lives in the script instead of the alerting layer (which we prefer). The closest thing to this is the filestat exporter: https://github.com/michael-doubez/filestat_exporter ... which provides way more metrics and seems overengineered for our purpose. Signed-off-by: Antoine Beaupré <[email protected]>
1 parent a2b43e1 commit 6c93e9d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

path-timestamp.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
# Expose timestamp of given path
4+
#
5+
# Usage: add this to crontab:
6+
#
7+
# */5 * * * * prometheus path-timestamp.sh /var/lib/prometheus | sponge /var/lib/node_exporter/path-timestamp.prom
8+
#
9+
# Author: Antoine Beaupré <[email protected]>
10+
11+
echo "# HELP node_path_modification_timestamp_seconds Last change timestamp"
12+
echo "# TYPE node_path_modification_timestamp_seconds gauge"
13+
for path in "$@"; do
14+
printf 'node_path_modification_timestamp_seconds{path="%s"}' "$path"
15+
stat -c %Y "$path"
16+
done

0 commit comments

Comments
 (0)