| 1 | package exporterscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/ |
| 2 | |
| 3 | import ( |
| 4 | "github.com/fffonion/tplink-plug-exporter/kasascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/" |
| 5 | "github.com/prometheus/client_golang/prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/" |
| 6 | logscip-go gomod github.com/sirupsen/logrus v1.7.0 `github.com/sirupsen/logrus`/ "github.com/sirupsen/logrusscip-go gomod github.com/sirupsen/logrus v1.7.0 `github.com/sirupsen/logrus`/" |
| 7 | ) |
| 8 | |
| 9 | type Exporterscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter# struct { |
| 10 | targetscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#target. string |
| 11 | clientscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#client. *kasascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/.KasaClientscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClient# |
| 12 | |
| 13 | metricsUpscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsUp., |
| 14 | metricsMetadatascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsMetadata., |
| 15 | metricsRelayStatescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsRelayState., |
| 16 | metricsOnTimescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsOnTime., |
| 17 | metricsRssiscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsRssi., |
| 18 | metricsCurrentscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsCurrent., |
| 19 | metricsVoltagescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsVoltage., |
| 20 | metricsPowerLoadscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsPowerLoad., |
| 21 | metricsPowerTotalscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsPowerTotal. *prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/Desc# |
| 22 | } |
| 23 | |
| 24 | type ExporterTargetscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/ExporterTarget# struct { |
| 25 | Hostscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/ExporterTarget#Host. string |
| 26 | } |
| 27 | |
| 28 | func NewExporterscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/NewExporter().(t *ExporterTargetscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/ExporterTarget#) *Exporterscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter# { |
| 29 | var ( |
| 30 | constLabels = prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.Labelsscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/Labels#{} |
| 31 | labelNames = []string{"alias", "id"} |
| 32 | ) |
| 33 | |
| 34 | e := &Exporterscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#{ |
| 35 | targetscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#target.: t.Hostscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/ExporterTarget#Host., |
| 36 | clientscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#client.: kasascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/.Newscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/New().(&kasascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/.KasaClientConfigscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientConfig#{ |
| 37 | Hostscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientConfig#Host.: t.Hostscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/ExporterTarget#Host., |
| 38 | }), |
| 39 | metricsUpscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsUp.: prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewDesc().("kasa_online", |
| 40 | "Device online.", |
| 41 | nil, constLabels, |
| 42 | ), |
| 43 | |
| 44 | metricsMetadatascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsMetadata.: prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewDesc().("kasa_metadata", |
| 45 | "Device metadata.", |
| 46 | []string{ |
| 47 | "alias", "hw_ver", "sw_ver", "model", "feature", |
| 48 | }, constLabels, |
| 49 | ), |
| 50 | |
| 51 | metricsRelayStatescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsRelayState.: prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewDesc().("kasa_relay_state", |
| 52 | "Relay state (switch on/off).", |
| 53 | labelNames, constLabels, |
| 54 | ), |
| 55 | metricsOnTimescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsOnTime.: prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewDesc().("kasa_on_time", |
| 56 | "Time in seconds since online.", |
| 57 | labelNames, constLabels), |
| 58 | metricsRssiscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsRssi.: prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewDesc().("kasa_rssi", |
| 59 | "Wifi received signal strength indicator.", |
| 60 | labelNames, constLabels), |
| 61 | |
| 62 | metricsCurrentscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsCurrent.: prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewDesc().("kasa_current", |
| 63 | "Current flowing through device in Ampere.", |
| 64 | labelNames, constLabels), |
| 65 | metricsVoltagescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsVoltage.: prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewDesc().("kasa_voltage", |
| 66 | "Current voltage connected to device in Volt.", |
| 67 | labelNames, constLabels), |
| 68 | metricsPowerLoadscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsPowerLoad.: prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewDesc().("kasa_power_load", |
| 69 | "Current power in Watt.", |
| 70 | labelNames, constLabels), |
| 71 | metricsPowerTotalscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsPowerTotal.: prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewDescscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewDesc().("kasa_power_total", |
| 72 | "Power consumption since device connected in kWh.", |
| 73 | labelNames, constLabels), |
| 74 | } |
| 75 | return e |
| 76 | } |
| 77 | |
| 78 | func (k *Exporterscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#) Describescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#Describe().(ch chan<- *prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/Desc#) { |
| 79 | ch <- k.metricsUpscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsUp. |
| 80 | ch <- k.metricsRelayStatescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsRelayState. |
| 81 | ch <- k.metricsOnTimescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsOnTime. |
| 82 | ch <- k.metricsRssiscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsRssi. |
| 83 | ch <- k.metricsCurrentscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsCurrent. |
| 84 | ch <- k.metricsVoltagescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsVoltage. |
| 85 | ch <- k.metricsPowerLoadscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsPowerLoad. |
| 86 | ch <- k.metricsPowerTotalscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsPowerTotal. |
| 87 | |
| 88 | } |
| 89 | |
| 90 | func (k *Exporterscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#) Collectscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#Collect().(ch chan<- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.Metricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/Metric#) { |
| 91 | s := k.clientscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#client..SystemServicescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClient#SystemService().(nil) |
| 92 | r, err := s.GetSysInfoscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientSystemService#GetSysInfo().() |
| 93 | |
| 94 | if err != nil { |
| 95 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsUpscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsUp., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 96 | 0) |
| 97 | logscip-go gomod github.com/sirupsen/logrus v1.7.0 `github.com/sirupsen/logrus`/.Errorlnscip-go gomod github.com/sirupsen/logrus v1.7.0 `github.com/sirupsen/logrus`/Errorln().("error collecting", k.targetscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#target., ":", err) |
| 98 | return |
| 99 | } |
| 100 | |
| 101 | // "alias", "hw_ver", "sw_ver", "model", "feature", |
| 102 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsMetadatascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsMetadata., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 103 | 1, r.Aliasscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#Alias., r.HardwareVersionscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#HardwareVersion., r.SoftwareVersionscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#SoftwareVersion., r.Modelscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#Model., r.Featurescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#Feature.) |
| 104 | |
| 105 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsRelayStatescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsRelayState., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 106 | float64(r.RelayStatescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#RelayState.), r.Aliasscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#Alias., r.DeviceIDscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#DeviceID.) |
| 107 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsOnTimescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsOnTime., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.CounterValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/CounterValue., |
| 108 | float64(r.OnTimescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#OnTime.), r.Aliasscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#Alias., r.DeviceIDscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#DeviceID.) |
| 109 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsRssiscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsRssi., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 110 | float64(r.RSSIscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#RSSI.), r.Aliasscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#Alias., r.DeviceIDscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#DeviceID.) |
| 111 | |
| 112 | aliases := map[string]string{} |
| 113 | emeterContexts := []*kasascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/.KasaRequestContextscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaRequestContext#{ |
| 114 | nil, // a nil context, represent the single plug or the parent strip |
| 115 | } |
| 116 | |
| 117 | // iterrate over every child plug in a power strip |
| 118 | for _, children := range r.Childrenscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#Children. { |
| 119 | aliases[children.IDscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/SysInfoChildren#ID.] = children.Aliasscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/SysInfoChildren#Alias. |
| 120 | emeterContexts = append(emeterContexts, &kasascip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/.KasaRequestContextscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaRequestContext#{ |
| 121 | ChildIDsscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaRequestContext#ChildIDs.: []string{children.IDscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/SysInfoChildren#ID.}, |
| 122 | }) |
| 123 | |
| 124 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsRelayStatescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsRelayState., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 125 | float64(children.Statescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/SysInfoChildren#State.), children.Aliasscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/SysInfoChildren#Alias., children.IDscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/SysInfoChildren#ID.) |
| 126 | |
| 127 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsOnTimescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsOnTime., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.CounterValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/CounterValue., |
| 128 | float64(children.OnTimescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/SysInfoChildren#OnTime.), children.Aliasscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/SysInfoChildren#Alias., children.IDscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/SysInfoChildren#ID.) |
| 129 | } |
| 130 | |
| 131 | if s.EmeterSupportedscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientSystemService#EmeterSupported().(r) { |
| 132 | for _, ctx := range emeterContexts { |
| 133 | m := k.clientscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#client..EmeterServicescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClient#EmeterService().(ctx) |
| 134 | re, err := m.GetRealtimescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaClientEmeterService#GetRealtime().() |
| 135 | |
| 136 | labels := []string{r.Aliasscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#Alias., r.DeviceIDscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetSysInfoResponse#DeviceID.} |
| 137 | // if this is a child plug in a powerstrip, set the alias and ID |
| 138 | if ctx != nil { |
| 139 | id := ctx.ChildIDsscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/KasaRequestContext#ChildIDs.[0] |
| 140 | labels[0] = aliases[id] |
| 141 | labels[1] = id |
| 142 | } |
| 143 | |
| 144 | // TODO: only set the child up to 0 on error |
| 145 | if err != nil { |
| 146 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsUpscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsUp., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 147 | 0) |
| 148 | logscip-go gomod github.com/sirupsen/logrus v1.7.0 `github.com/sirupsen/logrus`/.Errorlnscip-go gomod github.com/sirupsen/logrus v1.7.0 `github.com/sirupsen/logrus`/Errorln().("error collecting", k.targetscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#target., ":", err) |
| 149 | return |
| 150 | } |
| 151 | |
| 152 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsCurrentscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsCurrent., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 153 | float64(re.Currentscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Current.), labels...) |
| 154 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsVoltagescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsVoltage., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 155 | float64(re.Voltagescip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Voltage.), labels...) |
| 156 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsPowerLoadscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsPowerLoad., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 157 | float64(re.Powerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Power.), labels...) |
| 158 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsPowerTotalscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsPowerTotal., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.CounterValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/CounterValue., |
| 159 | float64(re.Totalscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/kasa`/GetRealtimeResponse#Total.), labels...) |
| 160 | } |
| 161 | |
| 162 | } |
| 163 | |
| 164 | ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(k.metricsUpscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/Exporter#metricsUp., prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.GaugeValuescip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/GaugeValue., |
| 165 | 1) |
| 166 | } |