This commit is contained in:
		
							parent
							
								
									5aa11e38e4
								
							
						
					
					
						commit
						21e923c1b5
					
				|  | @ -7,8 +7,8 @@ import ( | |||
| ) | ||||
| 
 | ||||
| const ( | ||||
| 	Talarm   = item("Alarm") | ||||
| 	Tanomaly = item("Anomaly") | ||||
| 	alarmT   = item("Alarm") | ||||
| 	anomalyT = item("Anomaly") | ||||
| ) | ||||
| 
 | ||||
| // batchAlarms generates alarm datapoints for InfluxDB.
 | ||||
|  | @ -44,7 +44,7 @@ func (u *InfluxUnifi) batchAlarms(r report, event *unifi.Alarm) { // nolint: god | |||
| 		"srcip_organization":   event.SourceIPGeo.Organization, | ||||
| 	} | ||||
| 
 | ||||
| 	r.addCount(Talarm) | ||||
| 	r.addCount(alarmT) | ||||
| 	r.send(&metric{ | ||||
| 		Table:  "unifi_alarm", | ||||
| 		TS:     event.Datetime, | ||||
|  | @ -72,7 +72,7 @@ func (u *InfluxUnifi) batchAnomaly(r report, event *unifi.Anomaly) { | |||
| 		return // The event is older than our interval, ignore it.
 | ||||
| 	} | ||||
| 
 | ||||
| 	r.addCount(Tanomaly) | ||||
| 	r.addCount(anomalyT) | ||||
| 	r.send(&metric{ | ||||
| 		TS:     event.Datetime, | ||||
| 		Table:  "unifi_anomaly", | ||||
|  |  | |||
|  | @ -6,9 +6,10 @@ import ( | |||
| 	"github.com/unifi-poller/unifi" | ||||
| ) | ||||
| 
 | ||||
| // These constants are used as names for printed/logged counters.
 | ||||
| const ( | ||||
| 	Tevent = item("Event") | ||||
| 	TIDS   = item("IDS") | ||||
| 	eventT = item("Event") | ||||
| 	idsT   = item("IDS") | ||||
| ) | ||||
| 
 | ||||
| // batchIDS generates intrusion detection datapoints for InfluxDB.
 | ||||
|  | @ -44,7 +45,7 @@ func (u *InfluxUnifi) batchIDS(r report, i *unifi.IDS) { // nolint: godupl | |||
| 		"srcip_organization":   i.SourceIPGeo.Organization, | ||||
| 	} | ||||
| 
 | ||||
| 	r.addCount(TIDS) | ||||
| 	r.addCount(idsT) | ||||
| 	r.send(&metric{ | ||||
| 		Table:  "unifi_ids", | ||||
| 		TS:     i.Datetime, | ||||
|  | @ -105,7 +106,7 @@ func (u *InfluxUnifi) batchEvent(r report, i *unifi.Event) { // nolint: funlen | |||
| 		"srcip_organization":   i.SourceIPGeo.Organization, | ||||
| 	} | ||||
| 
 | ||||
| 	r.addCount(Tevent) | ||||
| 	r.addCount(eventT) | ||||
| 	r.send(&metric{ | ||||
| 		TS:     i.Datetime, | ||||
| 		Table:  "unifi_events", | ||||
|  |  | |||
|  | @ -75,14 +75,15 @@ func (r *Report) error(err error) { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| // These constants are used as names for printed/logged counters.
 | ||||
| const ( | ||||
| 	Ttotal = item("Point") | ||||
| 	Tfield = item("Fields") | ||||
| 	pointT = item("Point") | ||||
| 	fieldT = item("Fields") | ||||
| ) | ||||
| 
 | ||||
| func (r *Report) batch(m *metric, p *influx.Point) { | ||||
| 	r.addCount(Ttotal) | ||||
| 	r.addCount(Tfield, len(m.Fields)) | ||||
| 	r.addCount(pointT) | ||||
| 	r.addCount(fieldT, len(m.Fields)) | ||||
| 	r.bp.AddPoint(p) | ||||
| } | ||||
| 
 | ||||
|  | @ -91,8 +92,8 @@ func (r *Report) String() string { | |||
| 		"%s: %d, %s/%s: %d, %s: %d, %s/%s/%s/%s: %d/%d/%d/%d, "+ | ||||
| 		"DPI Site/Client: %d/%d, %s: %d, %s: %d, Err: %d, Dur: %v", | ||||
| 		len(r.Metrics.Sites), len(r.Metrics.Clients), | ||||
| 		TUAP, r.Counts[TUAP], TUDM, TUSG, r.Counts[TUDM]+r.Counts[TUSG], TUSW, r.Counts[TUSW], | ||||
| 		TIDS, Tevent, Talarm, Tanomaly, r.Counts[TIDS], r.Counts[Tevent], r.Counts[Talarm], r.Counts[Tanomaly], | ||||
| 		len(r.Metrics.SitesDPI), len(r.Metrics.ClientsDPI), Ttotal, r.Counts[Ttotal], | ||||
| 		Tfield, r.Counts[Tfield], len(r.Errors), r.Elapsed.Round(time.Millisecond)) | ||||
| 		uapT, r.Counts[uapT], udmT, usgT, r.Counts[udmT]+r.Counts[usgT], uswT, r.Counts[uswT], | ||||
| 		idsT, eventT, alarmT, anomalyT, r.Counts[idsT], r.Counts[eventT], r.Counts[alarmT], r.Counts[anomalyT], | ||||
| 		len(r.Metrics.SitesDPI), len(r.Metrics.ClientsDPI), pointT, r.Counts[pointT], | ||||
| 		fieldT, r.Counts[fieldT], len(r.Errors), r.Elapsed.Round(time.Millisecond)) | ||||
| } | ||||
|  |  | |||
|  | @ -4,7 +4,8 @@ import ( | |||
| 	"github.com/unifi-poller/unifi" | ||||
| ) | ||||
| 
 | ||||
| const TUAP = item("UAP") | ||||
| // uapT is used as a name for printed/logged counters.
 | ||||
| const uapT = item("UAP") | ||||
| 
 | ||||
| // batchUAP generates Wireless-Access-Point datapoints for InfluxDB.
 | ||||
| // These points can be passed directly to influx.
 | ||||
|  | @ -34,7 +35,7 @@ func (u *InfluxUnifi) batchUAP(r report, s *unifi.UAP) { | |||
| 	fields["guest-num_sta"] = int(s.GuestNumSta.Val) | ||||
| 	fields["num_sta"] = s.NumSta.Val | ||||
| 
 | ||||
| 	r.addCount(TUAP) | ||||
| 	r.addCount(uapT) | ||||
| 	r.send(&metric{Table: "uap", Tags: tags, Fields: fields}) | ||||
| 	u.processRadTable(r, tags, s.RadioTable, s.RadioTableStats) | ||||
| 	u.processVAPTable(r, tags, s.VapTable) | ||||
|  |  | |||
|  | @ -4,7 +4,8 @@ import ( | |||
| 	"github.com/unifi-poller/unifi" | ||||
| ) | ||||
| 
 | ||||
| const TUDM = item("UDM") | ||||
| // udmT is used as a name for printed/logged counters.
 | ||||
| const udmT = item("UDM") | ||||
| 
 | ||||
| // Combine concatenates N maps. This will delete things if not used with caution.
 | ||||
| func Combine(in ...map[string]interface{}) map[string]interface{} { | ||||
|  | @ -84,7 +85,7 @@ func (u *InfluxUnifi) batchUDM(r report, s *unifi.UDM) { // nolint: funlen | |||
| 		}, | ||||
| 	) | ||||
| 
 | ||||
| 	r.addCount(TUDM) | ||||
| 	r.addCount(udmT) | ||||
| 	r.send(&metric{Table: "usg", Tags: tags, Fields: fields}) | ||||
| 	u.batchNetTable(r, tags, s.NetworkTable) | ||||
| 	u.batchUSGwans(r, tags, s.Wan1, s.Wan2) | ||||
|  |  | |||
|  | @ -4,7 +4,8 @@ import ( | |||
| 	"github.com/unifi-poller/unifi" | ||||
| ) | ||||
| 
 | ||||
| const TUSG = item("USG") | ||||
| // usgT is used as a name for printed/logged counters.
 | ||||
| const usgT = item("USG") | ||||
| 
 | ||||
| // batchUSG generates Unifi Gateway datapoints for InfluxDB.
 | ||||
| // These points can be passed directly to influx.
 | ||||
|  | @ -45,7 +46,7 @@ func (u *InfluxUnifi) batchUSG(r report, s *unifi.USG) { | |||
| 		}, | ||||
| 	) | ||||
| 
 | ||||
| 	r.addCount(TUSG) | ||||
| 	r.addCount(usgT) | ||||
| 	r.send(&metric{Table: "usg", Tags: tags, Fields: fields}) | ||||
| 	u.batchNetTable(r, tags, s.NetworkTable) | ||||
| 	u.batchUSGwans(r, tags, s.Wan1, s.Wan2) | ||||
|  |  | |||
|  | @ -4,7 +4,8 @@ import ( | |||
| 	"github.com/unifi-poller/unifi" | ||||
| ) | ||||
| 
 | ||||
| const TUSW = item("USW") | ||||
| // uswT is used as a name for printed/logged counters.
 | ||||
| const uswT = item("USW") | ||||
| 
 | ||||
| // batchUSW generates Unifi Switch datapoints for InfluxDB.
 | ||||
| // These points can be passed directly to influx.
 | ||||
|  | @ -40,7 +41,7 @@ func (u *InfluxUnifi) batchUSW(r report, s *unifi.USW) { | |||
| 			"user-num_sta":        s.UserNumSta.Val, | ||||
| 		}) | ||||
| 
 | ||||
| 	r.addCount(TUSW) | ||||
| 	r.addCount(uswT) | ||||
| 	r.send(&metric{Table: "usw", Tags: tags, Fields: fields}) | ||||
| 	u.batchPortTable(r, tags, s.PortTable) | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue