mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
storage: Calculate size of store for status page
This commit is contained in:
@@ -6,14 +6,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- Store size is now calculated during retention scan and displayed on the Status
|
||||
page.
|
||||
|
||||
### Changed
|
||||
- Massive refactor of back-end code. Inbucket should now be both easier and
|
||||
more enjoyable to work on.
|
||||
|
||||
|
||||
## [v1.3.1] - 2018-03-10
|
||||
|
||||
### Fixed
|
||||
|
||||
- Adding additional locking during message delivery to prevent race condition
|
||||
that could lose messages.
|
||||
|
||||
|
||||
@@ -18,14 +18,17 @@ var (
|
||||
expRetentionDeletesTotal = new(expvar.Int)
|
||||
expRetentionPeriod = new(expvar.Int)
|
||||
expRetainedCurrent = new(expvar.Int)
|
||||
expRetainedSize = new(expvar.Int)
|
||||
|
||||
// History of certain stats
|
||||
retentionDeletesHist = list.New()
|
||||
retainedHist = list.New()
|
||||
sizeHist = list.New()
|
||||
|
||||
// History rendered as comma delimited string
|
||||
expRetentionDeletesHist = new(expvar.String)
|
||||
expRetainedHist = new(expvar.String)
|
||||
expSizeHist = new(expvar.String)
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -36,10 +39,13 @@ func init() {
|
||||
rm.Set("Period", expRetentionPeriod)
|
||||
rm.Set("RetainedHist", expRetainedHist)
|
||||
rm.Set("RetainedCurrent", expRetainedCurrent)
|
||||
rm.Set("RetainedSize", expRetainedSize)
|
||||
rm.Set("SizeHist", expSizeHist)
|
||||
|
||||
log.AddTickerFunc(func() {
|
||||
expRetentionDeletesHist.Set(log.PushMetric(retentionDeletesHist, expRetentionDeletesTotal))
|
||||
expRetainedHist.Set(log.PushMetric(retainedHist, expRetainedCurrent))
|
||||
expSizeHist.Set(log.PushMetric(sizeHist, expRetainedSize))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -118,6 +124,7 @@ func (rs *RetentionScanner) DoScan() error {
|
||||
log.Tracef("Starting retention scan")
|
||||
cutoff := time.Now().Add(-1 * rs.retentionPeriod)
|
||||
retained := 0
|
||||
storeSize := int64(0)
|
||||
// Loop over all mailboxes.
|
||||
err := rs.ds.VisitMailboxes(func(messages []Message) bool {
|
||||
for _, msg := range messages {
|
||||
@@ -130,6 +137,7 @@ func (rs *RetentionScanner) DoScan() error {
|
||||
}
|
||||
} else {
|
||||
retained++
|
||||
storeSize += msg.Size()
|
||||
}
|
||||
}
|
||||
select {
|
||||
@@ -147,6 +155,7 @@ func (rs *RetentionScanner) DoScan() error {
|
||||
// Update metrics
|
||||
setRetentionScanCompleted(time.Now())
|
||||
expRetainedCurrent.Set(int64(retained))
|
||||
expRetainedSize.Set(storeSize)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ function displayMetrics(data, textStatus, jqXHR) {
|
||||
setHistoryOfActivity('retentionDeletesTotal', data.retention.DeletesHist);
|
||||
metric('retainedCurrent', data.retention.RetainedCurrent, numberFilter, false);
|
||||
setHistoryOfCount('retainedCurrent', data.retention.RetainedHist);
|
||||
metric('retainedSize', data.retention.RetainedSize, sizeFilter, false);
|
||||
setHistoryOfCount('retainedSize', data.retention.SizeHist);
|
||||
}
|
||||
|
||||
function loadMetrics() {
|
||||
|
||||
@@ -203,6 +203,12 @@ $(document).ready(
|
||||
<div class="col-sm-4"><span id="s-retainedCurrent"></span></div>
|
||||
<div class="col-sm-2 hidden-xs">(60min)</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3 col-xs-7"><b>Store Size:</b></div>
|
||||
<div class="col-sm-3 col-xs-5"><span id="m-retainedSize">.</span></div>
|
||||
<div class="col-sm-4"><span id="s-retainedSize"></span></div>
|
||||
<div class="col-sm-2 hidden-xs">(60min)</div>
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user