Merge pull request #127 from davidnewhall/dn2_fix_crash

protect against nil return values
This commit is contained in:
David Newhall II 2019-10-01 20:04:30 -07:00 committed by GitHub
commit 37add1054c
1 changed files with 3 additions and 0 deletions

View File

@ -115,6 +115,9 @@ func (u *UnifiPoller) CollectMetrics() (*Metrics, error) {
// This is where we can manipuate the returned data or make arbitrary decisions.
// This function currently adds parent device names to client metrics.
func (u *UnifiPoller) AugmentMetrics(metrics *Metrics) error {
if metrics == nil || metrics.Devices == nil || metrics.Clients == nil {
return fmt.Errorf("nil metrics, augment impossible")
}
devices := make(map[string]string)
bssdIDs := make(map[string]string)
for _, r := range metrics.UAPs {