mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 21:41:59 +01:00
Fixed some health issues during the refactoring
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
60b61ba225
commit
b8891360cc
@ -30,6 +30,7 @@ class ControllerHealthWorker extends Controller {
|
||||
}
|
||||
|
||||
$this->model_health_health->collect_data();
|
||||
$this->data['health'] = $this->model_health_health->data;
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
class ModelHealthHealth extends Model {
|
||||
$data = [];
|
||||
public $data = [];
|
||||
|
||||
public function collect_data() {
|
||||
ini_set("default_socket_timeout", 5);
|
||||
@ -17,7 +17,7 @@ class ModelHealthHealth extends Model {
|
||||
list($this->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;
|
||||
|
@ -4,38 +4,38 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="span8">
|
||||
<h2><i class="icon-dashboard icon-2x pull-left"></i><?php print $sysinfo[0]; ?> <small><?php print $text_status; ?></small></h2>
|
||||
<h3><strong>Up For:</strong> <?php print $uptime; ?></h3>
|
||||
<h2><i class="icon-dashboard icon-2x pull-left"></i><?php print $health['sysinfo'][0]; ?> <small><?php print $text_status; ?></small></h2>
|
||||
<h3><strong>Up For:</strong> <?php print $health['uptime']; ?></h3>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th class="span4">Piler:</th>
|
||||
<td class="span8"> <?php print $piler_version; ?></td>
|
||||
<td class="span8"> <?php print $health['piler_version']; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class="span4"><?php print $text_server_operating_system; ?>:</th>
|
||||
<td class="span8"> <?php print $sysinfo[1]; ?></td>
|
||||
<td class="span8"> <?php print $health['sysinfo'][1]; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><?php print $text_cpu_usage; ?>:</th>
|
||||
<td><div class="progress <?php if($cpuinfo < HEALTH_RATIO) { ?>progress-success<?php } else { ?>progress-danger<?php } ?>"><div class="bar" style="width: <?php print $cpuinfo; ?>%"></div> <?php print $cpuinfo; ?>% <?php print $cpuload; ?></div></td>
|
||||
<td><div class="progress <?php if($health['cpuinfo'] < HEALTH_RATIO) { ?>progress-success<?php } else { ?>progress-danger<?php } ?>"><div class="bar" style="width: <?php print $health['cpuinfo']; ?>%"></div> <?php print $health['cpuinfo']; ?>% <?php print $health['cpuload']; ?></div></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><?php print $text_memory_usage; ?>:</th>
|
||||
<td><div class="progress <?php if($meminfo < HEALTH_RATIO) { ?>progress-success<?php } else { ?>progress-danger<?php } ?>"><div class="bar" style="width: <?php print $meminfo; ?>%"></div> <?php print $meminfo; ?>% / <?php print $totalmem; ?> MB</div></td>
|
||||
<td><div class="progress <?php if($health['meminfo'] < HEALTH_RATIO) { ?>progress-success<?php } else { ?>progress-danger<?php } ?>"><div class="bar" style="width: <?php print $health['meminfo']; ?>%"></div> <?php print $health['meminfo']; ?>% / <?php print $health['totalmem']; ?> MB</div></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><?php print $text_swap_usage; ?>:</th>
|
||||
<td><div class="progress <?php if($swapinfo < HEALTH_RATIO) { ?>progress-success<?php } else { ?>progress-danger<?php } ?>"><div class="bar" style="width: <?php print $swapinfo; ?>%"></div> <?php print $swapinfo; ?>% / <?php print $totalswap; ?> MB</div></td>
|
||||
<td><div class="progress <?php if($health['swapinfo'] < HEALTH_RATIO) { ?>progress-success<?php } else { ?>progress-danger<?php } ?>"><div class="bar" style="width: <?php print $health['swapinfo']; ?>%"></div> <?php print $health['swapinfo']; ?>% / <?php print $health['totalswap']; ?> MB</div></td>
|
||||
</tr>
|
||||
|
||||
<?php if(ENABLE_SAAS == 1) { ?>
|
||||
<tr>
|
||||
<th class="span4"><?php print $text_online_users; ?>:</th>
|
||||
<td class="span8"><a href="index.php?route=stat/online"><?php print $num_of_online_users; ?></a></td>
|
||||
<td class="span8"><a href="index.php?route=stat/online"><?php print $health['num_of_online_users']; ?></a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
@ -45,14 +45,14 @@
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th><?php print $text_archive_size; ?>:</th>
|
||||
<td><?php print $archive_size; ?>B (<?php print $archive_stored_size; ?>B)</td>
|
||||
<td><?php print $health['archive_size']; ?>B (<?php print $health['archive_stored_size']; ?>B)</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><?php print $text_disk_usage; ?></th>
|
||||
<th><?php print $text_disk_usage; ?>:</th>
|
||||
<td>
|
||||
<table>
|
||||
<?php foreach($shortdiskinfo as $partition) { ?>
|
||||
<?php foreach($health['shortdiskinfo'] as $partition) { ?>
|
||||
|
||||
<tr class="<?php if($partition['utilization'] < HEALTH_RATIO) { ?>text-success<?php } else { ?>text-error<?php } ?>">
|
||||
<td><?php print $partition['partition']; ?></td>
|
||||
@ -69,7 +69,7 @@
|
||||
<tr>
|
||||
<th><?php print $text_smtp_status; ?>:</th>
|
||||
<td>
|
||||
<?php foreach($health as $h) {
|
||||
<?php foreach($health['health'] as $h) {
|
||||
if(preg_match("/^220/", $h[1])) {
|
||||
$status = 'OK'; $class = 'text-success';
|
||||
} else {
|
||||
@ -84,17 +84,17 @@
|
||||
<tr>
|
||||
<th><?php print $text_periodic_purge; ?></th>
|
||||
<td>
|
||||
<span class="<?php if($options['enable_purge'] == 1) { ?>ok<?php } else { ?>error<?php } ?>"><?php if($options['enable_purge'] == 1) { print $text_enabled; ?>. <a href="<?php print HEALTH_URL; ?>&toggle_enable_purge"><?php print $text_disable; ?></a>
|
||||
<?php if($purge_stat[0]) { print $text_last; ?>: <?php print $purge_stat[0]; ?>, <?php print $text_next; ?>: <?php print $purge_stat[1]; } ?>
|
||||
<span class="<?php if($health['options']['enable_purge'] == 1) { ?>ok<?php } else { ?>error<?php } ?>"><?php if($health['options']['enable_purge'] == 1) { print $text_enabled; ?>. <a href="<?php print HEALTH_URL; ?>&toggle_enable_purge"><?php print $text_disable; ?></a>
|
||||
<?php if($health['purge_stat'][0]) { print $text_last; ?>: <?php print $health['purge_stat'][0]; ?>, <?php print $text_next; ?>: <?php print $health['purge_stat'][1]; } ?>
|
||||
<?php } else { print $text_disabled; ?>. <a href="<?php print HEALTH_URL; ?>&toggle_enable_purge"><?php print $text_enable; ?></a><?php } ?>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if($indexer_stat[0]) { ?>
|
||||
<?php if($health['indexer_stat'][0]) { ?>
|
||||
<tr>
|
||||
<th><?php print $text_indexer_job; ?></th>
|
||||
<td><?php print $text_last; ?>: <?php print $indexer_stat[0]; ?>, <?php print $text_next; ?>: <?php print $indexer_stat[1]; ?></td>
|
||||
<td><?php print $text_last; ?>: <?php print $health['indexer_stat'][0]; ?>, <?php print $text_next; ?>: <?php print $health['indexer_stat'][1]; ?></td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@ -109,21 +109,21 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $text_oldest_record; ?></td>
|
||||
<td><?php print date(DATE_TEMPLATE, $oldestmessagets); ?></td>
|
||||
<td><?php print date(DATE_TEMPLATE, $health['oldestmessagets']); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $text_processed_emails; ?></td>
|
||||
<td>
|
||||
<?php print $processed_emails['last_60_mins_count']; ?> (<?php print $text_60_minutes; ?>)<br />
|
||||
<?php print $processed_emails['today_count']; ?> (<?php print $text_24_hours; ?>)<br />
|
||||
<?php print $processed_emails['last_7_days_count']; ?> (<?php print $text_1_week; ?>)<br />
|
||||
<?php print $processed_emails['last_30_days_count']; ?> (<?php print $text_30_days; ?>)
|
||||
<?php print $health['processed_emails']['last_60_mins_count']; ?> (<?php print $text_60_minutes; ?>)<br />
|
||||
<?php print $health['processed_emails']['today_count']; ?> (<?php print $text_24_hours; ?>)<br />
|
||||
<?php print $health['processed_emails']['last_7_days_count']; ?> (<?php print $text_1_week; ?>)<br />
|
||||
<?php print $health['processed_emails']['last_30_days_count']; ?> (<?php print $text_30_days; ?>)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="2"><?php print $text_message_disposition; ?></th>
|
||||
</tr>
|
||||
<?php while(list($k, $v) = each($counters)) {
|
||||
<?php while(list($k, $v) = each($health['counters'])) {
|
||||
if(!is_numeric($k)) { ?>
|
||||
<tr>
|
||||
<td><?php $a = preg_replace("/^_piler\:/", "", $k); if(isset($$a)) { print $$a; } else { print $k; } ?></td>
|
||||
@ -137,27 +137,27 @@
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<td><?php print $text_average_messages_day; ?></td>
|
||||
<td><?php print $averagemessages; ?></td>
|
||||
<td><?php print $health['averagemessages']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $text_average_message_size; ?></td>
|
||||
<td><?php print $averagemessagesize; ?> + <?php print $averagesqlsize; ?> + <?php print $averagesphinxsize; ?></td>
|
||||
<td><?php print $health['averagemessagesize']; ?> + <?php print $health['averagesqlsize']; ?> + <?php print $health['averagesphinxsize']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $text_average_size_day; ?></td>
|
||||
<td><?php print $averagesizeday; ?></td>
|
||||
<td><?php print $health['averagesizeday']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>"<?php print DATA_PARTITION; ?>" <?php print $text_partition_full; ?></td>
|
||||
<td><?php print $daysleftatcurrentrate[0]; ?> years, <?php print $daysleftatcurrentrate[1]; ?> months, <?php print $daysleftatcurrentrate[2]; ?> days</td>
|
||||
<td><?php print $health['daysleftatcurrentrate'][0]; ?> years, <?php print $health['daysleftatcurrentrate'][1]; ?> months, <?php print $health['daysleftatcurrentrate'][2]; ?> days</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $text_usage_trend; ?></td>
|
||||
<td><?php if ( $usagetrend > 0 ) { print $text_usage_increasing; } elseif( $usagetrend < 0 ) { print $text_usage_decreasing; } else { print $text_usage_neutral; } ?></td>
|
||||
<td><?php if ($health['usagetrend'] > 0) { print $text_usage_increasing; } elseif($health['usagetrend'] < 0) { print $text_usage_decreasing; } else { print $text_usage_neutral; } ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Sphinx main index</td>
|
||||
<td<?php if($sphinx_current_main_size > SPHINX_MAIN_INDEX_THRESHOLD) { ?> class="text-error"<?php } ?>><?php print nice_size($sphinx_current_main_size); ?></td>
|
||||
<td<?php if($health['sphinx_current_main_size'] > SPHINX_MAIN_INDEX_THRESHOLD) { ?> class="text-error"<?php } ?>><?php print nice_size($health['sphinx_current_main_size']); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -167,30 +167,6 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div id="health2">
|
||||
<?php if(isset($queues)) { ?>
|
||||
<tr>
|
||||
<th><?php print $text_queue_status; ?></div>
|
||||
</div>
|
||||
|
||||
<?php foreach ($queues as $queue) {
|
||||
|
||||
if(isset($queue['desc'])) { ?>
|
||||
|
||||
<tr>
|
||||
<th><?php print $queue['desc']; ?></div>
|
||||
</div>
|
||||
|
||||
<tr>
|
||||
<td><pre><?php print $queue['lines']; ?></pre></div>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user