-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_mia_uptime.php
executable file
·53 lines (43 loc) · 1.67 KB
/
check_mia_uptime.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
#!/usr/local/bin/php5 -q
<?php
require_once('lib/MiaNagiosPluginSimple.inc.php');
class MiaNagiosPlugin_CheckUpTime extends MiaNagiosPluginSimple{
/**
* (non-PHPdoc)
* @see nagios/plugins/lib/MiaNagiosPlugin#setSpecialProperties()
*/
protected function setSpecialProperties(){
$this->setSpecialProperty('intituleStatus','UPTIME');
$this->setSpecialProperty('titre_aide','Plugins Nagios qui v�rifie le uptime');
$this->setSpecialProperty('commentaire_aide','');
}
/**
* (non-PHPdoc)
* @see nagios/plugins/lib/MiaNagiosPlugin#setIndicators()
*/
protected function setIndicators(){
$this->addIndicatorSimple('uptime');
$this->setIndicatorMin('uptime',0 );
}
/**
* (non-PHPdoc)
* @see miadm/bin/nagios/plugins/lib/MiaNagiosPluginSNMPSimple#coreFunction()
*/
protected function coreFunction(){
trigger_error("start",E_USER_NOTICE);
exec('uptime',$output);
if (preg_match("/\s([0-9]+)\sdays?/",$output[0],$matche) > 0 ){
$output['uptime']=$matche[1];
trigger_error("uptime ".$matche[1],E_USER_NOTICE);
}
trigger_error("/\s([0-9]+:[0-9]+:[0-9]+)\sup\s/".$output[0],E_USER_NOTICE);
if (preg_match("/\s([0-9]+:[0-9]+:[0-9]+)\sup\s+/",$output[0],$matche) > 0 ){
$output['uptime']=0;
trigger_error("uptime ".$matche[1],E_USER_NOTICE);
}
trigger_error("end",E_USER_NOTICE);
return $output;
}
}
$check=new MiaNagiosPlugin_CheckUptime();
$check->OutputResult();