mirror of
https://github.com/unpoller/unpoller.git
synced 2026-04-05 08:54:09 -04:00
Add DPI collection
This commit is contained in:
@@ -80,6 +80,16 @@ func (u *InputUnifi) pollController(c *Controller) (*poller.Metrics, error) {
|
||||
return m, fmt.Errorf("unifi.GetSites(%v): %v", c.URL, err)
|
||||
}
|
||||
|
||||
if c.SaveDPI {
|
||||
if m.SitesDPI, err = c.Unifi.GetSiteDPI(m.Sites); err != nil {
|
||||
return m, fmt.Errorf("unifi.GetSiteDPI(%v): %v", c.URL, err)
|
||||
}
|
||||
|
||||
if m.ClientsDPI, err = c.Unifi.GetClientsDPI(m.Sites); err != nil {
|
||||
return m, fmt.Errorf("unifi.GetClientsDPI(%v): %v", c.URL, err)
|
||||
}
|
||||
}
|
||||
|
||||
if c.SaveIDS {
|
||||
m.IDSList, err = c.Unifi.GetIDS(m.Sites, time.Now().Add(2*time.Minute), time.Now())
|
||||
if err != nil {
|
||||
@@ -132,12 +142,23 @@ func (u *InputUnifi) augmentMetrics(c *Controller, metrics *poller.Metrics) *pol
|
||||
|
||||
// These come blank, so set them here.
|
||||
for i, c := range metrics.Clients {
|
||||
if devices[c.Mac] = c.Name; c.Name == "" {
|
||||
devices[c.Mac] = c.Hostname
|
||||
}
|
||||
metrics.Clients[i].SwName = devices[c.SwMac]
|
||||
metrics.Clients[i].ApName = devices[c.ApMac]
|
||||
metrics.Clients[i].GwName = devices[c.GwMac]
|
||||
metrics.Clients[i].RadioDescription = bssdIDs[metrics.Clients[i].Bssid] + metrics.Clients[i].RadioProto
|
||||
}
|
||||
|
||||
for i := range metrics.ClientsDPI {
|
||||
// Name on Client DPI data also comes blank, find it based on MAC address.
|
||||
metrics.ClientsDPI[i].Name = devices[metrics.ClientsDPI[i].MAC]
|
||||
if metrics.ClientsDPI[i].Name == "" {
|
||||
metrics.ClientsDPI[i].Name = metrics.ClientsDPI[i].MAC
|
||||
}
|
||||
}
|
||||
|
||||
if !*c.SaveSites {
|
||||
metrics.Sites = nil
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ type InputUnifi struct {
|
||||
type Controller struct {
|
||||
VerifySSL bool `json:"verify_ssl" toml:"verify_ssl" xml:"verify_ssl" yaml:"verify_ssl"`
|
||||
SaveIDS bool `json:"save_ids" toml:"save_ids" xml:"save_ids" yaml:"save_ids"`
|
||||
SaveDPI bool `json:"save_dpi" toml:"save_dpi" xml:"save_dpi" yaml:"save_dpi"`
|
||||
SaveSites *bool `json:"save_sites" toml:"save_sites" xml:"save_sites" yaml:"save_sites"`
|
||||
Role string `json:"role" toml:"role" xml:"role,attr" yaml:"role"`
|
||||
User string `json:"user" toml:"user" xml:"user" yaml:"user"`
|
||||
|
||||
Reference in New Issue
Block a user