This template allows you to turn web monitoring steps from Zabbix into an LLD to also monitor them for certificate expiration. It requires two PHP files, two UserParameters, an SQL user with SELECT permissions and this template to get up and running.
- PHP 7.x + mysqli module
- SQL user with SELECT permissions (do not use root please)
- Some changes to zabbix_agentd.conf
- Run the following command:
mkdir /etc/zabbix/scripts && git clone https://github.com/albinbatman/zabbix-ssl-monitor-template /etc/zabbix/scripts
cd /etc/zabbix/scripts/zabbix-ssl-monitor-template
- Open up SQL.php and adjust the following lines
private $host = "dns or ip to database";
private $user = "your username for sql";
private $pass = "your user sql password";
private $db = "zabbix";
private $table = "httptest"; // keep this as it is
- Edit zabbix_agentd.conf with the following:
UserParameter=get.urls,php /etc/zabbix/scripts/zabbix-ssl-monitor-template/scripts/SQL.php
UserParameter=get.ssl[*],php /etc/zabbix/scripts/zabbix-ssl-monitor-template/scripts/SSL.php $1
- I recommend creating a new host with a Zabbix agent (e.g Zabbix server).
- Add template Template Web SSL Certificate Monitor to host from above.
- Add a new web scenario (name must be a valid full URL, like https://example.com)
- SQL.php only sends back URLs with https:// in it to the template.
- Enjoy!
Since the items will go into unsupported state if an error with the script occurs (such as can't verify certificate), please follow this documentation to setup alerting for it: Receiving notification on unsupported items [Zabbix Documentation 5.0]
Another tip is to only use this template once per database, ie do not use this template on two hosts that have access to the same database because it will create duplicates.