update monitor.php
This commit is contained in:
parent
be8fa71580
commit
8eaa6356a3
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue