Home/Server & Website Managed Operations/Monitoring SSL Certificate Expiry with Zabbix
Server & Website Managed Operations

Monitoring SSL Certificate Expiry with Zabbix

WatchSSLExpiryData

Google announced on December 18, 2015, that it would prioritize indexing HTTPS pages. When running HTTP sites or applications, SSL certificates are indispensable. This article introduces how to monitor SSL certificate validity periods using Zabbix.

(1) Verify the ExternalScripts Parameter Configuration

### Option: ExternalScripts
#       Full path to location of external scripts.
#       Default depends on compilation options.
#
# Mandatory: no
# Default:
# ExternalScripts=${datadir}/zabbix/externalscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

If this directory does not exist, create it using the mkdir command.

# mkdir -p /usr/lib/zabbix/externalscripts

(2) Create ssl-cert-check.sh

In the /usr/lib/zabbix/externalscripts directory, create the ssl-cert-check.sh file with the following content.

#!/bin/sh
 
SERVER=$1
PORT=$2
TIMEOUT=25
 
PATH=/bin:/usr/bin; export PATH
basedir=`dirname $0`

$basedir/timeout $TIMEOUT $basedir/ssl-cert-check -s $SERVER -p $PORT -n | sed 's/  */ /g' | cut -f6 -d" " | sed 's/^.*=//g'

The execution of ssl-cert-check.sh requires the timeout and ssl-cert-check files. Download them using the wget command.

# cd /usr/lib/zabbix/externalscripts
# wget http://www.pixelbeat.org/scripts/timeout
# wget http://prefetch.net/code/ssl-cert-check
# chmod 755 *

(3) Execute the ssl-cert-check.sh Script to View Results

Check how many days remain until the SSL certificate for www.yunwei123.com expires.

# cd /usr/lib/zabbix/externalscripts/
# ./ssl-cert-check.sh www.yunwei123.com 443
361

There are 361 days remaining. After confirming that the script execution results are correct, proceed to configure Zabbix.

(4) Configure Zabbix

Create Host

After logging into the Zabbix management page, navigate to “Configuration” -> “Hosts” -> “Create host”.

HostDetail-600x505

  • Host name: www.yunwei123.com
  • Visible name: www.yunwei123.com
  • Groups: Linux servers
  • Zabbix agent interfaces
    IP address: 120.26.41.73
    DNS name: www.yunwei123.com
    Port: 10050

Fill in the above information and click “Add”.

Create Item

On the page for the newly created host www.yunwei123.com, click “Items”.

ClickItem-600x195

Fill in the following content and click “Add”.

  • Name: Web SSL-Cert
  • Type: External check
  • Key: ssl-cert-check.sh[{HOST.DNS},”443″]
  • Units: Days
  • Update interval (seconds): 86400 (check once a day)

ItemDetail-600x578

For External check type, Zabbix 1.8 defaulted the first parameter to the hostname, but starting from the Zabbix 2 series, this parameter must be specified explicitly.

Create Trigger

Similar to creating an item, on the host page, click “Triggers” -> “Create trigger”, fill in the following content, and click “Add”.

  • Name: SSL Certification will to expiration {HOST.DNS}
  • Expression: {www.yunwei123.com:ssl-cert-check.sh[{HOST.DNS},”443″].last(0)}<31
  • Severity: Average

TriggerDetail-600x383

Create Graph

On the host (www.yunwei123.com) page, click “Graphs” -> “Create graph”.

Fill in “Name: SSL Certificate Expiry Date” and click “Add”.

GraphDetail-600x345

Check “Web SSL-Cert” -> “Select”.

GraphDetail01-600x79

Select function “Minimum” and click “Add”.

GraphDetail02-600x360

FREE CHECKUP

Free server checkup

We will send a problem checklist and remediation advice within one business day — no obligation to engage.

135 410 16684
Weekdays Mon – Fri 10:00 – 22:00 (UTC+8) · 7×24 emergency response
Call now
CONTACT

Contact Us

How can we help?

* Required