1 | <?php |
||
8 | final class Diskspace extends CheckDefinition |
||
9 | { |
||
10 | public $command = 'df -P .'; |
||
11 | |||
12 | public function resolve(Process $process) |
||
13 | { |
||
14 | $percentage = $this->getDiskUsagePercentage($process->getOutput()); |
||
15 | |||
16 | $message = "usage at {$percentage}%"; |
||
17 | |||
18 | if ($percentage >= 90) { |
||
19 | $this->check->fail($message); |
||
20 | |||
21 | return; |
||
22 | } |
||
23 | |||
24 | if ($percentage >= 80) { |
||
25 | $this->check->warn($message); |
||
26 | |||
27 | return; |
||
28 | } |
||
29 | |||
30 | $this->check->succeed($message); |
||
31 | } |
||
32 | |||
33 | protected function getDiskUsagePercentage(string $commandOutput): int |
||
37 | } |
||
38 |