脚本: [root@yz shell]# cat cert_check.sh #!/bin/sh ### SSL Certificate Expire Day Check Script ### if [ "$1" = '' ];then echo "Need URL." exit 1;fi TARGET_URL=$1 EXP_DAY=`openssl s_client -connect ${TARGET_URL}:443 < /dev/null 2> /dev/null | openssl x509 -text 2> /dev/null | grep "Not After" | sed -e 's/^ *//g' | cut -d " " -f 4,5,6,7,8` NOW_TIME=`date +%s` EXP_TIME=`date +%s -d "${EXP_DAY}"` if [ "${EXP_DAY}" != '' -a ${NOW_TIME} -lt ${EXP_TIME} ]; then echo $(((EXP_TIME-NOW_TIME)/(60*60*24))) else echo "ERROR" exit 1; fi [root@yz shell]# pwd /etc/zabbix/shell [root@yz shell]#
userparameter值 [root@yz zabbix_agentd.d]# cat cert_check.conf UserParameter=cert_check[*],bash /etc/zabbix/shell/cert_check.sh $1 [root@yz zabbix_agentd.d]# pwdf -bash: pwdf: 未找到命令 [root@yz zabbix_agentd.d]# pwd /etc/zabbix/zabbix_agentd.d [root@yz zabbix_agentd.d]#
zabbix创建模板触发器