trim a few more zeros
This commit is contained in:
		
							parent
							
								
									ad29c59068
								
							
						
					
					
						commit
						0cb2350735
					
				|  | @ -43,35 +43,37 @@ func descClient(ns string) *uclient { | ||||||
| 		ns = "client_" | 		ns = "client_" | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	labels := []string{"name", "mac", "user_id", "site_name", "gw_mac", "gw_name", "sw_mac", "sw_name", "vlan", "ip"} | 	labels := []string{"name", "mac", "site_name", "gw_mac", "gw_name", "sw_mac", "sw_name", "vlan", "ip", "oui", "network"} | ||||||
| 	labelWired := append([]string{"sw_port"}, labels...) | 	labelWired := append([]string{"sw_port"}, labels...) | ||||||
| 	labelWireless := append([]string{"ap_mac", "ap_name", "radio_name", "radio", "radio_proto", "channel", "essid", "bssid", "radio_desc"}, labels...) | 	labelWireless := append([]string{"ap_mac", "ap_name", "radio_name", "radio", "radio_proto", "channel", "essid", "bssid", "radio_desc"}, labels...) | ||||||
|  | 	wireless := prometheus.Labels{"wired": "false"} | ||||||
|  | 	wired := prometheus.Labels{"wired": "true"} | ||||||
| 
 | 
 | ||||||
| 	return &uclient{ | 	return &uclient{ | ||||||
| 		Anomalies:      prometheus.NewDesc(ns+"anomalies_total", "Client Anomalies", labelWireless, nil), | 		Anomalies:      prometheus.NewDesc(ns+"anomalies_total", "Client Anomalies", labelWireless, wireless), | ||||||
| 		BytesR:         prometheus.NewDesc(ns+"transfer_rate_bytes", "Client Data Rate", labelWireless, nil), | 		BytesR:         prometheus.NewDesc(ns+"transfer_rate_bytes", "Client Data Rate", labelWireless, wireless), | ||||||
| 		CCQ:            prometheus.NewDesc(ns+"ccq_percent", "Client Connection Quality", labelWireless, nil), | 		CCQ:            prometheus.NewDesc(ns+"ccq_percent", "Client Connection Quality", labelWireless, wireless), | ||||||
| 		Noise:          prometheus.NewDesc(ns+"noise_db", "Client AP Noise", labelWireless, nil), | 		Noise:          prometheus.NewDesc(ns+"noise_db", "Client AP Noise", labelWireless, wireless), | ||||||
| 		RoamCount:      prometheus.NewDesc(ns+"roam_count_total", "Client Roam Counter", labelWireless, nil), | 		RoamCount:      prometheus.NewDesc(ns+"roam_count_total", "Client Roam Counter", labelWireless, wireless), | ||||||
| 		RSSI:           prometheus.NewDesc(ns+"rssi", "Client RSSI", labelWireless, nil), | 		RSSI:           prometheus.NewDesc(ns+"rssi", "Client RSSI", labelWireless, wireless), | ||||||
| 		RxBytes:        prometheus.NewDesc(ns+"receive_bytes_total", "Client Receive Bytes", labelWireless, nil), | 		RxBytes:        prometheus.NewDesc(ns+"receive_bytes_total", "Client Receive Bytes", labelWireless, wireless), | ||||||
| 		RxBytesR:       prometheus.NewDesc(ns+"receive_rate_bytes", "Client Receive Data Rate", labelWireless, nil), | 		RxBytesR:       prometheus.NewDesc(ns+"receive_rate_bytes", "Client Receive Data Rate", labelWireless, wireless), | ||||||
| 		RxPackets:      prometheus.NewDesc(ns+"receive_packets_total", "Client Receive Packets", labelWireless, nil), | 		RxPackets:      prometheus.NewDesc(ns+"receive_packets_total", "Client Receive Packets", labelWireless, wireless), | ||||||
| 		RxRate:         prometheus.NewDesc(ns+"radio_receive_rate", "Client Receive Rate", labelWireless, nil), | 		RxRate:         prometheus.NewDesc(ns+"radio_receive_rate", "Client Receive Rate", labelWireless, wireless), | ||||||
| 		Signal:         prometheus.NewDesc(ns+"radio_signal", "Client Signal Strength", labelWireless, nil), | 		Signal:         prometheus.NewDesc(ns+"radio_signal", "Client Signal Strength", labelWireless, wireless), | ||||||
| 		TxBytes:        prometheus.NewDesc(ns+"transmit_bytes_total", "Client Transmit Bytes", labelWireless, nil), | 		TxBytes:        prometheus.NewDesc(ns+"transmit_bytes_total", "Client Transmit Bytes", labelWireless, wireless), | ||||||
| 		TxBytesR:       prometheus.NewDesc(ns+"transmit_rate_bytes", "Client Transmit Data Rate", labelWireless, nil), | 		TxBytesR:       prometheus.NewDesc(ns+"transmit_rate_bytes", "Client Transmit Data Rate", labelWireless, wireless), | ||||||
| 		TxPackets:      prometheus.NewDesc(ns+"transmit_packets_total", "Client Transmit Packets", labelWireless, nil), | 		TxPackets:      prometheus.NewDesc(ns+"transmit_packets_total", "Client Transmit Packets", labelWireless, wireless), | ||||||
| 		TxPower:        prometheus.NewDesc(ns+"radio_transmit_power", "Client Transmit Power", labelWireless, nil), | 		TxPower:        prometheus.NewDesc(ns+"radio_transmit_power", "Client Transmit Power", labelWireless, wireless), | ||||||
| 		TxRate:         prometheus.NewDesc(ns+"radio_transmit_rate", "Client Transmit Rate", labelWireless, nil), | 		TxRate:         prometheus.NewDesc(ns+"radio_transmit_rate", "Client Transmit Rate", labelWireless, wireless), | ||||||
| 		WifiTxAttempts: prometheus.NewDesc(ns+"wifi_attempts_transmit_total", "Client Wifi Transmit Attempts", labelWireless, nil), | 		WifiTxAttempts: prometheus.NewDesc(ns+"wifi_attempts_transmit_total", "Client Wifi Transmit Attempts", labelWireless, wireless), | ||||||
| 
 | 
 | ||||||
| 		WiredRxBytes:   prometheus.NewDesc(ns+"wired_receive_bytes_total", "Client Wired Receive Bytes", labelWired, nil), | 		WiredRxBytes:   prometheus.NewDesc(ns+"wired_receive_bytes_total", "Client Wired Receive Bytes", labelWired, wired), | ||||||
| 		WiredRxBytesR:  prometheus.NewDesc(ns+"wired_receive_rate_bytes", "Client Wired Receive Data Rate", labelWired, nil), | 		WiredRxBytesR:  prometheus.NewDesc(ns+"wired_receive_rate_bytes", "Client Wired Receive Data Rate", labelWired, wired), | ||||||
| 		WiredRxPackets: prometheus.NewDesc(ns+"wired_receive_packets_total", "Client Wired Receive Packets", labelWired, nil), | 		WiredRxPackets: prometheus.NewDesc(ns+"wired_receive_packets_total", "Client Wired Receive Packets", labelWired, wired), | ||||||
| 		WiredTxBytes:   prometheus.NewDesc(ns+"wired_transmit_bytes_total", "Client Wired Transmit Bytes", labelWired, nil), | 		WiredTxBytes:   prometheus.NewDesc(ns+"wired_transmit_bytes_total", "Client Wired Transmit Bytes", labelWired, wired), | ||||||
| 		WiredTxBytesR:  prometheus.NewDesc(ns+"wired_transmit_rate_bytes", "Client Wired Data Rate", labelWired, nil), | 		WiredTxBytesR:  prometheus.NewDesc(ns+"wired_transmit_rate_bytes", "Client Wired Data Rate", labelWired, wired), | ||||||
| 		WiredTxPackets: prometheus.NewDesc(ns+"wired_transmit_packets_total", "Client Wired Transmit Packets", labelWired, nil), | 		WiredTxPackets: prometheus.NewDesc(ns+"wired_transmit_packets_total", "Client Wired Transmit Packets", labelWired, wired), | ||||||
| 
 | 
 | ||||||
| 		Uptime: prometheus.NewDesc(ns+"uptime", "Client Uptime", labels, nil), | 		Uptime: prometheus.NewDesc(ns+"uptime", "Client Uptime", labels, nil), | ||||||
| 		/* needs more "looking into" | 		/* needs more "looking into" | ||||||
|  | @ -87,7 +89,7 @@ func descClient(ns string) *uclient { | ||||||
| 
 | 
 | ||||||
| func (u *unifiCollector) exportClients(clients []*unifi.Client, r *Report) { | func (u *unifiCollector) exportClients(clients []*unifi.Client, r *Report) { | ||||||
| 	for _, c := range clients { | 	for _, c := range clients { | ||||||
| 		labels := []string{c.Name, c.Mac, c.UserID, c.SiteName, c.GwMac, c.GwName, c.SwMac, c.SwName, c.Vlan.Txt, c.IP} | 		labels := []string{c.Name, c.Mac, c.SiteName, c.GwMac, c.GwName, c.SwMac, c.SwName, c.Vlan.Txt, c.IP, c.Oui, c.Network} | ||||||
| 		labelWired := append([]string{c.SwPort.Txt}, labels...) | 		labelWired := append([]string{c.SwPort.Txt}, labels...) | ||||||
| 		labelWireless := append([]string{c.ApMac, c.ApName, c.RadioName, c.Radio, c.RadioProto, c.Channel.Txt, c.Essid, c.Bssid, c.RadioDescription}, labels...) | 		labelWireless := append([]string{c.ApMac, c.ApName, c.RadioName, c.Radio, c.RadioProto, c.Channel.Txt, c.Essid, c.Bssid, c.RadioDescription}, labels...) | ||||||
| 
 | 
 | ||||||
|  | @ -99,6 +101,7 @@ func (u *unifiCollector) exportClients(clients []*unifi.Client, r *Report) { | ||||||
| 				{u.Client.WiredTxBytes, prometheus.CounterValue, c.WiredTxBytes, labelWired}, | 				{u.Client.WiredTxBytes, prometheus.CounterValue, c.WiredTxBytes, labelWired}, | ||||||
| 				{u.Client.WiredTxBytesR, prometheus.GaugeValue, c.WiredTxBytesR, labelWired}, | 				{u.Client.WiredTxBytesR, prometheus.GaugeValue, c.WiredTxBytesR, labelWired}, | ||||||
| 				{u.Client.WiredTxPackets, prometheus.CounterValue, c.WiredTxPackets, labelWired}, | 				{u.Client.WiredTxPackets, prometheus.CounterValue, c.WiredTxPackets, labelWired}, | ||||||
|  | 				{u.Client.Uptime, prometheus.GaugeValue, c.Uptime, labels}, | ||||||
| 			} | 			} | ||||||
| 		} else { | 		} else { | ||||||
| 			r.ch <- []*metricExports{ | 			r.ch <- []*metricExports{ | ||||||
|  | @ -119,11 +122,9 @@ func (u *unifiCollector) exportClients(clients []*unifi.Client, r *Report) { | ||||||
| 				{u.Client.RxBytesR, prometheus.GaugeValue, c.RxBytesR, labelWireless}, | 				{u.Client.RxBytesR, prometheus.GaugeValue, c.RxBytesR, labelWireless}, | ||||||
| 				{u.Client.RxPackets, prometheus.CounterValue, c.RxPackets, labelWireless}, | 				{u.Client.RxPackets, prometheus.CounterValue, c.RxPackets, labelWireless}, | ||||||
| 				{u.Client.BytesR, prometheus.GaugeValue, c.BytesR, labelWireless}, | 				{u.Client.BytesR, prometheus.GaugeValue, c.BytesR, labelWireless}, | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		r.ch <- []*metricExports{ |  | ||||||
| 				{u.Client.Uptime, prometheus.GaugeValue, c.Uptime, labels}, | 				{u.Client.Uptime, prometheus.GaugeValue, c.Uptime, labels}, | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
| 		/* needs more "looking into" | 		/* needs more "looking into" | ||||||
| 		{u.Client.DpiStatsApp, prometheus.GaugeValue, c.DpiStats.App, labels}, | 		{u.Client.DpiStatsApp, prometheus.GaugeValue, c.DpiStats.App, labels}, | ||||||
| 		{u.Client.DpiStatsCat, prometheus.GaugeValue, c.DpiStats.Cat, labels}, | 		{u.Client.DpiStatsCat, prometheus.GaugeValue, c.DpiStats.Cat, labels}, | ||||||
|  | @ -133,5 +134,4 @@ func (u *unifiCollector) exportClients(clients []*unifi.Client, r *Report) { | ||||||
| 		{u.Client.DpiStatsTxPackets, prometheus.CounterValue, c.DpiStats.TxPackets, labels}, | 		{u.Client.DpiStatsTxPackets, prometheus.CounterValue, c.DpiStats.TxPackets, labels}, | ||||||
| 		*/ | 		*/ | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -70,7 +70,7 @@ func descUSW(ns string) *usw { | ||||||
| 	} | 	} | ||||||
| 	pns := ns + "port_" | 	pns := ns + "port_" | ||||||
| 	// The first five labels for switch are shared with (the same as) switch ports.
 | 	// The first five labels for switch are shared with (the same as) switch ports.
 | ||||||
| 	labels := []string{"type", "version", "device_id", "ip", | 	labels := []string{"type", "version", "ip", | ||||||
| 		"site_name", "mac", "model", "name", "serial", "site_id"} | 		"site_name", "mac", "model", "name", "serial", "site_id"} | ||||||
| 	// Copy labels, and replace first four with different names.
 | 	// Copy labels, and replace first four with different names.
 | ||||||
| 	labelP := append([]string{"port_num", "port_name", "port_mac", "port_ip"}, labels[5:]...) | 	labelP := append([]string{"port_num", "port_name", "port_mac", "port_ip"}, labels[5:]...) | ||||||
|  | @ -138,15 +138,21 @@ func descUSW(ns string) *usw { | ||||||
| 
 | 
 | ||||||
| func (u *unifiCollector) exportUSWs(usws []*unifi.USW, r *Report) { | func (u *unifiCollector) exportUSWs(usws []*unifi.USW, r *Report) { | ||||||
| 	for _, s := range usws { | 	for _, s := range usws { | ||||||
| 		labels := []string{s.Type, s.Version, s.DeviceID, s.IP, | 		labels := []string{s.Type, s.Version, s.IP, | ||||||
| 			s.SiteName, s.Mac, s.Model, s.Name, s.Serial, s.SiteID} | 			s.SiteName, s.Mac, s.Model, s.Name, s.Serial, s.SiteID} | ||||||
| 
 | 
 | ||||||
|  | 		metrics := []*metricExports{} | ||||||
|  | 		if s.HasTemperature.Val { | ||||||
|  | 			metrics = append(metrics, &metricExports{u.USW.Temperature, prometheus.GaugeValue, s.GeneralTemperature, labels}) | ||||||
|  | 		} | ||||||
|  | 		if s.HasFan.Val { | ||||||
|  | 			metrics = append(metrics, &metricExports{u.USW.FanLevel, prometheus.GaugeValue, s.FanLevel, labels}) | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		// Switch data.
 | 		// Switch data.
 | ||||||
| 		r.ch <- append([]*metricExports{ | 		r.ch <- append(metrics, append([]*metricExports{ | ||||||
| 			{u.USW.Uptime, prometheus.GaugeValue, s.Uptime, labels}, | 			{u.USW.Uptime, prometheus.GaugeValue, s.Uptime, labels}, | ||||||
| 			{u.USW.Temperature, prometheus.GaugeValue, s.GeneralTemperature, labels}, |  | ||||||
| 			{u.USW.TotalMaxPower, prometheus.GaugeValue, s.TotalMaxPower, labels}, | 			{u.USW.TotalMaxPower, prometheus.GaugeValue, s.TotalMaxPower, labels}, | ||||||
| 			{u.USW.FanLevel, prometheus.GaugeValue, s.FanLevel, labels}, |  | ||||||
| 			{u.USW.TotalTxBytes, prometheus.CounterValue, s.TxBytes, labels}, | 			{u.USW.TotalTxBytes, prometheus.CounterValue, s.TxBytes, labels}, | ||||||
| 			{u.USW.TotalRxBytes, prometheus.CounterValue, s.RxBytes, labels}, | 			{u.USW.TotalRxBytes, prometheus.CounterValue, s.RxBytes, labels}, | ||||||
| 			{u.USW.TotalBytes, prometheus.CounterValue, s.Bytes, labels}, | 			{u.USW.TotalBytes, prometheus.CounterValue, s.Bytes, labels}, | ||||||
|  | @ -177,7 +183,7 @@ func (u *unifiCollector) exportUSWs(usws []*unifi.USW, r *Report) { | ||||||
| 			{u.USW.SwTxMulticast, prometheus.CounterValue, s.Stat.Sw.TxMulticast, labels}, | 			{u.USW.SwTxMulticast, prometheus.CounterValue, s.Stat.Sw.TxMulticast, labels}, | ||||||
| 			{u.USW.SwTxBroadcast, prometheus.CounterValue, s.Stat.Sw.TxBroadcast, labels}, | 			{u.USW.SwTxBroadcast, prometheus.CounterValue, s.Stat.Sw.TxBroadcast, labels}, | ||||||
| 			{u.USW.SwBytes, prometheus.CounterValue, s.Stat.Sw.Bytes, labels}, | 			{u.USW.SwBytes, prometheus.CounterValue, s.Stat.Sw.Bytes, labels}, | ||||||
| 		}, u.exportPortTable(s.PortTable, labels[5:])...) | 		}, u.exportPortTable(s.PortTable, labels[5:])...)...) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -187,10 +193,14 @@ func (u *unifiCollector) exportPortTable(pt []unifi.Port, labels []string) []*me | ||||||
| 	for _, p := range pt { | 	for _, p := range pt { | ||||||
| 		// Copy labels, and add four new ones.
 | 		// Copy labels, and add four new ones.
 | ||||||
| 		l := append([]string{p.PortIdx.Txt, p.Name, p.Mac, p.IP}, labels...) | 		l := append([]string{p.PortIdx.Txt, p.Name, p.Mac, p.IP}, labels...) | ||||||
|  | 		if p.PoeEnable.Val && p.PortPoe.Val { | ||||||
| 			metrics = append(metrics, []*metricExports{ | 			metrics = append(metrics, []*metricExports{ | ||||||
| 				{u.USW.PoeCurrent, prometheus.GaugeValue, p.PoeCurrent, l}, | 				{u.USW.PoeCurrent, prometheus.GaugeValue, p.PoeCurrent, l}, | ||||||
| 				{u.USW.PoePower, prometheus.GaugeValue, p.PoePower, l}, | 				{u.USW.PoePower, prometheus.GaugeValue, p.PoePower, l}, | ||||||
| 				{u.USW.PoeVoltage, prometheus.GaugeValue, p.PoeVoltage, l}, | 				{u.USW.PoeVoltage, prometheus.GaugeValue, p.PoeVoltage, l}, | ||||||
|  | 			}...) | ||||||
|  | 		} | ||||||
|  | 		metrics = append(metrics, []*metricExports{ | ||||||
| 			{u.USW.RxBroadcast, prometheus.CounterValue, p.RxBroadcast, l}, | 			{u.USW.RxBroadcast, prometheus.CounterValue, p.RxBroadcast, l}, | ||||||
| 			{u.USW.RxBytes, prometheus.CounterValue, p.RxBytes, l}, | 			{u.USW.RxBytes, prometheus.CounterValue, p.RxBytes, l}, | ||||||
| 			{u.USW.RxBytesR, prometheus.GaugeValue, p.RxBytesR, l}, | 			{u.USW.RxBytesR, prometheus.GaugeValue, p.RxBytesR, l}, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue