监控脚本骨架
监控脚本骨架
for h in example.com api.example.com; do
end=$(echo | openssl s_client -servername $h -connect $h:443 2>/dev/null | openssl x509 -noout -enddate | cut -d= -f2)
days=$(( ( $(date -d "$end" +%s) - $(date +%s) ) / 86400 ))
echo "$h: ${days} days"
done
# 单文件检查:openssl x509 -in cert.pem -noout -checkend $((30*86400))监控要覆盖「所有入口」:LB、CDN、网关、内网 mTLS 证书各有各的到期日,别只盯主站。