我有一个脚本,它基本上获取 http 响应代码。我想触发一封电子邮件以获取除 200 之外的任何响应代码。我不想使用脚本触发邮件。有没有办法在后期构建操作中发送邮件?
请协助。
#!/bin/bash
date
if [ $# -eq 0 ]; then
cat /home/ubuntu/check_kibana/lists.txt | while read output
do
RESP=$(curl -sL $output -w "%{http_code} \n" -o /dev/null)
if [ $RESP -eq 200 ]; then
echo "ResponseCode: $RESP, Service is active."
else
echo "ResponseCode: $RESP, $output is not active."
echo "ResponseCode: $RESP for $output. Please check as the service may be down or not listening to the designated port." | mail -s "Error triggered for unavailable kibana service" xxxxxxxxx@gmail.com
fi
done
fi