-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_mia_redis.php
executable file
·70 lines (62 loc) · 1.94 KB
/
check_mia_redis.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/local/bin/php5 -q
<?php
require_once('lib/MiaNagiosPluginRedisSimple.inc.php');
class MiaNagiosPlugin_CheckRedis extends MiaNagiosPluginRedisSimple{
/**
* (non-PHPdoc)
* @see nagios/plugins/lib/MiaNagiosPlugin#setSpecialProperties()
*/
protected function setSpecialProperties(){
$this->setSpecialProperty('intituleStatus','REDIS');
$this->setSpecialProperty('titre_aide','Plugins Nagios de supervision serveur Redis');
$this->setSpecialProperty('commentaire_aide','');
}
/**
* (non-PHPdoc)
* @see nagios/plugins/lib/MiaNagiosPlugin#setIndicators()
*/
protected function setIndicators(){
$this->addIndicatorSimple('connected_clients');
$this->addIndicatorSimple('used_memory');
$this->addIndicatorSimple('connected_slaves');
$this->addIndicatorSimple('blocked_clients');
}
protected function coreFunction(){
trigger_error("start",E_USER_NOTICE);
try{
$info=$this->redis->info();
trigger_error(serialize($info),E_USER_NOTICE);
if ($info['role'] != 'master'){
$info['connected_slaves']=1;
}
} catch(Exception $e){
$info=array();
}
trigger_error("end",E_USER_NOTICE);
return $info;
}
/**
* (non-PHPdoc)
* @see nagios/plugins/lib/MiaNagiosPlugin#globalStatusFilter($status)
*/
public function globalStatusFilter($status){
if ($status == unknown){
return critical;
} else {
return $status;
}
}
/**
* (non-PHPdoc)
* @see nagios/plugins/lib/MiaNagiosPlugin#globalStatusFilter($status)
*/
public function dataFilter($name,$value){
switch($name){
case 'used_memory': $value=sprintf("%.0f",$value/1024/1024);
break;
}
return $value;
}
}
$check=new MiaNagiosPlugin_CheckRedis();
$check->OutputResult();