/** * Runs nagios checks based on flags * * @param \BackupStore $store * @return int returnstate * @author : Rafał Trójniak rafal@trojniak.net */ function run(\BackupStore $store) { $dir = $store->getDir($this->bucket); if(is_null($dir)){ throw new \RuntimeException("Cannot find dir with name ".$this->bucket); } $states=array(0=>true); $output=array(); if(in_array('size', $this->checks)){ list($ret,$comment,$perf) = $results = $this->checkSize($dir); $states[$ret]=true; $output['size']=$results; } if(in_array('count', $this->checks)){ list($ret,$comment,$perf) = $results = $this->checkCount($dir); $states[$ret]=true; $output['count']=$results; } if(in_array('oldest', $this->checks)){ list($ret,$comment,$perf) = $results = $this->checkOldest($dir); $states[$ret]=true; $output['oldest']= $results; } if(in_array('newest', $this->checks)){ list($ret,$comment,$perf) = $results = $this->checkNewest($dir); $states[$ret]=true; $output['newest']=$results; } $ret=max(array_keys($states)); $message=array(); foreach($output as $plugin=>$vals){ $message[]=$plugin."[".$this->retState($vals[0]).':'.$vals[1]."]"; } $message=implode('; ',$message)."|"; // Adding performance foreach($output as $plugin=>$vals){ $message.=$plugin."[".implode(' ',$vals[2])."] "; } echo $message."\n"; return $ret; }
/** * Prints bucket contents * * @param \BackupStore $store * @return int returnstate * @author : Rafał Trójniak rafal@trojniak.net */ function run(\BackupStore $store) { if($this->bucket!==false){ $dir=$store->getDir($this->bucket); if(is_null($dir)){ throw new \RuntimeException('Bucket "'.addslashes($this->bucket).'" not found'); } $this->listBackup($dir); }else{ echo "== List backups\n"; $dirs=$store->getDirs(); foreach($dirs as $id=>$dir){ echo "[$id]:\n"; $this->listBackup($dir); } } return true; }