13 lines
424 B
Bash
13 lines
424 B
Bash
#!/bin/bash
|
|
|
|
rm -f /var/lib/prometheus/node-exporter/certs.prom
|
|
|
|
for f in /etc/certs/*; do
|
|
snapshot_timestamp=$(openssl x509 -noout -enddate -in $f/cert.pem | cut -d= -f2)
|
|
snapshot_secs=$(date --date "$snapshot_timestamp" +%s)
|
|
now=$(date +%s)
|
|
delta=$((snapshot_secs - now))
|
|
name=$(echo $f | cut -d/ -f4)
|
|
printf 'certificate_validity{label="%s"} %s\n' $name $delta >> /var/lib/prometheus/node-exporter/certs.prom
|
|
done
|