<!--#include file="conn.asp"-->
<!--#include file="../../checkdata.asp"-->
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../../images/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
if session("type")="admin" or session("type")="writesys" or session("type")="readsys" then
hutuitime=request("hutuitime")
if hutuitime<>"" then
time0=hutuitime
yselect=year(time0)
mselect=right("0"&month(time0),2)
else
yselect=request("yselect")
mselect=request("mselect")
if yselect="" or mselect="" then
time0=now() '显示记录的起始时间
yselect=year(time0)
mselect=right("0"&month(time0),2)
else
time0=yselect&"-"&mselect&"-"&"31 23:59:59"
end if
end if
interval=request("interval") '时间间隔
if interval="" then
interval=60
end if
dim array(59),array1(59)
dim mark,mark1
mark=0 '记录总连接数的最大值
mark1=0 '记录总流量的最大值
set rs=server.CreateObject("adodb.recordset")
for i=0 to 59
if i=0 then
time1=time0
time2=dateadd("s",-interval,time1)
else
time1=dateadd("s",-i*interval,time0)
time2=dateadd("s",-interval,time1)
end if
time1=replace(time1," ","|")
time1=changedata3(time1) '终止时间
time2=replace(time2," ","|")
time2=changedata3(time2) '起始时间
sql="select sysstatflowlog_tolcon,sysstatflowlog_tolrate,sysstatflowlog_starttime,sysstatflowlog_stoptime from tb_sysstatflowlog where sysstatflowlog_stoptime<='ts_"&time1&"'or sysstatflowlog_starttime>='ts_"&time2&"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
array(i)=0.0 '标记是否有记录
array1(i)=0.0 '标记是否有记录
else
while not rs.eof
rstime1=rs("sysstatflowlog_stoptime") '记录的终止时间
rstime2=rs("sysstatflowlog_starttime") '记录的起始时间
time1=right(time1,(len(time1)-3)) '去掉前面的前缀ts_
time2=right(time2,(len(time2)-3))
rstime1=right(rstime1,(len(rstime1)-3))
rstime2=right(rstime2,(len(rstime2)-3))
if rstime1<=time1 and rstime2>=time2 then '记录完全包含在时间段里,则可简单相加
array(i)=array(i)+right(rs("sysstatflowlog_tolcon"),(len(rs("sysstatflowlog_tolcon"))-3))*1
array1(i)=array1(i)+right(rs("sysstatflowlog_tolrate"),(len(rs("sysstatflowlog_tolrate"))-3))*1
elseif rstime1<time1 and rstime<time2 then '终止时间符合要求,但起始时间不符合
time2=replace(time2,"|"," ") '化成时间格式好记算时间差
rstime1=replace(rstime1,"|"," ")
rstime2=replace(rstime2,"|"," ")
v1=datediff("s",time2,rstime1)
v2=datediff("s",rstime2,rstime1)
v=v1/v2
array(i)=array(i)+right(rs("sysstatflowlog_tolcon"),(len(rs("sysstatflowlog_tolcon"))-3))*1*v
array1(i)=array1(i)+right(rs("sysstatflowlog_tolrate"),(len(rs("sysstatflowlog_tolrate"))-3))*1*v
elseif rstime1>time1 and rstime2>time2 then '终止时间不符合要求,但起始时间符合
time1=replace(time1,"|"," ")
rstime1=replace(rstime1,"|"," ")
rstime2=replace(rstime2,"|"," ")
v1=datediff("s",rstime2,time1)
v2=datediff("s",rstime2,rstime1)
v=v1/v2
array(i)=array(i)+right(rs("sysstatflowlog_tolcon"),(len(rs("sysstatflowlog_tolcon"))-3))*1*v
array1(i)=array1(i)+right(rs("sysstatflowlog_tolrate"),(len(rs("sysstatflowlog_tolrate"))-3))*1*v
elseif rstime2<time2 and rstime1>rstime1 then '记录集时间包含了要求时间段
time1=replace(time1,"|"," ")
time2=replace(time2,"|"," ")
rstime1=replace(rstime1,"|"," ")
rstime2=replace(rstime2,"|"," ")
v1=datediff("s",time2,time1)
v2=datediff("s",rstime2,rstime1)
v=v1/v2
array(i)=array(i)+right(rs("sysstatflowlog_tolcon"),(len(rs("sysstatflowlog_tolcon"))-3))*1*v
array1(i)=array1(i)+right(rs("sysstatflowlog_tolrate"),(len(rs("sysstatflowlog_tolrate"))-3))*1*v
end if
rs.movenext
wend
end if
'response.write array(i)
'response.end
if array(i)<>0.0 or array(i)<>0 then
array(i)=formatnumber(array(i),2) '连接数记录的统计值
end if
if array1(i)<>0.0 or array1(i)<>0 then
array1(i)=formatnumber(array1(i),2) '流量记录的统计值
end if
if array(i)>mark then
mark=array(i) '得到连接数的最大值
end if
if array1(i)>mark1 then
mark1=array1(i) '得到流量的最大值
end if
rs.close
next
set rs=nothing
set conn=nothing
if mark<>0 then
mark=formatnumber(mark,0) '取整
end if
%>