Closed fbocolowski closed 5 years ago
Would also love this.
Here's a code snippet for a bash doing this:
SERVERS=("https://google.com", "https://github.com")
for SERVER in ${SERVERS[@]}; do
CURL_RESULT=`curl -s -o /dev/null -w "%{http_code} %{time_total}" $SERVER`
CURL_CODE=`echo "$CURL_RESULT"| awk {'print $1'}`
CURL_TIME=`echo "$CURL_RESULT"| awk {'print $2'}`
echo " $SERVER $CURL_CODE $CURL_TIME"
if [ $CURL_CODE != "200" -a $CURL_CODE != "302" -a $CURL_CODE != "301" ]; then
echo " SERVER ERROR!"
slack "Error connecting to $SERVER!\nResult was $CURL_CODE"
else
echo " SERVER OK!"
fi
done
Allow option to make the server ping to multiple domains and return the result (OK or NOT OK).