disk = $disk; } public function refreshData() { $return = 0; $datarows = array(); exec("df -m ".$this->disk." | grep -v Filesystem| tail -1 | awk '{printf int($1)\"::\"int($2)\"::\"int($3)\"::\"int($4)}'", $datarows, $return); // exec("df -m ".$this->disk." | grep -v Filesystem| tail -1 | awk '{printf int($2)::int($3)::int($4)::int($5)}'", $datarows, $return); if ($return !== 0) { throw new Exception('Could not read from "' . $this->disk . '"'); } $cmdoutput = implode(' ', $datarows); $parts = explode("::",$cmdoutput); foreach ($parts as $key => $part) { //$parts[$key] = ereg_replace("[^0-9]", "", $part); $parts[$key] = preg_replace('[^0-9]', '', $part); // printf("$parts[$key]\n"); } $this->availablespace = $parts[0]/1024; $this->usedspace = $parts[1]/1024; $this->freespace = $parts[2]/1024; $this->percentage = $parts[3]; } public function initRRD(rrd $rrd) { $rrd->addDatasource('availablediskspace', 'GAUGE', null, 0); $rrd->addDatasource('freediskspace', 'GAUGE', null, 0); $rrd->addDatasource('useddiskspace', 'GAUGE', null, 0); $rrd->addDatasource('usedpercentage', 'GAUGE', null, 0); } public function fetchValues() { $values = array(); $values['availablediskspace'] = $this->availablespace; $values['useddiskspace'] = $this->usedspace; $values['freediskspace'] = $this->freespace; $values['usedpercentage'] = $this->percentage; return $values; } } ?>