Convert Prometheus percents to ratio
Typically we like to use ratio in Prometheus rather than percent as it is easier to do math with. Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
		
							parent
							
								
									3b515b854e
								
							
						
					
					
						commit
						1df763e684
					
				|  | @ -46,8 +46,8 @@ func descClient(ns string) *uclient { | ||||||
| 	return &uclient{ | 	return &uclient{ | ||||||
| 		Anomalies:      prometheus.NewDesc(ns+"anomalies", "Client Anomalies", labelW, nil), | 		Anomalies:      prometheus.NewDesc(ns+"anomalies", "Client Anomalies", labelW, nil), | ||||||
| 		BytesR:         prometheus.NewDesc(ns+"transfer_rate_bytes", "Client Data Rate", labelW, nil), | 		BytesR:         prometheus.NewDesc(ns+"transfer_rate_bytes", "Client Data Rate", labelW, nil), | ||||||
| 		CCQ:            prometheus.NewDesc(ns+"ccq_percent", "Client Connection Quality", labelW, nil), | 		CCQ:            prometheus.NewDesc(ns+"ccq_ratio", "Client Connection Quality", labelW, nil), | ||||||
| 		Satisfaction:   prometheus.NewDesc(ns+"satisfaction_percent", "Client Satisfaction", labelW, nil), | 		Satisfaction:   prometheus.NewDesc(ns+"satisfaction_ratoi", "Client Satisfaction", labelW, nil), | ||||||
| 		Noise:          prometheus.NewDesc(ns+"noise_db", "Client AP Noise", labelW, nil), | 		Noise:          prometheus.NewDesc(ns+"noise_db", "Client AP Noise", labelW, nil), | ||||||
| 		RoamCount:      prometheus.NewDesc(ns+"roam_count_total", "Client Roam Counter", labelW, nil), | 		RoamCount:      prometheus.NewDesc(ns+"roam_count_total", "Client Roam Counter", labelW, nil), | ||||||
| 		RSSI:           prometheus.NewDesc(ns+"rssi_db", "Client RSSI", labelW, nil), | 		RSSI:           prometheus.NewDesc(ns+"rssi_db", "Client RSSI", labelW, nil), | ||||||
|  | @ -95,8 +95,8 @@ func (u *promUnifi) exportClient(r report, c *unifi.Client) { | ||||||
| 		labelW[len(labelW)-1] = "false" | 		labelW[len(labelW)-1] = "false" | ||||||
| 		r.send([]*metric{ | 		r.send([]*metric{ | ||||||
| 			{u.Client.Anomalies, prometheus.CounterValue, c.Anomalies, labelW}, | 			{u.Client.Anomalies, prometheus.CounterValue, c.Anomalies, labelW}, | ||||||
| 			{u.Client.CCQ, prometheus.GaugeValue, c.Ccq / 10, labelW}, | 			{u.Client.CCQ, prometheus.GaugeValue, c.Ccq / 1000, labelW}, | ||||||
| 			{u.Client.Satisfaction, prometheus.GaugeValue, c.Satisfaction, labelW}, | 			{u.Client.Satisfaction, prometheus.GaugeValue, c.Satisfaction.Val / 100.0, labelW}, | ||||||
| 			{u.Client.Noise, prometheus.GaugeValue, c.Noise, labelW}, | 			{u.Client.Noise, prometheus.GaugeValue, c.Noise, labelW}, | ||||||
| 			{u.Client.RoamCount, prometheus.CounterValue, c.RoamCount, labelW}, | 			{u.Client.RoamCount, prometheus.CounterValue, c.RoamCount, labelW}, | ||||||
| 			{u.Client.RSSI, prometheus.GaugeValue, c.Rssi, labelW}, | 			{u.Client.RSSI, prometheus.GaugeValue, c.Rssi, labelW}, | ||||||
|  |  | ||||||
|  | @ -107,8 +107,8 @@ func descUAP(ns string) *uap { | ||||||
| 		VAPMacFilterRejections:   prometheus.NewDesc(ns+"vap_mac_filter_rejects_total", "VAP MAC Filter Rejections", labelV, nil), | 		VAPMacFilterRejections:   prometheus.NewDesc(ns+"vap_mac_filter_rejects_total", "VAP MAC Filter Rejections", labelV, nil), | ||||||
| 		VAPNumSatisfactionSta:    prometheus.NewDesc(ns+"vap_satisfaction_stations", "VAP Number Satisifaction Stations", labelV, nil), | 		VAPNumSatisfactionSta:    prometheus.NewDesc(ns+"vap_satisfaction_stations", "VAP Number Satisifaction Stations", labelV, nil), | ||||||
| 		VAPAvgClientSignal:       prometheus.NewDesc(ns+"vap_average_client_signal", "VAP Average Client Signal", labelV, nil), | 		VAPAvgClientSignal:       prometheus.NewDesc(ns+"vap_average_client_signal", "VAP Average Client Signal", labelV, nil), | ||||||
| 		VAPSatisfaction:          prometheus.NewDesc(ns+"vap_satisfaction_percent", "VAP Satisfaction", labelV, nil), | 		VAPSatisfaction:          prometheus.NewDesc(ns+"vap_satisfaction_ratoi", "VAP Satisfaction", labelV, nil), | ||||||
| 		VAPSatisfactionNow:       prometheus.NewDesc(ns+"vap_satisfaction_now_percent", "VAP Satisfaction Now", labelV, nil), | 		VAPSatisfactionNow:       prometheus.NewDesc(ns+"vap_satisfaction_now_ratoi", "VAP Satisfaction Now", labelV, nil), | ||||||
| 		VAPDNSAvgLatency:         prometheus.NewDesc(ns+"vap_dns_latency_average_seconds", "VAP DNS Latency Average", labelV, nil), | 		VAPDNSAvgLatency:         prometheus.NewDesc(ns+"vap_dns_latency_average_seconds", "VAP DNS Latency Average", labelV, nil), | ||||||
| 		VAPRxBytes:               prometheus.NewDesc(ns+"vap_receive_bytes_total", "VAP Bytes Received", labelV, nil), | 		VAPRxBytes:               prometheus.NewDesc(ns+"vap_receive_bytes_total", "VAP Bytes Received", labelV, nil), | ||||||
| 		VAPRxCrypts:              prometheus.NewDesc(ns+"vap_receive_crypts_total", "VAP Crypts Received", labelV, nil), | 		VAPRxCrypts:              prometheus.NewDesc(ns+"vap_receive_crypts_total", "VAP Crypts Received", labelV, nil), | ||||||
|  | @ -151,8 +151,8 @@ func descUAP(ns string) *uap { | ||||||
| 		RadioTxPower:            prometheus.NewDesc(ns+"radio_transmit_power", "Radio Transmit Power", labelR, nil), | 		RadioTxPower:            prometheus.NewDesc(ns+"radio_transmit_power", "Radio Transmit Power", labelR, nil), | ||||||
| 		RadioAstBeXmit:          prometheus.NewDesc(ns+"radio_ast_be_xmit", "Radio AstBe Transmit", labelR, nil), | 		RadioAstBeXmit:          prometheus.NewDesc(ns+"radio_ast_be_xmit", "Radio AstBe Transmit", labelR, nil), | ||||||
| 		RadioChannel:            prometheus.NewDesc(ns+"radio_channel", "Radio Channel", labelR, nil), | 		RadioChannel:            prometheus.NewDesc(ns+"radio_channel", "Radio Channel", labelR, nil), | ||||||
| 		RadioCuSelfRx:           prometheus.NewDesc(ns+"radio_channel_utilization_receive_percent", "Radio Channel Utilization Receive", labelR, nil), | 		RadioCuSelfRx:           prometheus.NewDesc(ns+"radio_channel_utilization_receive_ratio", "Radio Channel Utilization Receive", labelR, nil), | ||||||
| 		RadioCuSelfTx:           prometheus.NewDesc(ns+"radio_channel_utilization_transmit_percent", "Radio Channel Utilization Transmit", labelR, nil), | 		RadioCuSelfTx:           prometheus.NewDesc(ns+"radio_channel_utilization_transmit_ratio", "Radio Channel Utilization Transmit", labelR, nil), | ||||||
| 		RadioExtchannel:         prometheus.NewDesc(ns+"radio_ext_channel", "Radio Ext Channel", labelR, nil), | 		RadioExtchannel:         prometheus.NewDesc(ns+"radio_ext_channel", "Radio Ext Channel", labelR, nil), | ||||||
| 		RadioGain:               prometheus.NewDesc(ns+"radio_gain", "Radio Gain", labelR, nil), | 		RadioGain:               prometheus.NewDesc(ns+"radio_gain", "Radio Gain", labelR, nil), | ||||||
| 		RadioGuestNumSta:        prometheus.NewDesc(ns+"radio_guest_stations", "Radio Guest Station Count", labelR, nil), | 		RadioGuestNumSta:        prometheus.NewDesc(ns+"radio_guest_stations", "Radio Guest Station Count", labelR, nil), | ||||||
|  | @ -260,8 +260,8 @@ func (u *promUnifi) exportVAPtable(r report, labels []string, vt unifi.VapTable) | ||||||
| 			{u.UAP.VAPMacFilterRejections, prometheus.CounterValue, v.MacFilterRejections, labelV}, | 			{u.UAP.VAPMacFilterRejections, prometheus.CounterValue, v.MacFilterRejections, labelV}, | ||||||
| 			{u.UAP.VAPNumSatisfactionSta, prometheus.GaugeValue, v.NumSatisfactionSta, labelV}, | 			{u.UAP.VAPNumSatisfactionSta, prometheus.GaugeValue, v.NumSatisfactionSta, labelV}, | ||||||
| 			{u.UAP.VAPAvgClientSignal, prometheus.GaugeValue, v.AvgClientSignal, labelV}, | 			{u.UAP.VAPAvgClientSignal, prometheus.GaugeValue, v.AvgClientSignal, labelV}, | ||||||
| 			{u.UAP.VAPSatisfaction, prometheus.GaugeValue, v.Satisfaction, labelV}, | 			{u.UAP.VAPSatisfaction, prometheus.GaugeValue, v.Satisfaction.Val / 100.0, labelV}, | ||||||
| 			{u.UAP.VAPSatisfactionNow, prometheus.GaugeValue, v.SatisfactionNow, labelV}, | 			{u.UAP.VAPSatisfactionNow, prometheus.GaugeValue, v.SatisfactionNow.Val / 100.0, labelV}, | ||||||
| 			{u.UAP.VAPDNSAvgLatency, prometheus.GaugeValue, v.DNSAvgLatency.Val / 1000, labelV}, | 			{u.UAP.VAPDNSAvgLatency, prometheus.GaugeValue, v.DNSAvgLatency.Val / 1000, labelV}, | ||||||
| 			{u.UAP.VAPRxBytes, prometheus.CounterValue, v.RxBytes, labelV}, | 			{u.UAP.VAPRxBytes, prometheus.CounterValue, v.RxBytes, labelV}, | ||||||
| 			{u.UAP.VAPRxCrypts, prometheus.CounterValue, v.RxCrypts, labelV}, | 			{u.UAP.VAPRxCrypts, prometheus.CounterValue, v.RxCrypts, labelV}, | ||||||
|  | @ -319,8 +319,8 @@ func (u *promUnifi) exportRadtable(r report, labels []string, rt unifi.RadioTabl | ||||||
| 				{u.UAP.RadioTxPower, prometheus.GaugeValue, t.TxPower, labelR}, | 				{u.UAP.RadioTxPower, prometheus.GaugeValue, t.TxPower, labelR}, | ||||||
| 				{u.UAP.RadioAstBeXmit, prometheus.GaugeValue, t.AstBeXmit, labelR}, | 				{u.UAP.RadioAstBeXmit, prometheus.GaugeValue, t.AstBeXmit, labelR}, | ||||||
| 				{u.UAP.RadioChannel, prometheus.GaugeValue, t.Channel, labelR}, | 				{u.UAP.RadioChannel, prometheus.GaugeValue, t.Channel, labelR}, | ||||||
| 				{u.UAP.RadioCuSelfRx, prometheus.GaugeValue, t.CuSelfRx, labelR}, | 				{u.UAP.RadioCuSelfRx, prometheus.GaugeValue, t.CuSelfRx.Val / 100.0, labelR}, | ||||||
| 				{u.UAP.RadioCuSelfTx, prometheus.GaugeValue, t.CuSelfTx, labelR}, | 				{u.UAP.RadioCuSelfTx, prometheus.GaugeValue, t.CuSelfTx.Val / 100.0, labelR}, | ||||||
| 				{u.UAP.RadioExtchannel, prometheus.GaugeValue, t.Extchannel, labelR}, | 				{u.UAP.RadioExtchannel, prometheus.GaugeValue, t.Extchannel, labelR}, | ||||||
| 				{u.UAP.RadioGain, prometheus.GaugeValue, t.Gain, labelR}, | 				{u.UAP.RadioGain, prometheus.GaugeValue, t.Gain, labelR}, | ||||||
| 				{u.UAP.RadioGuestNumSta, prometheus.GaugeValue, t.GuestNumSta, labelR}, | 				{u.UAP.RadioGuestNumSta, prometheus.GaugeValue, t.GuestNumSta, labelR}, | ||||||
|  |  | ||||||
|  | @ -62,8 +62,8 @@ func descDevice(ns string) *unifiDevice { | ||||||
| 		MemUsed:       prometheus.NewDesc(ns+"memory_used_bytes", "System Memory Used", labels, nil), | 		MemUsed:       prometheus.NewDesc(ns+"memory_used_bytes", "System Memory Used", labels, nil), | ||||||
| 		MemTotal:      prometheus.NewDesc(ns+"memory_installed_bytes", "System Installed Memory", labels, nil), | 		MemTotal:      prometheus.NewDesc(ns+"memory_installed_bytes", "System Installed Memory", labels, nil), | ||||||
| 		MemBuffer:     prometheus.NewDesc(ns+"memory_buffer_bytes", "System Memory Buffer", labels, nil), | 		MemBuffer:     prometheus.NewDesc(ns+"memory_buffer_bytes", "System Memory Buffer", labels, nil), | ||||||
| 		CPU:           prometheus.NewDesc(ns+"cpu_utilization_percent", "System CPU % Utilized", labels, nil), | 		CPU:           prometheus.NewDesc(ns+"cpu_utilization_ratio", "System CPU % Utilized", labels, nil), | ||||||
| 		Mem:           prometheus.NewDesc(ns+"memory_utilization_percent", "System Memory % Utilized", labels, nil), | 		Mem:           prometheus.NewDesc(ns+"memory_utilization_ratio", "System Memory % Utilized", labels, nil), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -88,8 +88,8 @@ func (u *promUnifi) exportUDM(r report, d *unifi.UDM) { | ||||||
| 		{u.Device.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels}, | 		{u.Device.MemUsed, prometheus.GaugeValue, d.SysStats.MemUsed, labels}, | ||||||
| 		{u.Device.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels}, | 		{u.Device.MemTotal, prometheus.GaugeValue, d.SysStats.MemTotal, labels}, | ||||||
| 		{u.Device.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels}, | 		{u.Device.MemBuffer, prometheus.GaugeValue, d.SysStats.MemBuffer, labels}, | ||||||
| 		{u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU, labels}, | 		{u.Device.CPU, prometheus.GaugeValue, d.SystemStats.CPU.Val / 100.0, labels}, | ||||||
| 		{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem, labels}, | 		{u.Device.Mem, prometheus.GaugeValue, d.SystemStats.Mem.Val / 100.0, labels}, | ||||||
| 	}) | 	}) | ||||||
| 
 | 
 | ||||||
| 	// Switch Data
 | 	// Switch Data
 | ||||||
|  |  | ||||||
|  | @ -78,7 +78,7 @@ func descUSW(ns string) *usw { | ||||||
| 		RxErrors:     prometheus.NewDesc(pns+"receive_errors_total", "Total Receive Errors", labelP, nil), | 		RxErrors:     prometheus.NewDesc(pns+"receive_errors_total", "Total Receive Errors", labelP, nil), | ||||||
| 		RxMulticast:  prometheus.NewDesc(pns+"receive_multicast_total", "Total Receive Multicast", labelP, nil), | 		RxMulticast:  prometheus.NewDesc(pns+"receive_multicast_total", "Total Receive Multicast", labelP, nil), | ||||||
| 		RxPackets:    prometheus.NewDesc(pns+"receive_packets_total", "Total Receive Packets", labelP, nil), | 		RxPackets:    prometheus.NewDesc(pns+"receive_packets_total", "Total Receive Packets", labelP, nil), | ||||||
| 		Satisfaction: prometheus.NewDesc(pns+"satisfaction_percent", "Satisfaction", labelP, nil), | 		Satisfaction: prometheus.NewDesc(pns+"satisfaction_ratoi", "Satisfaction", labelP, nil), | ||||||
| 		Speed:        prometheus.NewDesc(pns+"port_speed_bps", "Speed", labelP, nil), | 		Speed:        prometheus.NewDesc(pns+"port_speed_bps", "Speed", labelP, nil), | ||||||
| 		TxBroadcast:  prometheus.NewDesc(pns+"transmit_broadcast_total", "Total Transmit Broadcast", labelP, nil), | 		TxBroadcast:  prometheus.NewDesc(pns+"transmit_broadcast_total", "Total Transmit Broadcast", labelP, nil), | ||||||
| 		TxBytes:      prometheus.NewDesc(pns+"transmit_bytes_total", "Total Transmit Bytes", labelP, nil), | 		TxBytes:      prometheus.NewDesc(pns+"transmit_bytes_total", "Total Transmit Bytes", labelP, nil), | ||||||
|  | @ -168,7 +168,7 @@ func (u *promUnifi) exportPortTable(r report, labels []string, pt []unifi.Port) | ||||||
| 			{u.USW.RxErrors, prometheus.CounterValue, p.RxErrors, labelP}, | 			{u.USW.RxErrors, prometheus.CounterValue, p.RxErrors, labelP}, | ||||||
| 			{u.USW.RxMulticast, prometheus.CounterValue, p.RxMulticast, labelP}, | 			{u.USW.RxMulticast, prometheus.CounterValue, p.RxMulticast, labelP}, | ||||||
| 			{u.USW.RxPackets, prometheus.CounterValue, p.RxPackets, labelP}, | 			{u.USW.RxPackets, prometheus.CounterValue, p.RxPackets, labelP}, | ||||||
| 			{u.USW.Satisfaction, prometheus.GaugeValue, p.Satisfaction, labelP}, | 			{u.USW.Satisfaction, prometheus.GaugeValue, p.Satisfaction.Val / 100.0, labelP}, | ||||||
| 			{u.USW.Speed, prometheus.GaugeValue, p.Speed.Val * 1000000, labelP}, | 			{u.USW.Speed, prometheus.GaugeValue, p.Speed.Val * 1000000, labelP}, | ||||||
| 			{u.USW.TxBroadcast, prometheus.CounterValue, p.TxBroadcast, labelP}, | 			{u.USW.TxBroadcast, prometheus.CounterValue, p.TxBroadcast, labelP}, | ||||||
| 			{u.USW.TxBytes, prometheus.CounterValue, p.TxBytes, labelP}, | 			{u.USW.TxBytes, prometheus.CounterValue, p.TxBytes, labelP}, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue