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.
 
 
 

68 lines
1.7 KiB

<?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);
}
}