forked from infra/ansible
OpenVPN: fix path to Zabbix agent config in cron
Signed-off-by: Greg Sutcliffe <fedora@emeraldreverie.org>
This commit is contained in:
parent
aaa5941e9f
commit
3d7a57e1b0
1 changed files with 20 additions and 0 deletions
20
roles/openvpn/client/templates/zabbix/cron-openvpn-cert.j2
Normal file
20
roles/openvpn/client/templates/zabbix/cron-openvpn-cert.j2
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/bash
|
||||
# A script to report days-left on the openvpn cert to zabbix
|
||||
|
||||
# Configuration
|
||||
CERT_FILE="/etc/openvpn/client/client.crt"
|
||||
|
||||
# Get certificate expiry
|
||||
EXPIRY=$(openssl x509 -in "$CERT_FILE" -noout -enddate | cut -d= -f2)
|
||||
|
||||
if [ -z "$EXPIRY" ]; then
|
||||
echo "problem reading $CERT_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Convert to epoch and calculate days remaining
|
||||
EXPIRY_EPOCH=$(date -d "$EXPIRY" +%s)
|
||||
NOW_EPOCH=$(date +%s)
|
||||
DAYS_LEFT=$(( ($EXPIRY_EPOCH - $NOW_EPOCH) / 86400 ))
|
||||
|
||||
/usr/bin/zabbix_sender -c {{ zabbix_agentd }} -k openvpn.cert_date -o "$DAYS_LEFT" > /dev/null
|
||||
Loading…
Add table
Add a link
Reference in a new issue