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.

64 lines
1.5 KiB

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