Browse Source

Make prom-collect generic

vault-wip
ansible_admin 1 year ago
parent
commit
506cf4382d
  1. 13
      ansible/roles/common/templates/prom-collect.j2
  2. 2
      ansible/roles/postgresql/templates/pg_backup.j2
  3. 2
      builds/daily/postgres-backups.yaml

13
ansible/roles/common/templates/prom-collect.j2

@ -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"

2
ansible/roles/postgresql/templates/pg_backup.j2

@ -5,4 +5,4 @@
cd /var/lib/postgresql
sudo -u postgres pg_dumpall | gzip -9 > "pgbackup.gz"
prom-collect postgresql_backup
prom-collect postgresql_backup_last_run_seconds $(date +%s)

2
builds/daily/postgres-backups.yaml

@ -26,5 +26,5 @@ tasks:
- metrics: |
for server in "${targets[@]}"
do
ssh "$server" prom-collect postgresql_offsite_backup
ssh "$server" prom-collect postgresql_offsite_backup_last_run_seconds $(date +%s)
done

Loading…
Cancel
Save