| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | public function run() |
||
| 29 | { |
||
| 30 | $free = disk_free_space($this->directory); |
||
| 31 | $total = disk_total_space($this->directory); |
||
| 32 | |||
| 33 | $usage = 100 - round(($free / $total) * 100); |
||
| 34 | |||
| 35 | if ($usage > $this->maxUsageInPercent) { |
||
| 36 | $result = new MetricAwareResult(Result::STATUS_FAIL, 'No space left on device. ' . $usage . '% used (' . $this->directory . ').'); |
||
| 37 | } else { |
||
| 38 | $result = new MetricAwareResult(Result::STATUS_PASS, 'Enough space left on device. ' . $usage . '% used (' . $this->directory . ').'); |
||
| 39 | } |
||
| 40 | |||
| 41 | $result->setMetric($usage / 100, 'percent', MetricAwareResult::METRIC_TYPE_PERCENT); |
||
| 42 | $result->setLimit($this->maxUsageInPercent / 100); |
||
| 43 | $result->setLimitType(MetricAwareResult::LIMIT_TYPE_MAX); |
||
| 44 | $result->setObservedValuePrecision(2); |
||
| 45 | |||
| 46 | return $result; |
||
| 47 | } |
||
| 54 |