-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_mia_df_inode.php
executable file
·53 lines (44 loc) · 1.76 KB
/
check_mia_df_inode.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/MiaNagiosPluginIndexed.inc.php');
class MiaNagiosPlugin_CheckInodeUsage extends MiaNagiosPluginIndexed{
/**
* (non-PHPdoc)
* @see nagios/plugins/lib/MiaNagiosPlugin#setSpecialProperties()
*/
protected function setSpecialProperties(){
$this->setSpecialProperty('intituleStatus','INODE_USAGE');
$this->setSpecialProperty('titre_aide','Plugins Nagios de surveillance des remplissages des tables des inodes des FS');
$this->setSpecialProperty('commentaire_aide','');
}
/**
* (non-PHPdoc)
* @see nagios/plugins/lib/MiaNagiosPlugin#setIndicators()
*/
protected function setIndicators(){
$this->addIndicatorIndexed('inodes');
$this->setIndicatorMin('inodes',0 );
$this->setIndicatorUnit('inodes','%');
}
protected function coreFunction(){
trigger_error("start",E_USER_NOTICE);
exec('df -i | grep -vE "^Filesystem" | grep -v "/mnt/" | egrep -v "^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"',$output);
foreach ($output as $line){
if (preg_match("/\s([0-9]+)%\s+(.+)$/",$line,$matche)){
$output['inodes'][$matche[2]]=$matche[1];
trigger_error("df $nom trouve $percentused%",E_USER_NOTICE);
}
}
trigger_error("end",E_USER_NOTICE);
return $output;
}
/**
* (non-PHPdoc)
* @see nagios/plugins/lib/MiaNagiosPlugin#StatusInformationFilter()
*/
protected function StatusInformationFilter($name,$value){
return $name.'='.$value.'%';
}
}
$check=new MiaNagiosPlugin_CheckInodeUsage();
$check->OutputResult();