just dont log

This commit is contained in:
davidnewhall2 2020-06-22 01:15:39 -07:00
parent 2d2985addc
commit e973f4b193
1 changed files with 5 additions and 12 deletions

View File

@ -4,7 +4,6 @@ package inputunifi
import ( import (
"fmt" "fmt"
"os"
"strings" "strings"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -172,27 +171,21 @@ func (u *InputUnifi) RawMetrics(filter *poller.Filter) ([]byte, error) {
switch filter.Kind { switch filter.Kind {
case "d", "device", "devices": case "d", "device", "devices":
return u.dumpSitesJSON(c, unifi.APIDevicePath, "Devices", sites, !filter.Skip) return u.dumpSitesJSON(c, unifi.APIDevicePath, sites)
case "client", "clients", "c": case "client", "clients", "c":
return u.dumpSitesJSON(c, unifi.APIClientPath, "Clients", sites, !filter.Skip) return u.dumpSitesJSON(c, unifi.APIClientPath, sites)
case "other", "o": case "other", "o":
return u.dumpSitesJSON(c, filter.Path, "Path", sites, !filter.Skip) return c.Unifi.GetJSON(filter.Path)
default: default:
return []byte{}, errNoFilterKindProvided return []byte{}, errNoFilterKindProvided
} }
} }
func (u *InputUnifi) dumpSitesJSON(c *Controller, path, name string, sites []*unifi.Site, print bool) ([]byte, error) { func (u *InputUnifi) dumpSitesJSON(c *Controller, path string, sites []*unifi.Site) ([]byte, error) {
allJSON := []byte{} allJSON := []byte{}
for _, s := range sites { for _, s := range sites {
apiPath := fmt.Sprintf(path, s.Name) body, err := c.Unifi.GetJSON(fmt.Sprintf(path, s.Name))
if print {
_, _ = fmt.Fprintf(os.Stderr, "[INFO] Printing %s: '%s' JSON for site: %s (%s):\n", name, apiPath, s.Desc, s.Name)
}
body, err := c.Unifi.GetJSON(apiPath)
if err != nil { if err != nil {
return allJSON, err return allJSON, err
} }