'01','url'=>$ytitle.'01',name=>'January',sname=>'Jan',start=>mktime(0,0,0,1,$start_day,$ytitle),stop=>mktime(0,0,0,2,$start_day,$ytitle)), Array('id'=>'02','url'=>$ytitle.'02',name=>'February',sname=>'Feb',start=>mktime(0,0,0,2,$start_day,$ytitle),stop=>mktime(0,0,0,3,$start_day,$ytitle)), Array('id'=>'03','url'=>$ytitle.'03',name=>'March',sname=>'Mar',start=>mktime(0,0,0,3,$start_day,$ytitle),stop=>mktime(0,0,0,4,$start_day,$ytitle)), Array('id'=>'04','url'=>$ytitle.'04',name=>'April',sname=>'Apr',start=>mktime(0,0,0,4,$start_day,$ytitle),stop=>mktime(0,0,0,5,$start_day,$ytitle)), Array('id'=>'05','url'=>$ytitle.'05',name=>'May',sname=>'May',start=>mktime(0,0,0,5,$start_day,$ytitle),stop=>mktime(0,0,0,6,$start_day,$ytitle)), Array('id'=>'06','url'=>$ytitle.'06',name=>'June',sname=>'Jun',start=>mktime(0,0,0,6,$start_day,$ytitle),stop=>mktime(0,0,0,7,$start_day,$ytitle)), Array('id'=>'07','url'=>$ytitle.'07',name=>'July',sname=>'Jul',start=>mktime(0,0,0,7,$start_day,$ytitle),stop=>mktime(0,0,0,8,$start_day,$ytitle)), Array('id'=>'08','url'=>$ytitle.'08',name=>'August',sname=>'Aug',start=>mktime(0,0,0,8,$start_day,$ytitle),stop=>mktime(0,0,0,9,$start_day,$ytitle)), Array('id'=>'09','url'=>$ytitle.'09',name=>'September',sname=>'Sep',start=>mktime(0,0,0,9,$start_day,$ytitle),stop=>mktime(0,0,0,10,$start_day,$ytitle)), Array('id'=>'10','url'=>$ytitle.'10',name=>'October',sname=>'Oct',start=>mktime(0,0,0,10,$start_day,$ytitle),stop=>mktime(0,0,0,11,$start_day,$ytitle)), Array('id'=>'11','url'=>$ytitle.'11',name=>'November',sname=>'Nov',start=>mktime(0,0,0,11,$start_day,$ytitle),stop=>mktime(0,0,0,12,$start_day,$ytitle)), Array('id'=>'12','url'=>$ytitle.'12',name=>'December',sname=>'Dec',start=>mktime(0,0,0,12,$start_day,$ytitle),stop=>mktime(0,0,0,1,$start_day,$ytitle+1))); } else if (strlen($title) == 6) { // month $name="Day"; $next_month=($mtitle!=12 ? $mtitle+1 : 1); $next_year=($mtitle!=12 ? $ytitle : $ytitle + 1); $start=mktime(0,0,0,$mtitle,$start_day,$ytitle); $finish=mktime(0,0,0,$next_month,$start_day,$next_year); $days_max=$monlen[intval(substr($title,4,2))]; for ($i=1;$i<=$days_max;$i++) { $days[]=$i; } $days=array_merge( array_slice($days,$start_day-1,($days_max-$start_day)+1), array_slice($days,0,$start_day-1)); $month=$mtitle; $year=$ytitle; foreach ($days as $i) { $day=str_pad($i,2,"0",STR_PAD_LEFT); $output[$i]['id']=$day; $output[$i]['start']=mktime(0,0,0,$month,$i,$year); $output[$i]['stop']=mktime(0,0,0,($i!=$days_max ? $month : $next_month), ($i!=$days_max ? $i+1 : 1), ($i!=$days_max ? $year : $next_year)); $output[$i]['url']=date("Ymd",$output[$i]['start']); if ($i==$days_max) { $month=$next_month; $year=$next_year; } } } else if (strlen($title) == 8) { // day $name="Hour"; $days_max=$monlen[intval(substr($title,4,2))]; $next_month=($dtitle!=$days_max ? $mtitle : ($mtitle!=12 ? $mtitle+1 : 1)); $next_year=($dtitle!=$days_max ? $ytitle : ($mtitle!=12 ? $ytitle : $ytitle + 1)); $start=mktime(0,0,0,$mtitle,$dtitle,$ytitle); $finish=mktime(0,0,0,($dtitle!=$days_max ? $mtitle : $next_month), ($dtitle!=$days_max ? $dtitle+1 : 1), ($dtitle!=$days_max ? $ytitle : $next_year)); for ($i=$start;$i<$finish;$i+=3600) { $hour=date("H",$i); $hour=str_pad($hour,2,"0",STR_PAD_LEFT); $output[]=Array('id'=>$hour,'name'=>$hour.":00–".$hour.":59",'sname'=>$hour,'start'=>$i,'stop'=>$i+3600); } } $debug="start: ".microtime()."\n"; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file != "." && $file != "..") { if ($file+86400 <= $start || $file >= $finish) { continue; } $fd=file_get_contents($dir.$file); $z=explode(" ",str_replace("\n","",$fd)); foreach ($output as $key => $period) { if ($period['start'] >= $file+86400 || $period['stop'] <= $file) { continue; } if (MODE==PLUSNET || MODE==AAISP) { list ($y,$m,$d) = explode(" ",gmdate("Y m d",$file)); } if ($period['start'] <= $file && $period['stop'] >= $file+86400) { $all=TRUE; } if ((MODE==NORMAL || DAY) && $all) { // load the whole file $debug.="load: $file (all) to ".$period['id']."\n"; $data[$key][RX]+=array_sum(array_slice($z,0,24)); $data[$key][TX]+=array_sum(array_slice($z,24,24)); } else { // load part of the file if ($all) { $debug.="load: $file (all) to ".$period['id']."\n"; $offset=0; $length=24; } else { if ($period['start'] <= $file) { $offset=0; } else { $offset=($period['start'] - $file)/3600; } if ($period['stop'] >= $file+86400) { $length=24 - $offset; } else { $length=($period['stop'] - $file)/3600 - $offset; } $debug.="load: $file ($offset+$length) to ".$period['id']."\n"; } if (MODE==NORMAL || DAY) { $data[$key][RX]+=array_sum(array_slice($z,$offset,$length)); $data[$key][TX]+=array_sum(array_slice($z,24+$offset,$length)); } else if (MODE==PLUSNET) { for ($i=$file+$offset*3600,$j=$offset; $j<$offset+$length; $i+=3600,$j++) { $h=date("G",$i); if (isset($peak[$h])) { $data[$key][RX]+=$z[$j]; $data[$key][RX]+=$z[24+$j]; } else { $data[$key][TX]+=$z[$j]; $data[$key][TX]+=$z[24+$j]; } } } else if (MODE==AAISP) { for ($i=$file+$offset*3600,$j=$offset; $j<$offset+$length; $i+=3600,$j++) { $h=date("G",$i); $w=date("w",$i); if (isset($peak[$h]) && $w!=0 && $w!=6) { $data[$key][RX]+=$z[$j]; $data[$key][TX]+=$z[24+$j]; } else { $data[$key][TX]+=$z[$j]; $data[$key][TX]+=$z[24+$j]; } } } } } } } } $debug.="end: ".microtime()."\n"; if (!isset($data)) { header("HTTP/1.1 404 No Data"); header("Content-Type: text/plain"); echo "No data for $title\n"; die(); } ?> <?=$site?>: <?=$xtitle.$atitle?>

'.substr($xtitle,0,strlen($xtitle)-3).''.substr($xtitle,strlen($xtitle)-3).$atitle; } else { echo ''.substr($xtitle,0,strlen($xtitle)-3).''.substr($xtitle,strlen($xtitle)-3).$atitle; } } ?>

'EB', 1024*1024*1024*1024*1024=>'PB', 1024*1024*1024*1024=>'TB', 1024*1024*1024=>'GB', 1024*1024=>'MB', 1024=>'KB', 1=>'B'); $use=Array(1,'B'); $max=0; foreach ($output as $key => $period) { if ($data[$key][RX] > $max) { $max=$data[$key][RX]; } if ($data[$key][TX] > $max) { $max=$data[$key][TX]; } } foreach ($units as $key => $unit) { if ($max/$key < 1000) { $use=Array($key,$unit); } } $exe="./graph.pl"; $exe.=" ".$name; $exe.=" ".$use[1]; foreach ($output as $key => $period) { if (isset($period['sname'])) { $sname=$period['sname']; } else { $sname=$period['id']; } $exe.=" $sname,".$data[$key][RX]/$use[0].",".$data[$key][TX]/$use[0]; } echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $rx=$tx=$cx=Array(); $rows=0; foreach ($output as $key => $period) { if (isset($period['name'])) { $sname=$period['name']; } else { $sname=$period['id']; } echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } else if ($data[$key][RX] > $data[$key][TX]) { echo sprintf("%01.2f",round($data[$key][RX]/$data[$key][TX],2)).' : 1'; } else if ($data[$key][RX] < $data[$key][TX]) { echo sprintf("%01.2f",round($data[$key][RX]/$data[$key][TX],2)).' : 1'; } else if ($data[$key][RX] == $data[$key][TX]) { echo '1 : 1'; } echo ''; if ($data[$key][RX] == 0 && $data[$key][TX] == 0) { continue; } else { $rows++; } $rx[]=$data[$key][RX]; $tx[]=$data[$key][TX]; $cx[]=$data[$key][RX]+$data[$key][TX]; } if ($rows>0) { $arx=array_sum($rx)/$rows; $atx=array_sum($tx)/$rows; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } $mrx=median($rx); $mtx=median($tx); $mcx=median($cx); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $rx=array_sum($rx); $tx=array_sum($tx); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'.$name.''.$receive.' ('.$use[1].')'.$transmit.' ('.$use[1].')Total ('.$use[1].')Ratio
'; if (($data[$key][RX] == 0 && $data[$key][TX] == 0) || !isset($period['url'])) { echo $sname; } else { echo ''.$sname.''; } echo ''.sprintf("%01.2f",round($data[$key][RX]/$use[0],2)).''.sprintf("%01.2f",round($data[$key][TX]/$use[0],2)).''.sprintf("%01.2f",round(($data[$key][RX]+$data[$key][TX])/$use[0],2)).''; if ($data[$key][RX] == 0 || $data[$key][TX] == 0) { echo ' 
Average'.sprintf("%01.2f",round($arx/$use[0],2)).''.sprintf("%01.2f",round($atx/$use[0],2)).''.sprintf("%01.2f",round(($arx+$atx)/$use[0],2)).' '; echo '
Median'.sprintf("%01.2f",round($mrx/$use[0],2)).''.sprintf("%01.2f",round($mtx/$use[0],2)).''.sprintf("%01.2f",round($mcx/$use[0],2)).''; if ($mrx == 0 || $mtx == 0) { echo ' '; } else if ($mrx > $mtx) { echo sprintf("%01.2f",round($mrx/$mtx,2)).' : 1'; } else if ($mrx < $mtx) { echo sprintf("%01.2f",round($mrx/$mtx,2)).' : 1'; } else if ($mrx == $mtx) { echo '1 : 1'; } echo '
Total'.sprintf("%01.2f",round($rx/$use[0],2)).''.sprintf("%01.2f",round($tx/$use[0],2)).''.sprintf("%01.2f",round(($rx+$tx)/$use[0],2)).''; if ($rx == 0 || $tx == 0) { echo ' '; } else if ($rx > $tx) { echo sprintf("%01.2f",round($rx/$tx,2)).' : 1'; } else if ($rx < $tx) { echo sprintf("%01.2f",round($rx/$tx,2)).' : 1'; } else if ($rx == $tx) { echo '1 : 1'; } echo '
'; ?>