运行起来无报错,结果也不显示
#!/bin/bash
resrttem=$(tput sgr0)
LOGFILE='/usr/local/apache2.4/logs/access.log'
Check_http_status()
{
http_status_codes=(`cat $LOGFILE|grep -ioE "HTTP\/1\.[0|1]\"[[:blank:]][0-9]{3}"|awk -F"[ ]+" '{
if($2>=100&&$2<200)
{i++}
else if($2>=200&&$2<300)
{j++}
else if($2>=300&&$2<400)
{k++}
else if($2>=400&&$2<500)
{l++}
else if($2>=500)
{n++}
}END{
print i?i:0,j?j:0,k?k:0,l?l:0,n?n:0,i+j+k+l+n
}'
`)
echo -e '\E[33m' "HTTP状态[100+] :" ${resrttem} ${http_status_codes[0]}
echo -e '\E[33m' "HTTP状态[200+] :" ${resrttem} ${http_status_codes[1]}
echo -e '\E[33m' "HTTP状态[300+] :" ${resrttem} ${http_status_codes[2]}
echo -e '\E[33m' "HTTP状态[400+] :" ${resrttem} ${http_status_codes[3]}
echo -e '\e[33m' "HTTP状态[500+] :" ${resrttem} ${http_status_codes[4]}
echo -e '\e[33m' "HTTP全部状态 :" ${resrttem} ${http_status_codes[5]}
}