mirror of
https://github.com/unpoller/unpoller.git
synced 2026-04-05 08:54:09 -04:00
feat: add controller sysinfo metrics (unpoller#927)
- Add Sysinfo collection from stat/sysinfo endpoint - Export controller_info, uptime, update_available, data retention, ports - Hostname fallback: name, then site_name when API omits hostname - Apply site name override to Sysinfo for remote/cloud - Add Discover/Discoverer for endpoint discovery - Require unpoller/unifi v5.15.0 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -198,6 +198,14 @@ func (u *InputUnifi) pollController(c *Controller) (*poller.Metrics, error) {
|
||||
u.LogDebugf("Found %d WAN configuration entries", len(m.WANConfigs))
|
||||
}
|
||||
|
||||
// Get controller system info (UniFi OS only)
|
||||
if m.Sysinfos, err = c.Unifi.GetSysinfo(sites); err != nil {
|
||||
// Don't fail collection if sysinfo fails - older controllers may not have this endpoint
|
||||
u.LogDebugf("unifi.GetSysinfo(%s): %v (continuing)", c.URL, err)
|
||||
} else {
|
||||
u.LogDebugf("Found %d Sysinfo entries", len(m.Sysinfos))
|
||||
}
|
||||
|
||||
return u.augmentMetrics(c, m), nil
|
||||
}
|
||||
|
||||
@@ -397,6 +405,10 @@ func (u *InputUnifi) augmentMetrics(c *Controller, metrics *Metrics) *poller.Met
|
||||
m.WANConfigs = append(m.WANConfigs, wanConfig)
|
||||
}
|
||||
|
||||
for _, sysinfo := range metrics.Sysinfos {
|
||||
m.Sysinfos = append(m.Sysinfos, sysinfo)
|
||||
}
|
||||
|
||||
// Apply default_site_name_override to all metrics if configured.
|
||||
// This must be done AFTER all metrics are added to m, so everything is included.
|
||||
// This allows us to use the console name for Cloud Gateways while keeping
|
||||
@@ -502,6 +514,15 @@ func applySiteNameOverride(m *poller.Metrics, overrideName string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Apply to sysinfo (controller metrics)
|
||||
for i := range m.Sysinfos {
|
||||
if s, ok := m.Sysinfos[i].(*unifi.Sysinfo); ok {
|
||||
if isDefaultSiteName(s.SiteName) {
|
||||
s.SiteName = overrideName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply to WAN configs
|
||||
for i := range m.WANConfigs {
|
||||
if wanConfig, ok := m.WANConfigs[i].(*unifi.WANEnrichedConfiguration); ok {
|
||||
|
||||
Reference in New Issue
Block a user