| Conditions | 5 |
| Paths | 5 |
| Total Lines | 34 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | private function getServices(): array |
||
| 18 | { |
||
| 19 | $process = Runner::run("systemctl list-units --type=service --all --no-legend | awk '{print $1}'"); |
||
| 20 | |||
| 21 | if ($process->getExitCode() !== Command::SUCCESS) { |
||
| 22 | return []; |
||
| 23 | } |
||
| 24 | |||
| 25 | $output = $process->getOutput(); |
||
| 26 | |||
| 27 | if (!$output) { |
||
| 28 | return []; |
||
| 29 | } |
||
| 30 | |||
| 31 | $services = []; |
||
| 32 | $units = explode("\n", trim($output)); |
||
| 33 | |||
| 34 | foreach ($units as $unit) { |
||
| 35 | if (empty($unit)) continue; |
||
| 36 | |||
| 37 | $id = trim(Runner::run("systemctl show $unit --property=Id --value")->getOutput()); |
||
| 38 | $description = trim(Runner::run("systemctl show $unit --property=Description --value")->getOutput()); |
||
| 39 | $activeState = trim(Runner::run("systemctl show $unit --property=ActiveState --value")->getOutput()); |
||
| 40 | $subState = trim(Runner::run("systemctl show $unit --property=SubState --value")->getOutput()); |
||
| 41 | |||
| 42 | $services[] = [ |
||
| 43 | 'Id' => $id, |
||
| 44 | 'Description' => $description, |
||
| 45 | 'ActiveState' => $activeState, |
||
| 46 | 'SubState' => $subState, |
||
| 47 | ]; |
||
| 48 | } |
||
| 49 | |||
| 50 | return $services; |
||
| 51 | } |
||
| 54 |