From b8891360cc66bafded7d4d74f588ef8449f79509 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Sat, 14 Mar 2020 13:19:47 +0100 Subject: [PATCH] Fixed some health issues during the refactoring Signed-off-by: Janos SUTO --- webui/controller/health/worker.php | 1 + webui/model/health/health.php | 20 ++--- .../theme/default/templates/health/worker.tpl | 80 +++++++------------ 3 files changed, 40 insertions(+), 61 deletions(-) diff --git a/webui/controller/health/worker.php b/webui/controller/health/worker.php index 859c9022..cf619401 100644 --- a/webui/controller/health/worker.php +++ b/webui/controller/health/worker.php @@ -30,6 +30,7 @@ class ControllerHealthWorker extends Controller { } $this->model_health_health->collect_data(); + $this->data['health'] = $this->model_health_health->data; $this->render(); } diff --git a/webui/model/health/health.php b/webui/model/health/health.php index 998b6251..e5901d43 100644 --- a/webui/model/health/health.php +++ b/webui/model/health/health.php @@ -1,7 +1,7 @@ data['totalmem'], $this->data['meminfo'], $this->data['totalswap'], $this->data['swapinfo']) = $this->meminfo(); $this->data['shortdiskinfo'] = $this->diskinfo(); - list($archivesizeraw, $archivestoredsizeraw, $this->data['counters']) = $this->get_counters(); + list($archivesizeraw, $archivestoredsizeraw, $this->data['counters']) = $this->model_stat_counter->get_counters(); $this->data['archive_size'] = nice_size($archivesizeraw, ' '); $this->data['archive_stored_size'] = nice_size($archivestoredsizeraw, ' '); @@ -42,6 +42,8 @@ class ModelHealthHealth extends Model { $this->data['health'] = []; + $lang = Registry::get('language'); + foreach (Registry::get('health_smtp_servers') as $smtp) { if($smtp[0]) { $this->data['health'][] = $this->checksmtp($smtp, $lang->data['text_error']); @@ -55,10 +57,10 @@ class ModelHealthHealth extends Model { $this->data['processed_emails'] = $this->count_processed_emails(); // average messages per day, computed over the past week - $averagemessagesweekraw = ($this->data['processed_emails']['last_7_days_count']) / 7; + $this->data['averagemessagesweekraw'] = ($this->data['processed_emails']['last_7_days_count']) / 7; // average messages per day, computed over the past month - $averagemessagesmonthraw = ($this->data['processed_emails']['last_30_days_count']) / 30; + $this->data['averagemessagesmonthraw'] = ($this->data['processed_emails']['last_30_days_count']) / 30; //average messages per day, computed over the time period since the first email was archived $total_number_days = round( (time() - $this->get_first_email_arrival_ts()) / 86400 ); @@ -66,7 +68,7 @@ class ModelHealthHealth extends Model { $total_number_days = 1; } - $averagemessagestotalraw = $this->data['counters']['rcvd'] / $total_number_days; + $this->data['averagemessagestotalraw'] = $this->data['counters']['rcvd'] / $total_number_days; } @@ -85,7 +87,7 @@ class ModelHealthHealth extends Model { } // average total message size per day, computed over the time period since the first email was archived - $averagesizedayraw = ($averagemessagesizeraw + $averagesqlsizeraw + $averagesphinxsizeraw) * $averagemessagestotalraw; + $averagesizedayraw = ($averagemessagesizeraw + $averagesqlsizeraw + $averagesphinxsizeraw) * $this->data['averagemessagestotalraw']; $datapart = 0; foreach($this->data['shortdiskinfo'] as $part) { @@ -95,7 +97,7 @@ class ModelHealthHealth extends Model { } $this->data['oldestmessagets'] = $this->get_oldest_record_ts(); // date of the oldest record in the db - $this->data['averagemessages'] = round($averagemessagesweekraw); // rounded average of messages over the past week + $this->data['averagemessages'] = round($this->data['averagemessagesweekraw']); // rounded average of messages over the past week $this->data['averagemessagesize'] = nice_size($averagemessagesizeraw, ' '); // formatted average message size on disk $this->data['averagesqlsize'] = nice_size($averagesqlsizeraw, ' '); // formatted average metadata size in sql $this->data['averagesphinxsize'] = nice_size($averagesphinxsizeraw, ' '); // formatted average sphinx index @@ -110,9 +112,9 @@ class ModelHealthHealth extends Model { * increasing, decreasing, or neutral (only applies to message count, not size) */ - if ($averagemessagesweekraw > $averagemessagesmonthraw) { + if ($this->data['averagemessagesweekraw'] > $this->data['averagemessagesmonthraw']) { $this->data['usagetrend'] = 1; - } elseif($averagemessagesweekraw < $averagemessagesmonthraw) { + } elseif($this->data['averagemessagesweekraw'] < $this->data['averagemessagesmonthraw']) { $this->data['usagetrend'] = -1; } else { $this->data['usagetrend'] = 0; diff --git a/webui/view/theme/default/templates/health/worker.tpl b/webui/view/theme/default/templates/health/worker.tpl index 0a20c4e4..30ef75f4 100644 --- a/webui/view/theme/default/templates/health/worker.tpl +++ b/webui/view/theme/default/templates/health/worker.tpl @@ -4,38 +4,38 @@
-

-

Up For:

+

+

Up For:

- + - + - + - + - + - + @@ -45,14 +45,14 @@
Piler:
:
:
 %
 %
:
 % / MB
 % / MB
:
 % / MB
 % / MB
:
- + - + - - -
:B (B)B (B)
: - + @@ -69,7 +69,7 @@ - + - + @@ -109,21 +109,21 @@ - + - @@ -137,27 +137,27 @@
: - - . - : , : + . + : , : .
: , : : , :
- ()
- ()
- ()
- () + ()
+ ()
+ ()
+ ()
- + - + - + - + - + - SPHINX_MAIN_INDEX_THRESHOLD) { ?> class="text-error"> + SPHINX_MAIN_INDEX_THRESHOLD) { ?> class="text-error">
+ + + +
"" years, months, days years, months, days
0 ) { print $text_usage_increasing; } elseif( $usagetrend < 0 ) { print $text_usage_decreasing; } else { print $text_usage_neutral; } ?> 0) { print $text_usage_increasing; } elseif($health['usagetrend'] < 0) { print $text_usage_decreasing; } else { print $text_usage_neutral; } ?>
Sphinx main index
@@ -167,30 +167,6 @@ -
- -
- - - - -
- - -
- - - - - - -