From f356574ea5b71810d80795c8402a6bffdcf41f50 Mon Sep 17 00:00:00 2001 From: SJ Date: Mon, 5 May 2014 16:00:33 +0200 Subject: [PATCH] stored counter stats --- src/defs.h | 2 +- src/import.c | 1 + src/misc.c | 2 +- src/session.c | 3 ++- src/store.c | 2 +- webui/controller/health/worker.php | 3 ++- webui/model/stat/counter.php | 8 ++++++-- webui/view/theme/default/templates/health/worker.tpl | 2 +- webui/view/theme/mobile/templates/health/worker.tpl | 2 +- 9 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/defs.h b/src/defs.h index ca40ebb1..3f49eacb 100644 --- a/src/defs.h +++ b/src/defs.h @@ -196,7 +196,7 @@ struct session_data { int direction; int tls; int spam_message; - int fd, hdr_len, tot_len, store_len, num_of_rcpt_to, rav; + int fd, hdr_len, tot_len, stored_len, num_of_rcpt_to, rav; int need_scan; float __acquire, __parsed, __av, __store, __compress, __encrypt; char bodydigest[2*DIGEST_LENGTH+1]; diff --git a/src/import.c b/src/import.c index 55bb2b76..66560630 100644 --- a/src/import.c +++ b/src/import.c @@ -111,6 +111,7 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da bzero(&counters, sizeof(counters)); counters.c_rcvd = 1; counters.c_size += sdata->tot_len; + counters.c_stored_size = sdata->stored_len; update_counters(sdata, data, &counters, cfg); break; diff --git a/src/misc.c b/src/misc.c index 1327acf9..7050b750 100644 --- a/src/misc.c +++ b/src/misc.c @@ -455,7 +455,7 @@ void init_session_data(struct session_data *sdata, struct __config *cfg){ sdata->hdr_len = 0; sdata->tot_len = 0; - sdata->store_len = 0; + sdata->stored_len = 0; sdata->num_of_rcpt_to = 0; sdata->ms_journal = 0; diff --git a/src/session.c b/src/session.c index 1e045317..688c1f9f 100644 --- a/src/session.c +++ b/src/session.c @@ -233,6 +233,7 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){ inj = process_message(&sdata, &sstate, data, cfg); unlink(sstate.message_id_hash); counters.c_size += sdata.tot_len; + counters.c_stored_size = sdata.stored_len; } } @@ -268,7 +269,7 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){ (sdata.__acquire+sdata.__parsed+sdata.__av+sdata.__compress+sdata.__encrypt+sdata.__store)/1000000.0, sdata.__acquire/1000000.0, sdata.__parsed/1000000.0, sdata.__av/1000000.0, sdata.__compress/1000000.0, sdata.__encrypt/1000000.0, sdata.__store/1000000.0); - syslog(LOG_PRIORITY, "%s: from=%s, size=%d/%d, attachments=%d, reference=%s, message-id=%s, retention=%d, %s, status=%s", sdata.ttmpfile, sdata.fromemail, sdata.tot_len, sdata.store_len, sstate.n_attachments, sstate.reference, sstate.message_id, sstate.retention, delay, status); + syslog(LOG_PRIORITY, "%s: from=%s, size=%d/%d, attachments=%d, reference=%s, message-id=%s, retention=%d, %s, status=%s", sdata.ttmpfile, sdata.fromemail, sdata.tot_len, sdata.stored_len, sstate.n_attachments, sstate.reference, sstate.message_id, sstate.retention, delay, status); diff --git a/src/store.c b/src/store.c index 7efc6f2f..1fa291d2 100644 --- a/src/store.c +++ b/src/store.c @@ -158,7 +158,7 @@ int store_file(struct session_data *sdata, char *filename, int startpos, int len if(n > 0 && n == writelen){ ret = 1; - sdata->store_len += writelen; + sdata->stored_len += writelen; if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: stored '%s' %d/%d bytes", sdata->ttmpfile, filename, len, writelen); } else { diff --git a/webui/controller/health/worker.php b/webui/controller/health/worker.php index ac6f4d58..eddb9bef 100644 --- a/webui/controller/health/worker.php +++ b/webui/controller/health/worker.php @@ -64,12 +64,13 @@ class ControllerHealthWorker extends Controller { $db = Registry::get('db'); $db->select_db($db->database); - list($archivesizeraw, $this->data['counters']) = $this->model_stat_counter->get_counters(); + list($archivesizeraw, $archivestoredsizeraw, $this->data['counters']) = $this->model_stat_counter->get_counters(); $oldest_record_timestamp = $this->model_health_health->get_oldest_record_ts(); $total_number_days = round( (time() - $this->model_health_health->get_first_email_arrival_ts()) / 86400 ); $this->data['archive_size'] = nice_size($archivesizeraw, ' '); + $this->data['archive_stored_size'] = nice_size($archivestoredsizeraw, ' '); $this->data['prefix'] = ''; if(isset($this->data['counters'][MEMCACHED_PREFIX . 'rcvd'])) { $this->data['prefix'] = MEMCACHED_PREFIX; } diff --git a/webui/model/stat/counter.php b/webui/model/stat/counter.php index 7eb3e53b..b3462d74 100644 --- a/webui/model/stat/counter.php +++ b/webui/model/stat/counter.php @@ -13,9 +13,11 @@ class ModelStatCounter extends Model { if(isset($counter[MEMCACHED_PREFIX . 'counters_last_update'])) { if(isset($counter[MEMCACHED_PREFIX . 'size'])) { $asize = $counter[MEMCACHED_PREFIX . 'size']; } + if(isset($counter[MEMCACHED_PREFIX . 'stored_size'])) { $ssize = $counter[MEMCACHED_PREFIX . 'stored_size']; } unset($counter[MEMCACHED_PREFIX . 'size']); + unset($counter[MEMCACHED_PREFIX . 'stored_size']); - return array ($asize, $counter); + return array ($asize, $ssize, $counter); } } @@ -23,13 +25,15 @@ class ModelStatCounter extends Model { if($query->num_rows == 1) { $asize = $query->row['size']; + $ssize = $query->row['stored_size']; unset($query->row['size']); + unset($query->row['stored_size']); $counter = $query->row; } - return array ($asize, $counter); + return array ($asize, $ssize, $counter); } diff --git a/webui/view/theme/default/templates/health/worker.tpl b/webui/view/theme/default/templates/health/worker.tpl index 632b5120..5339d3fd 100644 --- a/webui/view/theme/default/templates/health/worker.tpl +++ b/webui/view/theme/default/templates/health/worker.tpl @@ -40,7 +40,7 @@ - + diff --git a/webui/view/theme/mobile/templates/health/worker.tpl b/webui/view/theme/mobile/templates/health/worker.tpl index d1c6778f..34a6bf7f 100644 --- a/webui/view/theme/mobile/templates/health/worker.tpl +++ b/webui/view/theme/mobile/templates/health/worker.tpl @@ -31,7 +31,7 @@
-
B
+
B (B)
:BB (B)