1、准备好验证SSL的脚本
cat /etc/zabbix/script/ssl_check.sh
#!/bin/bash
#获取证书的有效时间
time=$(echo | openssl s_client -connect $1:443 2>/dev/null | openssl x509 -noout -dates |awk -F'=' 'NR==2{print $2}')
#有效时间的时间戳
time1=$(date +%s -d "$time")
#当前时间的时间戳
time2=$(date +%s)
#当前时间减去有效时间,获得将要过期的天数
time3=$(((time1-time2)/(60*60*24)))
echo $time3
2、将脚本设置为可执行权限。视zabbix用户组而定,这里
chmod 777 /etc/zabbix/script/ssl_check.sh
3、添加zabbix配置文件
cat /etc/zabbix/zabbix_agentd.d/ssl_check.conf
UserParameter=ssl_check[*],/etc/zabbix/script/ssl_check.sh $1
4、重启agent服务 systemctl restart zabbix-agent
5、服务端测试是否有数据,此处以度娘为例
zabbix_get -s 192.168.1.22 -p 10050 -k ssl_check[www.baidu.com]
6、web页面上在指定主机上添加监控项,更新周期可以设置大点,比如8小时,一天等
7、 web页面上在指定主机上添加触发器,
8、大功告成