Changeset 517 for trunk


Ignore:
Timestamp:
2008-02-17T11:52:38+01:00 (7 years ago)
Author:
moo
Message:

show free blocks as graph

Location:
trunk/admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/common.php

    r418 r517  
    109109    $lang = 'en-us'; 
    110110} 
     111if (!isset($free_graph_width)) { 
     112    $free_graph_width = 120; 
     113} 
    111114 
    112115?> 
  • trunk/admin/config.php.example

    r161 r517  
    1111// developers only 
    1212$show_todo_strings = false; 
     13 
     14// width of graph for free blocks 
     15$free_graph_width = 120; 
    1316 
    1417// this function is detected by xcache.tpl.php, and enabled if function_exists 
  • trunk/admin/xcache.css

    r371 r517  
    2020.freeblocks td { text-align: right; } 
    2121form {margin: 0; padding: 0} 
    22 .percent { border: 1px solid black; width: 80%; height: 20px; } 
    23 .percent div { font-size: 1px; line-height: 1px; width: 100%;} 
    24 .percent .pavail { background: blue; } 
     22 
     23.percent { height: 3px; margin-bottom: 1px; background: gray; border: 1px solid gray; border-top: 0px; border-bottom: 0px; } 
     24.percent div { float: left; height: 100%; } 
     25.percent .pavail { background: green; } 
     26 
     27.usagegraph { height: 16px; } 
     28.usagegraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; } 
     29.usagegraph { border: 1px solid gray; border-bottom: 0px; } 
     30 
    2531.switcher, h1, h2 { text-align: center; display: block; } 
    2632.switcher * { color: blue; } 
  • trunk/admin/xcache.php

    r421 r517  
    7373 
    7474    return '0 s'; 
     75} 
     76 
     77function freeblock_to_graph($freeblocks, $size) 
     78{ 
     79    global $free_graph_width; 
     80 
     81    // cached in static variable 
     82    static $graph_initial; 
     83    if (!isset($graph_initial)) { 
     84        for ($i = 0; $i < $free_graph_width; $i ++) { 
     85            $graph_initial[$i] = 0; 
     86        } 
     87    } 
     88    $graph = $graph_initial; 
     89    foreach ($freeblocks as $b) { 
     90        $begin = $b['offset'] / $size * $free_graph_width; 
     91        $end = ($b['offset'] + $b['size']) / $size * $free_graph_width; 
     92 
     93        $graph[(int) $begin] += 1 - ($begin - (int) $begin); 
     94        $graph[(int) $end] += ($end - (int) $end); 
     95        for ($i = (int) $begin + 1, $e = (int) $end; $i < $e; $i ++) { 
     96            $graph[$i] = 1; 
     97        } 
     98    } 
     99    $html = array(); 
     100    $c = 255; 
     101    foreach ($graph as $k => $v) { 
     102        $v = (int) ($v * $c); 
     103        $r = $g = $c - $v; 
     104        $b = $c; 
     105        $html[] = '<div style="background: rgb(' . "$r,$g,$b" . ')"></div>'; 
     106    } 
     107    return implode('', $html); 
    75108} 
    76109 
  • trunk/admin/xcache.tpl.php

    r456 r517  
    5151        $pused = 100 - $pavail; 
    5252 
     53        $graph = freeblock_to_graph($ci['free_blocks'], $ci['size']); 
     54        $w = $free_graph_width; 
     55        $tdwidth = $w + 2; 
     56 
    5357        $ci_slots = size($ci['slots']); 
    5458        $ci_size  = size($ci['size']); 
     
    6266        <td title="{$ci['size']}">{$ci_size}</td> 
    6367        <td title="{$ci['avail']}">{$ci_avail}</td> 
    64         <td title="{$pavail} %"><div class="percent"><div style="height: {$pused}%" class="pused">&nbsp;</div><div style="height: {$pavail}%" class="pavail">&nbsp;</div></div></td> 
     68        <td title="{$pavail} %" width="{$tdwidth}" 
     69            ><div class="percent" style="width: {$w}px" 
     70                ><div style="width: {$pavail}%" class="pavail"></div 
     71                ><div style="width: {$pused}%" class="pused"></div 
     72            ></div 
     73            ><div class="usagegraph" style="width: {$w}px">{$graph}</div 
     74        ></td> 
    6575        <td> 
    6676            <form method="post"> 
     
    8999    <?php } ?> 
    90100</table> 
    91 <div> 
    92     <?php echo _T('Free Blocks'); ?>: 
    93 </div> 
    94 <?php 
    95 foreach ($cacheinfos as $i => $ci) { 
    96     $b->reset(); 
    97 ?> 
    98 <table cellspacing="0" cellpadding="4" class="cycles freeblocks"> 
    99     <tr> 
    100         <th><?php echo $ci['cache_name']; ?> <?php echo _T("size"); ?><br><?php echo _T("offset"); ?></th> 
    101     <?php 
    102     foreach ($ci['free_blocks'] as $block) { 
    103         $size   = size($block['size']); 
    104         $offset = size($block['offset']); 
    105  
    106         $c = $b->next(); 
    107         echo " 
    108         <td $c><nobr>$size<br>$offset</nobr></td>"; 
    109     } 
    110     ?> 
    111  
    112     </tr> 
    113 </table> 
    114 <?php 
    115 } 
    116 ?> 
    117101<div style="clear: both">&nbsp;</div> 
    118102<?php 
Note: See TracChangeset for help on using the changeset viewer.