1、自定义监控项
在zabbix server端这里面创建一个监控项
cd /etc/zabbix/zabbix_agentd.d# vi domain_check.confUserParameter=https.remaining[*],/etc/zabbix/scripts/domain_check.sh $1
2、编写脚本
mkdir -p /etc/zabbix/scripts# vi domain_check.sh#/bin/bashhost=$1port=443end_date=`openssl s_client -host $host -port $port -showcerts /dev/null | sed -n '/BEGIN CERTIFICATE/,/END CERT/p' | openssl x509 -text 2>/dev/null | sed -n 's/ *Not After : *//p'`if [ -n "$end_date" ]then end_date_seconds=`date '+%s' --date "$end_date"` # date指令format字符串时间。 now_seconds=`date '+%s'` echo "($end_date_seconds-$now_seconds)/24/3600" | bcfi
3、重启zabbix_agent
systemctl restart zabbix-agent
4、zabbi