#!/bin/sh
#This script is created by ssparser automatically. The parser first created by MaoShouyan
printf "Content-type: text/html
Cache-Control: no-cache

"
echo -n "";
. ../common/common.sh
myself="/cgi-bin/Monitor/`basename $0`"
afm_load_page 30 "${myself}"

echo -n "
<body>
"; 
cgi_show_title "ϵͳſ->½"
floweyearg="width=800 height=300 tag=flow.newrate tag=flow.delrate yname=flows/s"
oneday=`expr 3600 \* 24`
endtm=`date +%s`
errmsg=`${FLOWEYE} chart show ${floweyearg} outimg=${TMPPATH}/flowrate_day.png hours=24`
endtm=`expr ${endtm} - ${oneday}`
errmsg=`${FLOWEYE} chart show ${floweyearg} outimg=${TMPPATH}/flowrate_week.png tmend=${endtm} hours=168`
endtm=`expr ${endtm} - ${oneday}`
errmsg=`${FLOWEYE} chart show ${floweyearg} outimg=${TMPPATH}/flowrate_month.png tmend=${endtm} hours=720`

echo -n "
<br>
";
newrate=""
delrate=""
for rate in `${FLOWEYE} flow stat | grep rate | cut -d '=' -f2 | cut -d'/' -f1`
do
	if [ "${newrate}" = "" ]; then
		newrate="${rate}"
	else
		delrate="${rate}"
	fi
	[ "${newrate}" != "" -a "${delrate}" != "" ] && break
done

echo -n "
<table width=800 border=0 cellspacing=1 cellpadding=1> 
<tr id=tblhdr height=22>
	<td width=200 align=center>ǰ½</td>
	<td width=200 align=center>${newrate}/</td>
	<td width=200 align=center>ǰɾ</td>
	<td width=* align=center>${delrate}/</td>
</tr> 
</table>
<br>
<table style=\"width:800; font:bold  14px; color:#CE6C04\">
<tr><td style=\"font:14px\"><b>1ͼ</b></td></tr>
</table>
<table width=\"700\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"#ffffff\">
<tr><td><img src=\"/tmp/flowrate_day.png\"></img></td></tr>
</table>
<br>
<table style=\"width:800; font:bold  14px; color:#CE6C04\">
<tr><td style=\"font:14px\"><b>1ͼ</b></td></tr>
</table>
<table width=\"700\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"#ffffff\">
<tr><td><img src=\"/tmp/flowrate_week.png\"></img></td></tr>
</table>
<br>
<table style=\"width:800; font:bold  14px; color:#CE6C04\">
<tr><td style=\"font:14px\"><b>1ͼ</b></td></tr>
</table>
<table width=\"800\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"#ffffff\">
<tr><td><img src=\"/tmp/flowrate_month.png\"></img></td></tr>
</table>
</body>
</html>
";