# check site load speed
site=http://site.tld/
#how many miliseconds is bad site load time
badtime=2000
[email protected]
logfilename="site_speed_history"
curl -H 'Cache-Control: no-cache' --max-time 30 -s -w '\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nAppCon time:\t%{time_appconnect}\nRedirect time:\t%{time_redirect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' -o /dev/null "$site$suffix" 2>/dev/null|tail -n 1|awk '{print $3}'|sed 's|\.||g' >> time
timerefined="$(cat time|head -c 5|grep -o '[0-9]*'|sed 's/^0*//')"
echo "$timerefined" >> $logfilename
if [[ "$timerefined" -gt "$badtime" ]];then
echo "$site load took $timerefined miliseconds.
$(cat /tmp/nodewatch_stats|grep -E \"cpu|CPU|3400\")
$(ps auxf)
$(free -mt)
$(cat /proc/net/nf_conntrack)
$(netstat -tlnp)
Local connections:
$(netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head)
All server connections:
$(netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n)
HTTPD connections: netstat -anpt| grep http
$(netstat -anpt| grep httpd)
Sumary of http IPs connected:
$(netstat -alntp | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n)
Number of connections per port (consider disabling service on that port if under attack):
$(netstat -tuna | awk -F':+| +' 'NR>2{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n)
$(tail /var/log/lfd.log)
This is a script at $(hostname)"|mail -s "$site loading slow" $adminmail
else
echo "Load time $timerefined is below $badtime miliseconds. ok"
fi
rm time
Bookmarks