update monitor.php

This commit is contained in:
Guobao Jiang 2014-03-19 17:40:53 +08:00
parent be8fa71580
commit 8eaa6356a3
2 changed files with 30 additions and 15 deletions

View File

@ -57,6 +57,11 @@ class iredis
return $this->status;
}
public function getRedis()
{
return $this->redis;
}
public function configure($redis_server, $redis_port)
{
$this->redis_server = $redis_server;

View File

@ -4,30 +4,40 @@
* This class uses to monitor all redis cluster pool
*
* DEPENDS
* phpredis and iredis
* phpredis and iredis
*
* VERSION
* 2014-03-19 1.0
* 2014-03-19 1.0
*
* AUTHOR
* Aborn Jiang
* Aborn Jiang
*
***/
require_once 'iredis.php'
require_once '/vagrant_data/data/rediska/library/Rediska.php';
// Initialize Rediska
$rediska = new Rediska();
class monitor
{
private $redis;
private $iredis;
public function __construct()
{
$this->iredis = new iredis();
$this->redis = $this->iredis->getRedis();
}
// Get monitor with 2 minutes timeout
$monitor = $rediska->monitor(60 * 2);
// Get monitor on specified server
// $monitor = $rediska->on('server1')->monitor();
// Get commands
foreach($monitor as $timestamp => $command) {
print "$timestamp => $command";
public function __destruct()
{
}
// get how many keys in the current redis
public function getSize()
{
return $this->redis->dbSize();
}
}
?>