|
|
- <?php
-
- namespace App\Commands;
-
- use Illuminate\Console\Scheduling\Schedule;
- use LaravelZero\Framework\Commands\Command;
-
- /**
- * get count of updates and state of hardisks
- *
- * @author Björn Hase, Tentakelfabrik
- * @license http://opensource.org/licenses/MIT The MIT License
- * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
- *
- */
- class MonitoringStateCommand extends Command
- {
- /**
- * The signature of the command.
- *
- * @var string
- */
- protected $signature = 'monitoring:state';
-
- /**
- * The description of the command.
- *
- * @var string
- */
- protected $description = 'I';
-
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- // getting harddisks
- exec('df -H | grep \'^/dev\'', $harddisks);
-
- //
- exec('$(apt list --upgradable 2>/dev/null | grep "\-security" | wc -l)', $securityUpgrades);
-
- if (isset($securityUpgrades[0]) && intval($securityUpgrades[0]) > 0) {
- exec('apt list --upgradable 2>/dev/null | grep "\-security"', $securityUpgrades);
-
- // remove listening
- if (isset($securityUpgrades[1])) {
- unset($securityUpgrades[1]);
- }
- }
-
- // getting info of files
- exec('echo $(apt list --upgradable 2>/dev/null | grep -v "\-security" | wc -l)', $upgrades);
-
- if (isset($upgrades[0]) && intval($upgrades[0]) > 0) {
- exec('apt list --upgradable 2>/dev/null | grep -v "\-security"', $upgrades);
-
- // remove listening
- if (isset($upgrades[1])) {
- unset($upgrades[1]);
- }
- }
-
- $result = implode("\n", $upgrades);
- }
- }
|