Example #1
0
        $items = $cacheItems['items'];
        $totals = $cacheItems['counts'];
        $maxDump = MAX_ITEM_DUMP;
        foreach ($items as $server => $entries) {
            echo <<<EOB

\t\t\t<div class="info"><table cellspacing=0><tbody>
\t\t\t<tr><th colspan="2">{$server}</th></tr>
\t\t\t<tr><th>Slab Id</th><th>Info</th></tr>
EOB;
            foreach ($entries as $slabId => $slab) {
                $dumpUrl = $PHP_SELF . '&op=2&server=' . array_search($server, $MEMCACHE_SERVERS) . '&dumpslab=' . $slabId;
                echo "<tr class=tr-{$m}>", "<td class=td-0><center>", '<a href="', $dumpUrl, '">', $slabId, '</a>', "</center></td>", "<td class=td-last><b>Item count:</b> ", $slab['number'], '<br/><b>Age:</b>', duration($time - $slab['age']), '<br/> <b>Evicted:</b>', isset($slab['evicted']) && $slab['evicted'] == 1 ? 'Yes' : 'No';
                if (isset($_GET['dumpslab']) && $_GET['dumpslab'] == $slabId && (isset($_GET['server']) && $_GET['server'] == array_search($server, $MEMCACHE_SERVERS))) {
                    echo "<br/><b>Items: item</b><br/>";
                    $items = dumpCacheSlab($server, $slabId, $slab['number']);
                    // maybe someone likes to do a pagination here :)
                    $i = 1;
                    foreach ($items['ITEM'] as $itemKey => $itemInfo) {
                        $itemInfo = trim($itemInfo, '[ ]');
                        echo '<a href="', $PHP_SELF, '&op=4&server=', array_search($server, $MEMCACHE_SERVERS), '&key=', base64_encode($itemKey) . '">', $itemKey, '</a>';
                        if ($i++ % 10 == 0) {
                            echo '<br/>';
                        } elseif ($i != $slab['number'] + 1) {
                            echo ',';
                        }
                    }
                }
                echo "</td></tr>";
                $m = 1 - $m;
            }
\t\t\t<tr><th>Slab Id</th><th>Info</th></tr>
EOB;
            foreach ($entries as $slabId => $slab) {
                $dumpUrl = $PHP_SELF . '&op=2&server=' . array_search($server, $MEMCACHE_SERVERS) . '&dumpslab=' . $slabId;
                echo "<tr class=tr-{$m}>", "<td class=td-0><center>", '<a href="', $dumpUrl, '">', $slabId, '</a>', "</center></td>", "<td class=td-last><b>Item count:</b> ", $slab['number'], '<br/><b>Age:</b>', duration($time - $slab['age']), '<br/><b>Evicted:</b> ', isset($slab['evicted']) ? $slab['evicted'] : 'No', '<br/><b>chunk size:</b> ', $slab['chunk_size'], '', '<br/><b>chunks per page:</b> ', $slab['chunks_per_page'], '<br/><b>total chunks:</b> ', $slab['total_chunks'], '<br/><b>used chunks:</b> ', $slab['used_chunks'], '<br/><b>free chunks:</b> ', $slab['free_chunks'], '<br/><b>free chunks_end:</b> ', $slab['free_chunks_end'], '<br/><b>total pages:</b> ', $slab['total_pages'], '<br/><b>total memory:</b> ', bsize($slab['chunk_size'] * $slab['total_chunks']);
                if ($slab['number'] && (isset($_GET['dumpslab']) && $_GET['dumpslab'] == $slabId) && (isset($_GET['server']) && $_GET['server'] == array_search($server, $MEMCACHE_SERVERS))) {
                    echo "<br/><b>Items: item</b><br/>";
                    if (isset($_GET['dumplimit'])) {
                        $dump_limit = intval($_GET['dumplimit']);
                    } else {
                        $dump_limit = $slab['number'];
                    }
                    if ($dump_limit > 100 || $dump_limit < 1) {
                        $dump_limit = 100;
                    }
                    $items = dumpCacheSlab($server, $slabId, $dump_limit);
                    // maybe someone likes to do a pagination here :)
                    $i = 1;
                    foreach ($items['ITEM'] as $itemKey => $itemInfo) {
                        $itemInfo = trim($itemInfo, '[ ]');
                        echo '<a href="', $PHP_SELF, '&op=4&server=', array_search($server, $MEMCACHE_SERVERS), '&key=', base64_encode($itemKey) . '">', $itemKey, '</a>';
                        if ($i++ % 10 == 0) {
                            echo '<br/>';
                        } elseif ($i != $slab['number'] + 1) {
                            echo ',';
                        }
                    }
                }
                echo "</td></tr>";
                $m = 1 - $m;
            }