OpenSource CLI-App to install and handle stuff related to Web-Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB

4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\Commands;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use LaravelZero\Framework\Commands\Command;
  5. use Log;
  6. class MonitoringStateCommand extends Command
  7. {
  8. /**
  9. * The signature of the command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'monitoring:state';
  14. /**
  15. * The description of the command.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'I';
  20. /**
  21. * Execute the console command.
  22. *
  23. * @return mixed
  24. */
  25. public function handle()
  26. {
  27. // getting harddisks
  28. exec('df -H | grep \'^/dev\'', $harddisks);
  29. //
  30. exec('$(apt list --upgradable 2>/dev/null | grep "\-security" | wc -l)', $securityUpgrades);
  31. if (isset($securityUpgrades[0]) && intval($securityUpgrades[0]) > 0) {
  32. exec('apt list --upgradable 2>/dev/null | grep "\-security"', $securityUpgrades);
  33. // remove listening
  34. if (isset($securityUpgrades[1])) {
  35. unset($securityUpgrades[1]);
  36. }
  37. }
  38. // getting info of files
  39. exec('echo $(apt list --upgradable 2>/dev/null | grep -v "\-security" | wc -l)', $upgrades);
  40. if (isset($upgrades[0]) && intval($upgrades[0]) > 0) {
  41. exec('apt list --upgradable 2>/dev/null | grep -v "\-security"', $upgrades);
  42. // remove listening
  43. if (isset($upgrades[1])) {
  44. unset($upgrades[1]);
  45. }
  46. }
  47. $result = implode("\n", $upgrades);
  48. }
  49. }