From af98d47ab122fdc8fe01557b8736be06874989d9 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sat, 25 Apr 2020 20:15:41 +0200 Subject: Minor tweaks and cleanups --- modules-available/statistics/api.inc.php | 19 +++++++++++-------- modules-available/statistics/hooks/cron.inc.php | 6 +++--- modules-available/statistics/pages/list.inc.php | 3 --- modules-available/statistics/pages/summary.inc.php | 3 --- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index af773a61..b8ef2eb1 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -45,9 +45,9 @@ if ($type{0} === '~') { if ($macaddr === false) die("No/Invalid MAC address.\n"); if ($uptime < 0 || $uptime > 4000000) die("Implausible uptime.\n"); $realcores = Request::post('realcores', 0, 'integer'); - if ($realcores < 0 || $realcores > 512) $realcores = 0; + if ($realcores < 0 || $realcores > 1024) $realcores = 0; $mbram = Request::post('mbram', 0, 'integer'); - if ($mbram < 0 || $mbram > 2048000) $mbram = 0; + if ($mbram < 0 || $mbram > 4096000) $mbram = 0; $kvmstate = Request::post('kvmstate', 'UNKNOWN', 'string'); $valid = array('UNKNOWN', 'UNSUPPORTED', 'DISABLED', 'ENABLED'); if (!in_array($kvmstate, $valid)) $kvmstate = 'UNKNOWN'; @@ -152,13 +152,13 @@ if ($type{0} === '~') { // Log potential crash if ($old['state'] === 'IDLE' || $old['state'] === 'OCCUPIED') { writeClientLog('machine-mismatch-poweron', 'Poweron event, but previous known state is ' . $old['state'] - . '. RAM: ' . Util::readableFileSize($old['live_memfree'], -1, 2) - . ', Swap: ' . Util::readableFileSize($old['live_swapfree'], -1, 2) - . ', ID44: ' . Util::readableFileSize($old['live_tmpfree'], -1, 2)); + . '. Free RAM: ' . Util::readableFileSize($old['live_memfree'], -1, 2) + . ', free Swap: ' . Util::readableFileSize($old['live_swapfree'], -1, 2) + . ', free ID44: ' . Util::readableFileSize($old['live_tmpfree'], -1, 2)); } } - // Inform WOL (rebootcontrol) module about subnet size + // Inform WOL (rebootcontrol) module about subnet size (TODO: Use upcoming hook) if (Module::get('rebootcontrol') !== false) { $subnet = Request::post('subnet', false, 'string'); if ($subnet !== false && ($subnet = explode('/', $subnet)) !== false && count($subnet) === 2 @@ -216,8 +216,11 @@ if ($type{0} === '~') { } } foreach (['memsize', 'tmpsize', 'swapsize', 'memfree', 'tmpfree', 'swapfree'] as $item) { - $strUpdateBoottime .= ' live_' . $item . ' = :_' . $item . ', '; - $params['_' . $item] = ceil(Request::post($item, 0, 'int') / 1024); + $liveVal = Request::post($item, false, 'int'); + if ($liveVal !== false) { + $strUpdateBoottime .= ' live_' . $item . ' = :_' . $item . ', '; + $params['_' . $item] = ceil($liveVal / 1024); + } } // Figure out what's happening - state changes if ($used === 0 && $old['state'] !== 'IDLE') { diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php index 6393b2c6..8db6b79c 100644 --- a/modules-available/statistics/hooks/cron.inc.php +++ b/modules-available/statistics/hooks/cron.inc.php @@ -32,9 +32,9 @@ function state_cleanup() 'type' => 'machine-mismatch-cron', 'client' => $row['clientip'], 'description' => 'Client timed out, last known state is ' . $row['state'] - . '. RAM: ' . Util::readableFileSize($row['live_memfree'], -1, 2) - . ', Swap: ' . Util::readableFileSize($row['live_swapfree'], -1, 2) - . ', ID44: ' . Util::readableFileSize($row['live_tmpfree'], -1, 2), + . '. Free RAM: ' . Util::readableFileSize($row['live_memfree'], -1, 2) + . ', free Swap: ' . Util::readableFileSize($row['live_swapfree'], -1, 2) + . ', free ID44: ' . Util::readableFileSize($row['live_tmpfree'], -1, 2), 'longdesc' => '', 'uuid' => $row['machineuuid'], )); diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php index cb938d03..2dab152d 100644 --- a/modules-available/statistics/pages/list.inc.php +++ b/modules-available/statistics/pages/list.inc.php @@ -10,9 +10,6 @@ class SubPage public static function doRender() { - $sortColumn = Request::any('sortColumn'); - $sortDirection = Request::any('sortDirection'); - $filters = StatisticsFilter::parseQuery(); $filterSet = new StatisticsFilterSet($filters); diff --git a/modules-available/statistics/pages/summary.inc.php b/modules-available/statistics/pages/summary.inc.php index ead62a26..6fa37c61 100644 --- a/modules-available/statistics/pages/summary.inc.php +++ b/modules-available/statistics/pages/summary.inc.php @@ -12,9 +12,6 @@ class SubPage public static function doRender() { - $sortColumn = Request::any('sortColumn'); - $sortDirection = Request::any('sortDirection'); - $filters = StatisticsFilter::parseQuery(); $filterSet = new StatisticsFilterSet($filters); -- cgit v1.2.3-55-g7522