Umstellung auf GET Methoden
Zusammenfassen von Anfragen
This commit is contained in:
@@ -3,14 +3,12 @@ if (!defined('PICONTROL')) exit();
|
||||
|
||||
function rpi_getRuntime()
|
||||
{
|
||||
$runtime = trim(@shell_exec('cat /proc/uptime | awk -F \'.\' \'{print $1}\''));
|
||||
return $runtime;
|
||||
return trim(@shell_exec('cat /proc/uptime | awk -F \'.\' \'{print $1}\''));
|
||||
}
|
||||
|
||||
function rpi_getHostname()
|
||||
{
|
||||
$host = trim(@shell_exec('cat /proc/sys/kernel/hostname'));
|
||||
return $host;
|
||||
return trim(@shell_exec('cat /proc/sys/kernel/hostname'));
|
||||
}
|
||||
|
||||
function rpi_getHostAddr()
|
||||
@@ -75,28 +73,27 @@ function rpi_getCPUType()
|
||||
if (isset($match[1]))
|
||||
return $match[1];
|
||||
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
function rpi_getCpuModel()
|
||||
{
|
||||
$model = trim(@shell_exec('cat /proc/cpuinfo | grep -m 1 "Model" | cut -d ":" -f 2'));
|
||||
return $model;
|
||||
return trim(@shell_exec('cat /proc/cpuinfo | grep -m 1 "Model" | cut -d ":" -f 2'));
|
||||
}
|
||||
|
||||
function rpi_getCPULoad($accurate = false, $mulitcore = false)
|
||||
{
|
||||
$return = NULL;
|
||||
$return = null;
|
||||
|
||||
if ($accurate === true)
|
||||
$file = shell_exec('cat /proc/stat; sleep 2; echo "##--##"; cat /proc/stat');
|
||||
else
|
||||
$file = shell_exec('cat /proc/stat; sleep 0.5; echo "##--##"; cat /proc/stat');
|
||||
$file = shell_exec('cat /proc/stat; echo "##--##"; cat /proc/stat');
|
||||
|
||||
$file = explode('##--##', $file);
|
||||
|
||||
if (!isset($file[0], $file[1]))
|
||||
return NULL;
|
||||
return null;
|
||||
|
||||
preg_match_all('/^cpu[0-9]?(.*)$/im', $file[0], $prevCPUStrings);
|
||||
preg_match_all('/^cpu[0-9]?(.*)$/im', $file[1], $curCPUStrings);
|
||||
@@ -110,7 +107,7 @@ function rpi_getCPULoad($accurate = false, $mulitcore = false)
|
||||
|
||||
|
||||
if (!isset($prevCPU[0], $curCPU[1]) || count($prevCPU) != 11 || count($curCPU) != 11)
|
||||
return NULL;
|
||||
return null;
|
||||
|
||||
$prevIdle = $prevCPU[4] + $prevCPU[5];
|
||||
$curIdle = $curCPU[4] + $curCPU[5];
|
||||
@@ -124,7 +121,7 @@ function rpi_getCPULoad($accurate = false, $mulitcore = false)
|
||||
$total = $curTotal - $prevTotal;
|
||||
$idle = $curIdle - $prevIdle;
|
||||
|
||||
if ($mulitcore == true)
|
||||
if ($mulitcore)
|
||||
$return[$prevCPU[0]] = (int) round(($total - $idle) / $total * 100);
|
||||
else
|
||||
$return = (int) round(($total - $idle) / $total * 100);
|
||||
@@ -153,20 +150,17 @@ function rpi_getDistribution()
|
||||
|
||||
function rpi_getKernelVersion()
|
||||
{
|
||||
$kernel = trim(@shell_exec('cat /proc/version | cut -d " " -f 1,3'));
|
||||
return $kernel;
|
||||
return trim(@shell_exec('cat /proc/version | cut -d " " -f 1,3'));
|
||||
}
|
||||
|
||||
function rpi_getCountRunningTasks()
|
||||
{
|
||||
$tasks = trim(@shell_exec('ps -auxeaf| wc -l'));
|
||||
return $tasks;
|
||||
return trim(@shell_exec('ps -auxeaf| wc -l'));
|
||||
}
|
||||
|
||||
function rpi_getCountInstalledPackages()
|
||||
{
|
||||
$packages = trim(@shell_exec('dpkg --get-selections | grep -v deinstall | wc -l'));
|
||||
return $packages;
|
||||
return trim(@shell_exec('dpkg --get-selections | grep -v deinstall | wc -l'));
|
||||
}
|
||||
|
||||
function rpi_getInstalledPackages()
|
||||
|
||||
Reference in New Issue
Block a user