Skip to content

Commit

Permalink
add debug information and purge reports every minute
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoriz committed Apr 14, 2018
1 parent 62b9a05 commit 098784d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions goiardi.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ func main() {
startReportPurge()
}

displayStats()

/* Create default clients and users. Currently chef-validator,
* chef-webui, and admin. */
createDefaultActors()
Expand Down Expand Up @@ -803,8 +805,7 @@ func startNodeMonitor() {

func startReportPurge() {
go func() {
// purge reports after 2 hours, I guess.
ticker := time.NewTicker(2 * time.Hour)
ticker := time.NewTicker(time.Second * time.Duration(60))
for _ = range ticker.C {
del, err := report.DeleteByAge(config.Config.PurgeReportsDur)
if err != nil {
Expand Down Expand Up @@ -835,6 +836,20 @@ func startNodeStatusPurge() {
}()
}

func displayStats() {
go func() {
ticker := time.NewTicker(time.Second * time.Duration(60))
for _ = range ticker.C {
logger.Debugf("Objects:")
logger.Debugf("Nodes: %d", node.Count())
logger.Debugf("NodeStatuses: %d", len(node.AllNodeStatuses()))
logger.Debugf("LogInfos: %d", len(loginfo.AllLogInfos()))
logger.Debugf("Reports: %d", len(report.AllReports()))
logger.Debugf("Sandboxes: %d", len(sandbox.AllSandboxes()))
}
}()
}

func initGeneralStatsd(metricsBackend met.Backend) {
if !config.Config.UseStatsd {
return
Expand Down

0 comments on commit 098784d

Please sign in to comment.