Scripts, Zabbix userparameters, and Zabbix templates for monitoring SSL certificate expiration from Zabbix.
The included python script uses openssl
to discover SSL certificates on a host and add Zabbix items to monitor certificate expiry.
Templates were built against Zabbix 3.0.
Two Zabbix templates are included in templates/
for two different approaches: externalscripts
or agent
(Zabbix agent). Both cases expect Python and Zabbix sender to be installed.
Zabbix server or Zabbix proxy runs the checks via pollers.
-
Install
scripts/ssl_cert.py
to theexternalscripts
directory$ cp scripts/ssl_cert.py /usr/lib/zabbix/externalscripts/
ExternalScripts
is a configuration option inzabbix_server.conf
andzabbix_proxy.conf
, so check there first to see where your directory is. On a default install on Ubuntu via repos.zabbix.com I found myzabbix_server.conf
was configured toExternalScripts=/usr/lib/zabbix/externalscripts
. -
Import template
templates/template_ssl_cert_externalscripts.xml
in the Zabbix server UI.This will create
Template SSL Cert - externalscripts
in theTemplates
group of the Zabbix server. -
Create a hostname representing the host you want to monitor SSL certs for. For example
github.com
.By default the template passes the
{HOST.NAME}
macro into the script. This will be the target of the SSL certificate discovery and monitoring.
Zabbix agent runs the checks.
NOTE: Zabbix agent can run checks against localhost
and/or remote hosts
-
Install
scripts/ssl_cert.py
to the/etc/zabbix/scripts/
directory on the host where the Zabbix agent is running. -
Install
zabbix_agentd.d/userparameter_ssl_cert.conf
to the userparameters directory on the host where the Zabbix agent is running.Default is
/etc/zabbix/zabbix_agentd.d/
. -
Restart
zabbix-agent
service to load the new UserParameter. -
Import template
templates/template_ssl_cert_agent.xml
in the Zabbix server UI.This will create
Template SSL Cert - agent
in theTemplates
group of the Zabbix server. -
Apply the template to monitor SSL certificates.
The agent will run the script, but by default it will still target the
{HOST.NAME}
macro. If you wanted apply the template many hosts and have them monitor SSL certificates onlocalhost
, theRun SSL certificate checks
item in the template can be updated to look like this:ssl_cert.run_checks[localhost,443,10]
-
In cases where one IP/server serves many hostnames (i.e. using nginx for SSL termination of multiple hostnames), only the default SSL Certificate will be returned. The script
ssl_cert.py
can target by servername if theRun SSL certificate checks
in theexternalscripts
version is updated:ssl_cert.py["--port","443","--timeout","10","--servername","{HOST.NAME}"]
This still requires individually adding each host in Zabbix, however.
A Vagrantfile
has been included that will create a Zabbix 3.0 server VM and provide an example configuration of these monitoring templates.
-
Install VirtualBox
-
Install Vagrant
-
Change directory to
test/
and bring the Vagrant VM up$ cd test/ $ vagrant up
-
Browse to http://localhost:8080/zabbix
User: Admin Pass: zabbix
Two hosts will be created:
github.com
(example of externalscripts template) andgoogle.com
(example of agent template). SSL certificates will be discovered and added as items on these hosts.