Merge pull request #127 from davidnewhall/dn2_fix_crash
protect against nil return values
This commit is contained in:
commit
37add1054c
|
|
@ -115,6 +115,9 @@ func (u *UnifiPoller) CollectMetrics() (*Metrics, error) {
|
||||||
// This is where we can manipuate the returned data or make arbitrary decisions.
|
// This is where we can manipuate the returned data or make arbitrary decisions.
|
||||||
// This function currently adds parent device names to client metrics.
|
// This function currently adds parent device names to client metrics.
|
||||||
func (u *UnifiPoller) AugmentMetrics(metrics *Metrics) error {
|
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)
|
devices := make(map[string]string)
|
||||||
bssdIDs := make(map[string]string)
|
bssdIDs := make(map[string]string)
|
||||||
for _, r := range metrics.UAPs {
|
for _, r := range metrics.UAPs {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue