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.

67 lines
1.7 KiB

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