Skip to content

Commit

Permalink
Report alerts and warnings list even if it was empty or nil slice
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-vanyasin committed Oct 5, 2019
1 parent 9920bb2 commit 758ec90
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/sirupsen/logrus"

"github.com/cloudradar-monitoring/cagent/pkg/common"
"github.com/cloudradar-monitoring/cagent/pkg/monitoring"
"github.com/cloudradar-monitoring/cagent/pkg/monitoring/storcli"
)

Expand Down Expand Up @@ -39,14 +40,16 @@ func (ca *Cagent) collectModulesMeasurements() ([]map[string]interface{}, error)
}

alerts := m.GetAlerts()
if len(alerts) > 0 {
moduleResult["alerts"] = alerts
if alerts == nil {
alerts = make([]monitoring.Alert, 0)
}
moduleResult["alerts"] = alerts

warnings := m.GetWarnings()
if len(warnings) > 0 {
moduleResult["warnings"] = warnings
if warnings == nil {
warnings = make([]monitoring.Warning, 0)
}
moduleResult["warnings"] = warnings

result = append(result, moduleResult)
}
Expand Down

0 comments on commit 758ec90

Please sign in to comment.