Paillasse/ansible/roles/portail/templates/syllabus-expiration-certificat.sh.j2

15 lines
774 B
Text
Raw Normal View History

#!/bin/sh
# Géré par Ansible (rôle portail). Publie la date d'expiration du certificat
# HTTPS pour Prometheus (collecteur textfile de node_exporter) : alerte
# CertificatExpireBientot si le renouvellement automatique échoue.
set -eu
CERT=/etc/letsencrypt/live/{{ portail_domaine }}/fullchain.pem
DOSSIER=/var/lib/node_exporter/textfile
FIN=$(date -d "$(openssl x509 -enddate -noout -in "$CERT" | cut -d= -f2)" +%s)
cat > "$DOSSIER/certificat.prom.tmp" <<METRIQUE
# HELP syllabus_certificat_expiration_timestamp Date d'expiration du certificat HTTPS (secondes Unix).
# TYPE syllabus_certificat_expiration_timestamp gauge
syllabus_certificat_expiration_timestamp{domaine="{{ portail_domaine }}"} $FIN
METRIQUE
mv "$DOSSIER/certificat.prom.tmp" "$DOSSIER/certificat.prom"