update monitor.php
This commit is contained in:
parent
be8fa71580
commit
8eaa6356a3
|
@ -57,6 +57,11 @@ class iredis
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRedis()
|
||||||
|
{
|
||||||
|
return $this->redis;
|
||||||
|
}
|
||||||
|
|
||||||
public function configure($redis_server, $redis_port)
|
public function configure($redis_server, $redis_port)
|
||||||
{
|
{
|
||||||
$this->redis_server = $redis_server;
|
$this->redis_server = $redis_server;
|
||||||
|
|
|
@ -4,30 +4,40 @@
|
||||||
* This class uses to monitor all redis cluster pool
|
* This class uses to monitor all redis cluster pool
|
||||||
*
|
*
|
||||||
* DEPENDS
|
* DEPENDS
|
||||||
* phpredis and iredis
|
* phpredis and iredis
|
||||||
*
|
*
|
||||||
* VERSION
|
* VERSION
|
||||||
* 2014-03-19 1.0
|
* 2014-03-19 1.0
|
||||||
*
|
*
|
||||||
* AUTHOR
|
* AUTHOR
|
||||||
* Aborn Jiang
|
* Aborn Jiang
|
||||||
*
|
*
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
require_once 'iredis.php'
|
||||||
|
|
||||||
require_once '/vagrant_data/data/rediska/library/Rediska.php';
|
class monitor
|
||||||
// Initialize Rediska
|
{
|
||||||
$rediska = new Rediska();
|
private $redis;
|
||||||
|
private $iredis;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->iredis = new iredis();
|
||||||
|
$this->redis = $this->iredis->getRedis();
|
||||||
|
}
|
||||||
|
|
||||||
// Get monitor with 2 minutes timeout
|
public function __destruct()
|
||||||
$monitor = $rediska->monitor(60 * 2);
|
{
|
||||||
|
}
|
||||||
// Get monitor on specified server
|
|
||||||
// $monitor = $rediska->on('server1')->monitor();
|
// get how many keys in the current redis
|
||||||
|
public function getSize()
|
||||||
// Get commands
|
{
|
||||||
foreach($monitor as $timestamp => $command) {
|
return $this->redis->dbSize();
|
||||||
print "$timestamp => $command";
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue