mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 19:00:11 +01:00
health fix
This commit is contained in:
parent
ea9da966ff
commit
5247e2dfe9
14
src/config.h
14
src/config.h
@ -43,18 +43,18 @@
|
||||
#define CRLF "\n"
|
||||
|
||||
|
||||
#define MEMCACHED_CLAPF_PREFIX "_piler"
|
||||
#define MEMCACHED_CLAPF_PREFIX "_piler:"
|
||||
#define MAX_MEMCACHED_KEY_LEN 250
|
||||
|
||||
#define MEMCACHED_SUCCESS 0
|
||||
#define MEMCACHED_FAILURE 1
|
||||
|
||||
#define MEMCACHED_COUNTERS_LAST_UPDATE MEMCACHED_CLAPF_PREFIX ":counters_last_update"
|
||||
#define MEMCACHED_MSGS_RCVD MEMCACHED_CLAPF_PREFIX ":rcvd"
|
||||
#define MEMCACHED_MSGS_VIRUS MEMCACHED_CLAPF_PREFIX ":virus"
|
||||
#define MEMCACHED_MSGS_DUPLICATE MEMCACHED_CLAPF_PREFIX ":duplicate"
|
||||
#define MEMCACHED_MSGS_IGNORE MEMCACHED_CLAPF_PREFIX ":ignore"
|
||||
#define MEMCACHED_MSGS_SIZE MEMCACHED_CLAPF_PREFIX ":size"
|
||||
#define MEMCACHED_COUNTERS_LAST_UPDATE MEMCACHED_CLAPF_PREFIX "counters_last_update"
|
||||
#define MEMCACHED_MSGS_RCVD MEMCACHED_CLAPF_PREFIX "rcvd"
|
||||
#define MEMCACHED_MSGS_VIRUS MEMCACHED_CLAPF_PREFIX "virus"
|
||||
#define MEMCACHED_MSGS_DUPLICATE MEMCACHED_CLAPF_PREFIX "duplicate"
|
||||
#define MEMCACHED_MSGS_IGNORE MEMCACHED_CLAPF_PREFIX "ignore"
|
||||
#define MEMCACHED_MSGS_SIZE MEMCACHED_CLAPF_PREFIX "size"
|
||||
|
||||
|
||||
#define LOG_PRIORITY LOG_INFO
|
||||
|
@ -143,14 +143,14 @@ define('MIN_PASSWORD_LENGTH', 6);
|
||||
define('CGI_INPUT_FIELD_WIDTH', 50);
|
||||
define('CGI_INPUT_FIELD_HEIGHT', 7);
|
||||
|
||||
define('MEMCACHED_PREFIX', '_piler_webui:');
|
||||
define('MEMCACHED_PREFIX', '_piler:');
|
||||
define('MEMCACHED_TTL', 3600);
|
||||
|
||||
$memcached_servers = array(
|
||||
array('127.0.0.1', 11211)
|
||||
);
|
||||
|
||||
$counters = array('_piler:rcvd', '_piler:virus', '_piler:duplicate', '_piler:ignore', '_piler:counters_last_update');
|
||||
$counters = array(MEMCACHED_PREFIX . 'rcvd', MEMCACHED_PREFIX . 'virus', MEMCACHED_PREFIX . 'duplicate', MEMCACHED_PREFIX . 'ignore', MEMCACHED_PREFIX . 'counters_last_update');
|
||||
|
||||
$health_smtp_servers = array( array(PILER_HOST, PILER_PORT, "piler"), array(SMARTHOST, SMARTHOST_PORT, "smarthost") );
|
||||
|
||||
|
@ -31,32 +31,17 @@ class ControllerHealthWorker extends Controller {
|
||||
}
|
||||
|
||||
|
||||
/*$this->data['queues'][] = format_qshape($lang->data['text_active_incoming_queue'], QSHAPE_ACTIVE_INCOMING);
|
||||
$this->data['queues'][] = format_qshape($lang->data['text_deferred_queue'], QSHAPE_DEFERRED);*/
|
||||
|
||||
/*if(file_exists(QSHAPE_ACTIVE_INCOMING_OUT)) {
|
||||
$this->data['queues_out'][] = format_qshape($lang->data['text_active_incoming_queue'], QSHAPE_ACTIVE_INCOMING_OUT);
|
||||
$this->data['queues_out'][] = format_qshape($lang->data['text_deferred_queue'], QSHAPE_DEFERRED_OUT);
|
||||
}*/
|
||||
|
||||
$this->data['processed_emails'] = $this->model_health_health->count_processed_emails();
|
||||
|
||||
list ($this->data['uptime'], $this->data['cpuload']) = $this->model_health_health->uptime();
|
||||
|
||||
$this->data['cpuinfo'] = 100 - (int)file_get_contents(CPUSTAT);
|
||||
$this->data['archive_size'] = (int)file_get_contents(ARCHIVE_SIZE);
|
||||
|
||||
$this->data['quarantinereportinfo'] = @file_get_contents(DAILY_QUARANTINE_REPORT_STAT);
|
||||
|
||||
list($this->data['totalmem'], $this->data['meminfo'], $this->data['totalswap'], $this->data['swapinfo']) = $this->model_health_health->meminfo();
|
||||
$this->data['shortdiskinfo'] = $this->model_health_health->diskinfo();
|
||||
|
||||
/*if(file_exists(MAILLOG_PID_FILE)) {
|
||||
$this->data['maillog_status'] = $lang->data['text_running'];
|
||||
} else {
|
||||
$this->data['maillog_status'] = $lang->data['text_not_running'];
|
||||
}*/
|
||||
|
||||
|
||||
if(ENABLE_LDAP_IMPORT_FEATURE == 1) {
|
||||
$this->data['adsyncinfo'] = @file_get_contents(AD_SYNC_STAT);
|
||||
@ -86,9 +71,10 @@ class ControllerHealthWorker extends Controller {
|
||||
}
|
||||
|
||||
|
||||
$this->data['counters'] = $this->model_stat_counter->getCounters();
|
||||
list($this->data['archive_size'], $this->data['counters']) = $this->model_stat_counter->getCounters();
|
||||
|
||||
$this->data['prefix'] = '';
|
||||
if(isset($this->data['counters']['_c:rcvd'])) { $this->data['prefix'] = '_c:'; }
|
||||
if(isset($this->data['counters'][MEMCACHED_PREFIX . 'rcvd'])) { $this->data['prefix'] = MEMCACHED_PREFIX; }
|
||||
|
||||
$this->data['sysinfo'] = $this->model_health_health->sysinfo();
|
||||
|
||||
|
@ -4,22 +4,31 @@ class ModelStatCounter extends Model {
|
||||
|
||||
public function getCounters(){
|
||||
$counter = array();
|
||||
$asize = 0;
|
||||
|
||||
if(MEMCACHED_ENABLED) {
|
||||
$memcache = Registry::get('memcache');
|
||||
|
||||
$counter = $memcache->get(Registry::get('counters'));
|
||||
|
||||
if(isset($counter['_c:counters_last_update'])) { return $counter; }
|
||||
if(isset($counter[MEMCACHED_PREFIX . 'counters_last_update'])) {
|
||||
$asize = nice_size($counter[MEMCACHED_PREFIX . 'size'], ' ');
|
||||
unset($counter[MEMCACHED_PREFIX . 'size']);
|
||||
|
||||
return array ($asize, $counter);
|
||||
}
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . TABLE_COUNTER);
|
||||
|
||||
if($query->num_rows == 1) {
|
||||
$asize = nice_size($query->row['size'], ' ');
|
||||
unset($query->row['size']);
|
||||
|
||||
$counter = $query->row;
|
||||
}
|
||||
|
||||
return $counter;
|
||||
return array ($asize, $counter);
|
||||
}
|
||||
|
||||
|
||||
|
@ -297,7 +297,7 @@ class ModelUserUser extends Model {
|
||||
|
||||
if(MEMCACHED_ENABLED) {
|
||||
$memcache = Registry::get('memcache');
|
||||
$memcache->delete("_c:" . $email);
|
||||
$memcache->delete(MEMCACHED_PREFIX . $email);
|
||||
}
|
||||
|
||||
if($query->row['count'] > 0) {
|
||||
@ -394,7 +394,7 @@ class ModelUserUser extends Model {
|
||||
|
||||
if(MEMCACHED_ENABLED) {
|
||||
$memcache = Registry::get('memcache');
|
||||
$memcache->delete("_c:" . $email);
|
||||
$memcache->delete(MEMCACHED_PREFIX . $email);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="cellhealthleft"><?php print $text_archive_size; ?>:</div>
|
||||
<div class="cellhealthright"><?php print $archive_size; ?> MB</div>
|
||||
<div class="cellhealthright"><?php print $archive_size; ?>B</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
@ -1,131 +0,0 @@
|
||||
<table border="0" cellpadding="10">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
|
||||
<p><?php print $text_refresh_period; ?>: <?php print HEALTH_REFRESH; ?> sec</p>
|
||||
|
||||
<p><strong><?php print $text_server_name; ?>: </strong><?php print $sysinfo[0]; ?></p>
|
||||
|
||||
<p><strong><?php print $text_server_operating_system; ?>: </strong><?php print $sysinfo[1]; ?></p>
|
||||
|
||||
<p><strong><?php print $text_uptime; ?>: </strong><?php print $uptime; ?></p>
|
||||
|
||||
<p><strong><?php print $text_archive_size; ?>: </strong><?php print $archive_size; ?> MB</p>
|
||||
|
||||
<p><strong><?php print $text_processed_emails_in; ?>:</strong> <?php print $processed_emails[0]; ?>/<?php print $processed_emails[1]; ?>/<?php print $processed_emails[2]; ?></p>
|
||||
|
||||
<!--p><strong><?php print $text_smtp_status; ?>: </strong></p>
|
||||
|
||||
<p>
|
||||
<table border="1">
|
||||
<?php foreach($health as $h) {
|
||||
$status = 'ERROR';
|
||||
if(preg_match("/^220/", $h[1]) || preg_match("/^action=DUNNO/", $h[1])) { $status = 'OK'; }
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php print $h[3]; ?></td>
|
||||
<td class="<?php if($status == 'OK') { ?>health-ok<?php } else { ?>health-alert<?php } ?>"><span onmouseover="Tip('<?php print preg_replace("/\'/", "\'", $h[1]); ?>, <?php print $h[2]; ?>', BALLOON, true, ABOVE,
|
||||
true)" onmouseout="UnTip()"><?php print $status; ?></span></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<?php if(MAILLOG_PID_FILE) { ?><p><strong><?php print $text_maillog_status; ?>:</strong> <span class="health-<?php if($maillog_status == $text_running) { ?>ok<?php } else { ?>alert<?php } ?>"><?php print $maillog_status; ?></span><?php } ?>
|
||||
|
||||
<?php if(ENABLE_LDAP_IMPORT_FEATURE == 1) { ?><p><strong><?php print $text_ad_sync_status; ?>:</strong> <span class="health-<?php if($totalusers >= LDAP_IMPORT_MINIMUM_NUMBER_OF_USERS_TO_HEALTH_OK && $total_emails_in_database >= LDAP_IMPORT_MINIMUM_NUMBER_OF_USERS_TO_HEALTH_OK) { ?>ok<?php } else { ?>alert<?php } ?>"><?php print $adsyncinfo; ?> <?php print strtolower($text_email); ?></span></p><?php } ?>
|
||||
|
||||
<?php if(file_exists(DAILY_QUARANTINE_REPORT_STAT)) { ?><p><strong><?php print $text_daily_quarantine_report_status; ?>:</strong> <span class="health-<?php if(preg_match("/\/0$/", $quarantinereportinfo) && !preg_match("/ 0\//", $quarantinereportinfo) ) { ?>ok<?php } else { ?>alert<?php } ?>"><?php print $quarantinereportinfo; ?></span></p><?php } ?>
|
||||
-->
|
||||
|
||||
|
||||
<p><strong><?php print $text_cpu_usage; ?>:</strong> <span class="health-<?php if($cpuinfo < HEALTH_RATIO) { ?>ok<?php } else { ?>alert<?php } ?>"><?php print $cpuinfo; ?>%</span>, <strong><?php print $text_cpu_load; ?>:</strong> <span class="health-<?php if($cpuinfo < HEALTH_RATIO) { ?>ok<?php } else { ?>alert<?php } ?>"><?php print $cpuload; ?></span></p>
|
||||
|
||||
<p><strong><?php print $text_memory_usage; ?>: </strong> <span class="health-<?php if($meminfo < HEALTH_RATIO) { ?>ok<?php } else { ?>alert<?php } ?>"><?php print $meminfo; ?>%</span> / <?php print $totalmem; ?> MB, <strong><?php print $text_swap_usage; ?></strong>: <span class="health-<?php if($swapinfo < HEALTH_RATIO) { ?>ok<?php } else { ?>alert<?php } ?>"><?php print $swapinfo; ?>%</span> / <?php print $totalswap; ?> MB</p>
|
||||
|
||||
<p><strong><?php print $text_disk_usage; ?>: </strong> <?php foreach($shortdiskinfo as $partition) { ?><span class="health-<?php if($partition['utilization'] < HEALTH_RATIO) { ?>ok<?php } else { ?>alert<?php } ?>"><?php print $partition['partition']; ?> <?php print $partition['utilization']; ?>%</span> <?php } ?></p>
|
||||
|
||||
<p><strong><?php print $text_counters; ?>:</strong></p>
|
||||
|
||||
<p>
|
||||
<table border="1">
|
||||
<?php while(list($k, $v) = each($counters)) {
|
||||
if(!is_numeric($k)) { ?>
|
||||
<tr><td><?php $a = preg_replace("/^_piler\:/", "", $k); if(isset($$a)) { print $$a; } else { print $k; } ?></td><td><?php print $v; ?></td></tr>
|
||||
<?php } } ?>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<?php if(Registry::get('admin_user') == 1) { ?>
|
||||
<form action="index.php?route=health/worker" method="post">
|
||||
<input type="hidden" name="resetcounters" value="1" />
|
||||
<input type="submit" name="submit" value="<?php print $text_reset_counters; ?>" />
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<h4><?php print $text_queue_status; ?>: </h4>
|
||||
|
||||
<?php foreach ($queues as $queue) { ?>
|
||||
|
||||
<p class="queue"><table class="queue" border="0">
|
||||
|
||||
<?php if(isset($queue['desc'])) { ?>
|
||||
|
||||
<tr><td colspan="12"><strong><?php print $queue['desc']; ?></strong></td></tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
while(list($k, $v) = each($queue['lines'])) {
|
||||
$i++;
|
||||
print "<tr class='queue'>";
|
||||
$v = preg_replace("/^\*\<\/td\>/", "", $v);
|
||||
if($i == 1) { print "<td> </td>"; }
|
||||
print "$v</td></tr>\n";
|
||||
if($i == count($queue['lines'])-1) { break; }
|
||||
}
|
||||
?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</table></p>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if(isset($queues_out)) { ?>
|
||||
|
||||
<h4><?php print $text_queue_out_status; ?>: </h4>
|
||||
|
||||
<?php foreach ($queues_out as $queue) { ?>
|
||||
|
||||
<p class="queue"><table class="queue" border="0">
|
||||
|
||||
<?php if(isset($queue['desc'])) { ?>
|
||||
<tr><td colspan="12"><strong><?php print $queue['desc']; ?></strong></td></tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
while(list($k, $v) = each($queue['lines'])) {
|
||||
$i++;
|
||||
print "<tr class='queue'>";
|
||||
$v = preg_replace("/^\*\<\/td\>/", "", $v);
|
||||
if($i == 1) { print "<td> </td>"; }
|
||||
print "$v</td></tr>\n";
|
||||
if($i == count($queue['lines'])-1) { break; }
|
||||
}
|
||||
?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</table></p>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user