Browse Source

cacher/htdocs: same scale in same cache type for hits graph

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1058 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 9 years ago
parent
commit
e9a5bed3e9
  1. 19
      htdocs/cacher/cacher.php
  2. 2
      htdocs/cacher/cacher.tpl.php

19
htdocs/cacher/cacher.php

@ -91,20 +91,20 @@ function bar_hits_percent($v, $percent, $active)
. '</div>';
}
function hits_to_graph($hits)
function get_cache_hits_graph($ci, $key)
{
$max = 0;
foreach ($hits as $v) {
if ($max < $v) {
$max = $v;
}
if ($ci['cacheid'] == -1) {
$max = max($ci[$key]);
}
else {
$max = $GLOBALS['maxhits_by_hour'][$ci['type']];
}
if (!$max) {
return '';
$max = 1;
}
$t = (time() / (60 * 60)) % 24;
$html = array();
foreach ($hits as $i => $v) {
foreach ($ci[$key] as $i => $v) {
$html[] = bar_hits_percent($v, $v / $max, $i == $t);
}
return implode('', $html);
@ -184,6 +184,7 @@ processClear();
// {{{ load info/list
$cacheinfos = array();
$total = array();
$maxhits_by_hour = array(0, 0);
for ($i = 0; $i < $pcnt; $i ++) {
$data = xcache_info(XC_TYPE_PHP, $i);
if ($type === XC_TYPE_PHP) {
@ -193,6 +194,7 @@ for ($i = 0; $i < $pcnt; $i ++) {
$data['cache_name'] = "php#$i";
$data['cacheid'] = $i;
$cacheinfos[] = $data;
$maxhits_by_hour[XC_TYPE_PHP] = max($maxhits_by_hour[XC_TYPE_PHP], max($data['hits_by_hour']));
if ($pcnt >= 2) {
calc_total($total, $data);
}
@ -217,6 +219,7 @@ for ($i = 0; $i < $vcnt; $i ++) {
$data['cache_name'] = "var#$i";
$data['cacheid'] = $i;
$cacheinfos[] = $data;
$maxhits_by_hour[XC_TYPE_VAR] = max($maxhits_by_hour[XC_TYPE_VAR], max($data['hits_by_hour']));
if ($vcnt >= 2) {
calc_total($total, $data);
}

2
htdocs/cacher/cacher.tpl.php

@ -83,7 +83,7 @@ $b = new Cycle('class="col1"', 'class="col2"');
$hits_avg_h = number_format(array_avg($ci['hits_by_hour']), 2);
$hits_avg_s = number_format(array_avg($ci['hits_by_second']), 2);
$hits_graph_h = hits_to_graph($ci['hits_by_hour']);
$hits_graph_h = get_cache_hits_graph($ci, 'hits_by_hour');
$hits_graph_h_w = count($ci['hits_by_hour']) * 2;
if (!empty($ci['istotal'])) {

Loading…
Cancel
Save