add "total" stat
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@521 c26eb9a1-5813-0410-bd6c-c2e55f420ca73.0
parent
20160af348
commit
a148ea51f3
|
@ -70,6 +70,8 @@ $strings = array(
|
|||
=> '建议参考',
|
||||
'GC'
|
||||
=> 'GC',
|
||||
'Total'
|
||||
=> '总共',
|
||||
'Cache'
|
||||
=> '缓冲区',
|
||||
'Caches'
|
||||
|
|
|
@ -70,6 +70,8 @@ $strings = array(
|
|||
=> '建議參考',
|
||||
'GC'
|
||||
=> 'GC',
|
||||
'Total'
|
||||
=> '总共',
|
||||
'Cache'
|
||||
=> '快取',
|
||||
'Caches'
|
||||
|
|
|
@ -17,17 +17,15 @@ th { font-size: 12px; }
|
|||
.moduleinfo .v {background-color: #cccccc; color: #000000;}
|
||||
.button { }
|
||||
span.sortarrow { color: white; text-decoration: none; }
|
||||
.freeblocks { float: left; margin-right: 4px;}
|
||||
.freeblocks td { text-align: right; }
|
||||
form {margin: 0; padding: 0}
|
||||
|
||||
.percent { height: 3px; margin-bottom: 1px; background: gray; border: 1px solid gray; border-top: 0px; border-bottom: 0px; }
|
||||
.percent div { float: left; height: 100%; }
|
||||
.percent .pavail { background: green; }
|
||||
|
||||
.usagegraph { height: 16px; }
|
||||
.usagegraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; }
|
||||
.usagegraph { border: 1px solid gray; border-bottom: 0px; }
|
||||
.freeblockgraph { height: 16px; }
|
||||
.freeblockgraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; }
|
||||
.freeblockgraph { border: 1px solid gray; border-bottom: 0px; }
|
||||
|
||||
.switcher, h1, h2 { text-align: center; display: block; }
|
||||
.switcher * { color: blue; }
|
||||
|
|
|
@ -168,7 +168,15 @@ function processClear()
|
|||
if (isset($type)) {
|
||||
$cacheid = (int) (isset($_POST['cacheid']) ? $_POST['cacheid'] : 0);
|
||||
if (isset($_POST['clearcache'])) {
|
||||
xcache_clear_cache($type, $cacheid);
|
||||
$count = xcache_count($type);
|
||||
if ($cacheid == $count) {
|
||||
for ($cacheid = 0; $cacheid < $count; $cacheid ++) {
|
||||
xcache_clear_cache($type, $cacheid);
|
||||
}
|
||||
}
|
||||
else {
|
||||
xcache_clear_cache($type, $cacheid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,6 +184,7 @@ processClear();
|
|||
// }}}
|
||||
// {{{ load info/list
|
||||
$cacheinfos = array();
|
||||
$total = array();
|
||||
for ($i = 0; $i < $pcnt; $i ++) {
|
||||
$data = xcache_info(XC_TYPE_PHP, $i);
|
||||
if ($type === XC_TYPE_PHP) {
|
||||
|
@ -185,7 +194,35 @@ for ($i = 0; $i < $pcnt; $i ++) {
|
|||
$data['cache_name'] = "php#$i";
|
||||
$data['cacheid'] = $i;
|
||||
$cacheinfos[] = $data;
|
||||
if ($pcnt >= 2) {
|
||||
foreach ($data as $k => $v) {
|
||||
switch ($k) {
|
||||
case 'type':
|
||||
case 'cache_name':
|
||||
case 'cacheid':
|
||||
case 'free_blocks':
|
||||
continue 2;
|
||||
}
|
||||
if (!isset($total[$k])) {
|
||||
$total[$k] = $v;
|
||||
}
|
||||
else {
|
||||
$total[$k] += $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($pcnt >= 2) {
|
||||
$total['type'] = XC_TYPE_PHP;
|
||||
$total['cache_name'] = _T('Total');
|
||||
$total['cacheid'] = $pcnt;
|
||||
$total['gc'] = null;
|
||||
$total['istotal'] = true;
|
||||
$cacheinfos[] = $total;
|
||||
}
|
||||
|
||||
$total = array();
|
||||
for ($i = 0; $i < $vcnt; $i ++) {
|
||||
$data = xcache_info(XC_TYPE_VAR, $i);
|
||||
if ($type === XC_TYPE_VAR) {
|
||||
|
@ -195,6 +232,33 @@ for ($i = 0; $i < $vcnt; $i ++) {
|
|||
$data['cache_name'] = "var#$i";
|
||||
$data['cacheid'] = $i;
|
||||
$cacheinfos[] = $data;
|
||||
if ($pcnt >= 2) {
|
||||
foreach ($data as $k => $v) {
|
||||
switch ($k) {
|
||||
case 'type':
|
||||
case 'cache_name':
|
||||
case 'cacheid':
|
||||
case 'free_blocks':
|
||||
case 'gc':
|
||||
continue 2;
|
||||
}
|
||||
if (!isset($total[$k])) {
|
||||
$total[$k] = $v;
|
||||
}
|
||||
else {
|
||||
$total[$k] += $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($vcnt >= 2) {
|
||||
$total['type'] = XC_TYPE_VAR;
|
||||
$total['cache_name'] = _T('Total');
|
||||
$total['cacheid'] = $vcnt;
|
||||
$total['gc'] = null;
|
||||
$total['istotal'] = true;
|
||||
$cacheinfos[] = $total;
|
||||
}
|
||||
// }}}
|
||||
// {{{ merge the list
|
||||
|
@ -209,6 +273,9 @@ case XC_TYPE_VAR:
|
|||
$cachelist['type_name'] = 'php';
|
||||
}
|
||||
foreach ($cacheinfos as $i => $c) {
|
||||
if (!empty($c['istotal'])) {
|
||||
continue;
|
||||
}
|
||||
if ($c['type'] == $type && isset($c['cache_list'])) {
|
||||
foreach ($c['cache_list'] as $e) {
|
||||
$e['cache_name'] = $c['cache_name'];
|
||||
|
|
|
@ -50,16 +50,28 @@ $b = new Cycle('class="col1"', 'class="col2"');
|
|||
$pavail = (int) ($ci['avail'] / $ci['size'] * 100);
|
||||
$pused = 100 - $pavail;
|
||||
|
||||
$graph = freeblock_to_graph($ci['free_blocks'], $ci['size']);
|
||||
$w = $free_graph_width;
|
||||
$tdwidth = $w + 2;
|
||||
if (empty($ci['istotal'])) {
|
||||
$graph = freeblock_to_graph($ci['free_blocks'], $ci['size']);
|
||||
$freeblockgraph = "<div class=\"freeblockgraph\" style=\"width: {$w}px\">{$graph}</div>";
|
||||
}
|
||||
else {
|
||||
$freeblockgraph = '';
|
||||
}
|
||||
|
||||
$ci_slots = size($ci['slots']);
|
||||
$ci_size = size($ci['size']);
|
||||
$ci_avail = size($ci['avail']);
|
||||
$ci = number_formats($ci, $numkeys);
|
||||
$ci['compiling'] = $ci['type'] == $type_php ? ($ci['compiling'] ? 'yes' : 'no') : '-';
|
||||
$ci['can_readonly'] = $ci['can_readonly'] ? 'yes' : 'no';
|
||||
if (!empty($ci['istotal'])) {
|
||||
$ci['compiling'] = '-';
|
||||
$ci['can_readonly'] = '-';
|
||||
}
|
||||
else {
|
||||
$ci['compiling'] = $ci['type'] == $type_php ? ($ci['compiling'] ? 'yes' : 'no') : '-';
|
||||
$ci['can_readonly'] = $ci['can_readonly'] ? 'yes' : 'no';
|
||||
}
|
||||
echo <<<EOS
|
||||
<th>{$ci['cache_name']}</th>
|
||||
<td title="{$ci['slots']}">{$ci_slots}</td>
|
||||
|
@ -70,8 +82,7 @@ $b = new Cycle('class="col1"', 'class="col2"');
|
|||
><div style="width: {$pavail}%" class="pavail"></div
|
||||
><div style="width: {$pused}%" class="pused"></div
|
||||
></div
|
||||
><div class="usagegraph" style="width: {$w}px">{$graph}</div
|
||||
></td>
|
||||
>{$freeblockgraph}</td>
|
||||
<td
|
||||
><form method="post"
|
||||
><div
|
||||
|
|
Loading…
Reference in New Issue