1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#/bin/bash html=/var/www/servers_state.html while true; do echo "<br><br><br>" > $html echo '<center><table width="40%" border="1" cellspacing="0" cellpadding="5" >' >> $html echo "<tr><td></td><td><b>HOST</b></td><td><b>State</b></td></tr>" >> $html i=1 serverlist=(website1.com website2.com website3.com website4.com website4.com) for web in "${serverlist[@]}";do state=$(HEAD -t 8 $web |sed -n 1p) echo "<tr><td>$i</td><td>$ip</td><td>$state</td></tr>" >> $html if [ "$state" != "200 OK" ] then echo "Something is wrong with $ip" |mail -s "Invalid responce from $web" \ yourmail@domain.com fi let "i = $i +1" done echo "</table>" >> $html echo "<br>" >> $html echo "<p>Last updated at $(date +%H:%M:%S)</p>" >> $html echo "</center>" >> $html sleep 30 done |