diff --git a/smtpd/listener.go b/smtpd/listener.go index 51c265f..2dd58b2 100644 --- a/smtpd/listener.go +++ b/smtpd/listener.go @@ -104,11 +104,12 @@ func metricsTicker(t *time.Ticker) { } } -// pushMetric adds the metric to the end of the list and returns a comma -// separated string of the previous 50 entries +// pushMetric adds the metric to the end of the list and returns a comma separated string of the +// previous 61 entries. We return 61 instead of 60 (an hour) because the chart on the client +// tracks deltas between these values - there is nothing to compare the first value against. func pushMetric(history *list.List, ev expvar.Var) string { history.PushBack(ev.String()) - if history.Len() > 50 { + if history.Len() > 61 { history.Remove(history.Front()) } return JoinStringList(history) diff --git a/smtpd/retention.go b/smtpd/retention.go index 0c6bc52..b9dd33a 100644 --- a/smtpd/retention.go +++ b/smtpd/retention.go @@ -13,6 +13,7 @@ var retentionScanCompleted time.Time var retentionScanCompletedMu sync.RWMutex var expRetentionDeletesTotal = new(expvar.Int) +var expRetentionPeriod = new(expvar.Int) // History of certain stats var retentionDeletesHist = list.New() @@ -22,6 +23,7 @@ var expRetentionDeletesHist = new(expvar.String) func StartRetentionScanner(ds DataStore) { cfg := config.GetDataStoreConfig() + expRetentionPeriod.Set(int64(cfg.RetentionMinutes * 60)) if cfg.RetentionMinutes > 0 { // Retention scanning enabled log.Info("Retention configured for %v minutes", cfg.RetentionMinutes) @@ -109,4 +111,5 @@ func init() { rm.Set("SecondsSinceScanCompleted", expvar.Func(secondsSinceRetentionScanCompleted)) rm.Set("DeletesHist", expRetentionDeletesHist) rm.Set("DeletesTotal", expRetentionDeletesTotal) + rm.Set("Period", expRetentionPeriod) } diff --git a/themes/integral/public/main.css b/themes/integral/public/main.css index 4dd6f14..f0e5bd4 100644 --- a/themes/integral/public/main.css +++ b/themes/integral/public/main.css @@ -325,7 +325,7 @@ table.metrics { } .metrics td.sparkline { - width: 170px; + width: 200px; } #emailAttachments { diff --git a/themes/integral/templates/root/status.html b/themes/integral/templates/root/status.html index efbb6c7..9a33b78 100644 --- a/themes/integral/templates/root/status.html +++ b/themes/integral/templates/root/status.html @@ -42,8 +42,8 @@ h = new Array(0) } // Prevent array from growing - if (h.length >= 50) { - h = h.slice(1,50) + if (h.length >= 60) { + h = h.slice(1,60) } h.push(parseInt(value)) dataHist[name] = h @@ -61,6 +61,10 @@ h[i] = t-prev prev = t } + // First value will always be zero + if (h.length > 0) { + h = h.slice(1) + } el = $('#s-' + name) if (el) { el.sparkline(h) @@ -86,6 +90,7 @@ // Non graphing metric('uptime', data.uptime, timeFilter, false) metric('retentionScanCompleted', data.retention.SecondsSinceScanCompleted, timeFilter, false) + metric('retentionPeriod', data.retention.Period, timeFilter, false) // JavaScript history metric('memstatsSys', data.memstats.Sys, sizeFilter, true) @@ -114,7 +119,7 @@ function aboutInit() { loadMetrics() - setInterval(loadMetrics, 5000) + setInterval(loadMetrics, 10000) } $(document).ready(aboutInit) @@ -131,9 +136,8 @@ {{define "content"}}

Inbucket Status

-

Metrics are polled every 5 seconds. Inbucket does not keep history for the -graphs labeled (5s), but your web browser will chart the last 50 -values over time.

+

Metrics are polled every 10 seconds. Inbucket does not keep history for the +10 minute graphs, but your web browser will accumulate the data over time.

General Metrics

@@ -146,25 +150,25 @@ values over time.

System Memory: . . - (5s) + (10min) Heap Size: . . - (5s) + (10min) Heap In-Use: . . - (5s) + (10min) Heap # Objects: . . - (5s) + (10min)

 

@@ -176,31 +180,31 @@ values over time.

Current Connections: . . - (5s) + (10min) Total Connections: . . - (60s) + (60min) Messages Delivered: . . - (60s) + (60min) Errors Logged: . - (60s) + (60min) Warnings Logged: . - (60s) + (60min)

 

@@ -208,15 +212,31 @@ values over time.

Data Store Metrics

+ + + + - + - +
Retention Period: + {{if .retentionMinutes}} + . + {{else}} + Disabled + {{end}} +
Retention Scan:Completed . ago + {{if .retentionMinutes}} + Completed . ago + {{else}} + Disabled + {{end}} +
Retention Deletes: . (60s)(60min)

 

diff --git a/web/root_controller.go b/web/root_controller.go index 53dd145..bcd83a7 100644 --- a/web/root_controller.go +++ b/web/root_controller.go @@ -1,6 +1,7 @@ package web import ( + "github.com/jhillyerd/inbucket/config" "net/http" ) @@ -11,7 +12,9 @@ func RootIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err erro } func RootStatus(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) { + retentionMinutes := config.GetDataStoreConfig().RetentionMinutes return RenderTemplate("root/status.html", w, map[string]interface{}{ "ctx": ctx, + "retentionMinutes": retentionMinutes, }) }