#!/bin/bash # Recommended crontab: # * * * * * /path/to/collect-certdata.sh influx_host="{{ influx_host }}" influx_path="/api/v2/write" influx_org="{{ influx_org }}" influx_bucket="{{ influx_bucket }}" influx_token="{{ influx_token }}" influx_metric="certificate" domains=({% for dns in certificate_monitor_domains %}"{{dns}}" {% endfor %}) influx_url="${influx_host}${influx_path}?org=${influx_org}&bucket=${influx_bucket}" influx_header_auth="Authorization: Token ${influx_token}" influx_header_content="Content-Type: text/plain; charset=utf-8" influx_header_accept="Accept: application/json" for dn in ${domains[@]}; do certificate="$(openssl s_client -connect ${dn}:443 2>/dev/null