Wednesday, April 24, 2019

Site Down Checker using curl

Working in a support center we needed a simple site checker script that could be used to check for a site not being available. In this example, I'm using my favorite tool "cUrl"  The script can be modified to inspect what ever status.code that you are looking for. This  kinda of what a F5 LTM health monitor does btw

#!/bin/bash
#
#
D=`curl -k -o /dev/null -s  -w "response_code: %{http_code}\n"  https://platform.ringcentral.com/restapi/ | awk ' { print$2}'`


#echo $S

T=200


if [ $T =  $D ] ; then

    echo "Site is reachable"

else

    echo "Site is down"

fi

You should beable to add to this and even set expect response time if your making functional changes based on extended times.

example we are looking for status code 200 and  response time of  200ms or less could set the  time 

e.g

F=curl -k -o /dev/null -s  -w "response_code: %{time_total}\n"  https://platform.ringcentral.com/restapi/  | awk ' { print $2} ' | cut -d "." 


And do a comparison against the variable  to see if the value is less than 200ms





NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o
        /  \


No comments:

Post a Comment