Pages

Subscribe:

Monday, August 24, 2015

Script to Monitor the Website Availability

With Bash scripting you can monitor the Availability of a Website in your environment.

In order to achieve this without any third party monitoring tool you can simply create a script which can check the URL status code and if that changes it can simply send an email to you with the latest status code in the email body after which you can troubleshoot the same.


For checking the URL periodically over a specified period of time you need to enter the script in the crontab entry with period like every 5 minutes or as per your need.

The below script will send you a mail whenever the www.xyz.com has any status other than 302

 #!/bin/bash  
status=`curl -I https://www.xyz.com 2>|/dev/null | grep HTTP/1.1 | awk '{print $2}'`  
if [ $status = 200 ]  
then  
echo "The domain is working fine "  
else  
echo "The domain is having some problem, last status was $status" | mail -s "Error on the Domain" [email protected]  
fi

1 comments:

  1. Copiare i vestiti Moncler sono molto belli e molto temperati.repliche moncler Mi piace molto questo abito Moncler replica. Il servizio del negozio è molto buono,replica moncler uomo gilet polos la qualità dei vestiti è molto buona e il prezzo è molto buono, penso di essere molto economico ed economico.

    ReplyDelete