Posted by Anthony on Fri 1 May 15:20
report abuse | download | new post
- <?php
- /*
- This application will connect to the memcached daemons found in the $daemons array and do a raw "stats" command and then
- pump that data out via echo commands.
- ant92083 {at} gmail {dot} com
- 5/1/09
- */
- $host = 'localhost';
- // the array is built port=>type
- '11211' => 'page',
- '11212' => 'default',
- '11213' => 'content',
- '11214' => 'filter',
- '11215' => 'menu',
- '11216' => 'views'
- );
- // loop through the $daemons array
- echo "<table><tr>";
- foreach($daemons as $port=>$type)
- {
- echo "<td>";
- echo "<h1>{$host}:{$port} $type</h1>";
- if(!$socket)
- {
- echo "<h2 style='color: red;'>Error getting connection to {$host}:{$port}</h2>";
- }
- else
- {
- // issue our command to the memcached daemon
- if($bytes <= 0)
- {
- echo "<h2 style'color: red;'>Error sending \'stats\' command to {$host}:{$port}</h2>";
- }
- // kill our telnet connection
- if($bytes <= 0)
- {
- echo "<h2 style'color: red;'>Error sending \'quit\' command to {$host}:{$port}</h2>";
- }
- echo $string;
- }
- echo "</td>";
- }
- }
- echo "</tr></table>";
- ?>
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.