From 54e7c8a97138eb362681477935986b95cc8316ce Mon Sep 17 00:00:00 2001 From: DanB Date: Wed, 13 Aug 2014 18:05:05 +0200 Subject: [PATCH] Adding cdrstats metrics to email and log actions --- engine/action.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/action.go b/engine/action.go index 4584d7748..f8f4e5a0e 100644 --- a/engine/action.go +++ b/engine/action.go @@ -117,7 +117,7 @@ func logAction(ub *Account, sq *StatsQueue, a *Action) (err error) { Logger.Info(fmt.Sprintf("Threshold hit, Balance: %s", body)) } if sq != nil { - Logger.Info(fmt.Sprintf("Threshold hit, StatsQueueId: %s", sq.GetId())) + Logger.Info(fmt.Sprintf("Threshold hit, StatsQueueId: %s, Metrics: %+v", sq.GetId(), sq.getStats())) } return } @@ -334,7 +334,7 @@ func mailAsync(ub *Account, sq *StatsQueue, a *Action) error { } message = []byte(fmt.Sprintf("To: %s\r\nSubject: [CGR Notification] Threshold hit on Balance: %s\r\n\r\nTime: \r\n\t%s\r\n\r\nBalance:\r\n\t%s\r\n\r\nYours faithfully,\r\nCGR Balance Monitor\r\n", toAddrStr, ub.Id, time.Now(), balJsn)) } else if sq != nil { - message = []byte(fmt.Sprintf("To: %s\r\nSubject: [CGR Notification] Threshold hit on StatsQueueId: %s\r\n\r\nTime: \r\n\t%s\r\n\r\nStatsQueueId:\r\n\t%s\r\n\r\nYours faithfully,\r\nCGR CDR Stats Monitor\r\n", toAddrStr, sq.GetId(), time.Now(), sq.GetId())) + message = []byte(fmt.Sprintf("To: %s\r\nSubject: [CGR Notification] Threshold hit on StatsQueueId: %s\r\n\r\nTime: \r\n\t%s\r\n\r\nStatsQueueId:\r\n\t%s\r\n\r\nMetrics:\r\n\t%+v\r\n\r\nYours faithfully,\r\nCGR CDR Stats Monitor\r\n", toAddrStr, sq.GetId(), time.Now(), sq.GetId(), sq.getStats())) } auth := smtp.PlainAuth("", cgrCfg.MailerAuthUser, cgrCfg.MailerAuthPass, strings.Split(cgrCfg.MailerServer, ":")[0]) // We only need host part, so ignore port go func() {