Make a new docker image

This commit is contained in:
davidnewhall2 2019-12-24 23:43:49 -08:00
parent 122b75b853
commit 444e9ea0f7
19 changed files with 66 additions and 40 deletions

View File

@ -58,12 +58,12 @@
version = "v1.1.0" version = "v1.1.0"
[[projects]] [[projects]]
branch = "master"
digest = "1:982be0b5396e16a663697899ce69cc7b1e71ddcae4153af157578d4dc9bc3f88" digest = "1:982be0b5396e16a663697899ce69cc7b1e71ddcae4153af157578d4dc9bc3f88"
name = "github.com/prometheus/client_model" name = "github.com/prometheus/client_model"
packages = ["go"] packages = ["go"]
pruneopts = "UT" pruneopts = "UT"
revision = "d1d2010b5beead3fa1c5f271a5cf626e40b3ad6e" revision = "d1d2010b5beead3fa1c5f271a5cf626e40b3ad6e"
version = "v0.1.0"
[[projects]] [[projects]]
digest = "1:7dec9ab2db741c280b89b142b08ea142824152c5f40fb1f90c35b6ef7a694456" digest = "1:7dec9ab2db741c280b89b142b08ea142824152c5f40fb1f90c35b6ef7a694456"
@ -100,27 +100,30 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:07f0cb66f649e51f9ef23441f8dfc34a73e7d9bf0832417abcbad578f1d8c8d6" digest = "1:0ca5ac8aedc2fd9cb63c90acbd71c0cba8ddb61dfcca58b96cf41550689bf56d"
name = "golang.org/x/sys" name = "golang.org/x/sys"
packages = ["windows"] packages = ["windows"]
pruneopts = "UT" pruneopts = "UT"
revision = "af0d71d358abe0ba3594483a5d519f429dbae3e9" revision = "c709ea063b76879dc9915358f55d4d77c16ab6d5"
[[projects]] [[projects]]
digest = "1:54742bef5cb29f706614c9edcfdeb29fb5992f26090f26ca955f575dddf54f9e" digest = "1:b914912b8cb13beebf85b913006d8692bbf20d8620122966a7a911bbfc6e0104"
name = "golift.io/cnfg" name = "golift.io/cnfg"
packages = ["."] packages = [
".",
"cnfgfile",
]
pruneopts = "UT" pruneopts = "UT"
revision = "961061d377655468e9da4a9333e71b9b77402470" revision = "7d859f27a93d43faceb7101d02baeb8e69f16d4a"
version = "v0.0.1" version = "v0.0.4"
[[projects]] [[projects]]
digest = "1:2883cea734f2766f41ff9c9d4aefccccc53e3d44f5c8b08893b9c218cf666722" branch = "master"
digest = "1:13b9e827c1f958ffe31554d57940495010eef89928697f6c6beae78a750ee637"
name = "golift.io/unifi" name = "golift.io/unifi"
packages = ["."] packages = ["."]
pruneopts = "UT" pruneopts = "UT"
revision = "a607fe940c6a563c6994f2c945394b19d2183b1c" revision = "4d78625be4cd448ea2db35c63a40b451e7d0df99"
version = "v4.1.6"
[[projects]] [[projects]]
digest = "1:b75b3deb2bce8bc079e16bb2aecfe01eb80098f5650f9e93e5643ca8b7b73737" digest = "1:b75b3deb2bce8bc079e16bb2aecfe01eb80098f5650f9e93e5643ca8b7b73737"
@ -140,6 +143,7 @@
"github.com/prometheus/common/version", "github.com/prometheus/common/version",
"github.com/spf13/pflag", "github.com/spf13/pflag",
"golift.io/cnfg", "golift.io/cnfg",
"golift.io/cnfg/cnfgfile",
"golift.io/unifi", "golift.io/unifi",
] ]
solver-name = "gps-cdcl" solver-name = "gps-cdcl"

View File

@ -7,3 +7,8 @@
[prune] [prune]
go-tests = true go-tests = true
unused-packages = true unused-packages = true
# TODO: remove this!!!
[[constraint]]
name = "golift.io/unifi"
branch = "master"

View File

@ -28,7 +28,7 @@
[influxdb] [influxdb]
disable = false disable = false
# InfluxDB does not require auth by default, so the user/password are probably unimportant. # InfluxDB does not require auth by default, so the user/password are probably unimportant.
url = "http://127.0.0.1:8086" url = "http://127.0.0.1:8086"
user = "unifipoller" user = "unifipoller"
pass = "unifipoller" pass = "unifipoller"
# Be sure to create this database. # Be sure to create this database.

View File

@ -10,6 +10,7 @@ func (u *InfluxUnifi) batchClient(r report, s *unifi.Client) {
tags := map[string]string{ tags := map[string]string{
"mac": s.Mac, "mac": s.Mac,
"site_name": s.SiteName, "site_name": s.SiteName,
"source": s.SourceName,
"ap_name": s.ApName, "ap_name": s.ApName,
"gw_name": s.GwName, "gw_name": s.GwName,
"sw_name": s.SwName, "sw_name": s.SwName,

View File

@ -8,6 +8,8 @@ import (
// These points can be passed directly to influx. // These points can be passed directly to influx.
func (u *InfluxUnifi) batchIDS(r report, i *unifi.IDS) { func (u *InfluxUnifi) batchIDS(r report, i *unifi.IDS) {
tags := map[string]string{ tags := map[string]string{
"site_name": i.SiteName,
"source": i.SourceName,
"in_iface": i.InIface, "in_iface": i.InIface,
"event_type": i.EventType, "event_type": i.EventType,
"proto": i.Proto, "proto": i.Proto,

View File

@ -11,6 +11,7 @@ func (u *InfluxUnifi) batchSite(r report, s *unifi.Site) {
tags := map[string]string{ tags := map[string]string{
"name": s.Name, "name": s.Name,
"site_name": s.SiteName, "site_name": s.SiteName,
"source": s.SourceName,
"desc": s.Desc, "desc": s.Desc,
"status": h.Status, "status": h.Status,
"subsystem": h.Subsystem, "subsystem": h.Subsystem,

View File

@ -14,6 +14,7 @@ func (u *InfluxUnifi) batchUAP(r report, s *unifi.UAP) {
tags := map[string]string{ tags := map[string]string{
"mac": s.Mac, "mac": s.Mac,
"site_name": s.SiteName, "site_name": s.SiteName,
"source": s.SourceName,
"name": s.Name, "name": s.Name,
"version": s.Version, "version": s.Version,
"model": s.Model, "model": s.Model,
@ -85,6 +86,7 @@ func (u *InfluxUnifi) processVAPTable(r report, t map[string]string, vt unifi.Va
tags := map[string]string{ tags := map[string]string{
"device_name": t["name"], "device_name": t["name"],
"site_name": t["site_name"], "site_name": t["site_name"],
"source": t["source"],
"ap_mac": s.ApMac, "ap_mac": s.ApMac,
"bssid": s.Bssid, "bssid": s.Bssid,
"id": s.ID, "id": s.ID,
@ -148,6 +150,7 @@ func (u *InfluxUnifi) processRadTable(r report, t map[string]string, rt unifi.Ra
tags := map[string]string{ tags := map[string]string{
"device_name": t["name"], "device_name": t["name"],
"site_name": t["site_name"], "site_name": t["site_name"],
"source": t["source"],
"channel": p.Channel.Txt, "channel": p.Channel.Txt,
"radio": p.Radio, "radio": p.Radio,
} }

View File

@ -40,6 +40,7 @@ func (u *InfluxUnifi) batchUDM(r report, s *unifi.UDM) {
} }
tags := map[string]string{ tags := map[string]string{
"source": s.SourceName,
"mac": s.Mac, "mac": s.Mac,
"site_name": s.SiteName, "site_name": s.SiteName,
"name": s.Name, "name": s.Name,
@ -52,6 +53,7 @@ func (u *InfluxUnifi) batchUDM(r report, s *unifi.UDM) {
u.batchUSGstat(s.SpeedtestStatus, s.Stat.Gw, s.Uplink), u.batchUSGstat(s.SpeedtestStatus, s.Stat.Gw, s.Uplink),
u.batchSysStats(s.SysStats, s.SystemStats), u.batchSysStats(s.SysStats, s.SystemStats),
map[string]interface{}{ map[string]interface{}{
"source": s.SourceName,
"ip": s.IP, "ip": s.IP,
"bytes": s.Bytes.Val, "bytes": s.Bytes.Val,
"last_seen": s.LastSeen.Val, "last_seen": s.LastSeen.Val,
@ -76,6 +78,7 @@ func (u *InfluxUnifi) batchUDM(r report, s *unifi.UDM) {
tags = map[string]string{ tags = map[string]string{
"mac": s.Mac, "mac": s.Mac,
"site_name": s.SiteName, "site_name": s.SiteName,
"source": s.SourceName,
"name": s.Name, "name": s.Name,
"version": s.Version, "version": s.Version,
"model": s.Model, "model": s.Model,
@ -105,6 +108,7 @@ func (u *InfluxUnifi) batchUDM(r report, s *unifi.UDM) {
tags = map[string]string{ tags = map[string]string{
"mac": s.Mac, "mac": s.Mac,
"site_name": s.SiteName, "site_name": s.SiteName,
"source": s.SourceName,
"name": s.Name, "name": s.Name,
"version": s.Version, "version": s.Version,
"model": s.Model, "model": s.Model,

View File

@ -14,6 +14,7 @@ func (u *InfluxUnifi) batchUSG(r report, s *unifi.USG) {
tags := map[string]string{ tags := map[string]string{
"mac": s.Mac, "mac": s.Mac,
"site_name": s.SiteName, "site_name": s.SiteName,
"source": s.SourceName,
"name": s.Name, "name": s.Name,
"version": s.Version, "version": s.Version,
"model": s.Model, "model": s.Model,
@ -76,6 +77,7 @@ func (u *InfluxUnifi) batchUSGwans(r report, tags map[string]string, wans ...uni
tags := map[string]string{ tags := map[string]string{
"device_name": tags["name"], "device_name": tags["name"],
"site_name": tags["site_name"], "site_name": tags["site_name"],
"source": tags["source"],
"ip": wan.IP, "ip": wan.IP,
"purpose": wan.Name, "purpose": wan.Name,
"mac": wan.Mac, "mac": wan.Mac,
@ -115,6 +117,7 @@ func (u *InfluxUnifi) batchNetTable(r report, tags map[string]string, nt unifi.N
tags := map[string]string{ tags := map[string]string{
"device_name": tags["name"], "device_name": tags["name"],
"site_name": tags["site_name"], "site_name": tags["site_name"],
"source": tags["source"],
"up": p.Up.Txt, "up": p.Up.Txt,
"enabled": p.Enabled.Txt, "enabled": p.Enabled.Txt,
"ip": p.IP, "ip": p.IP,

View File

@ -14,6 +14,7 @@ func (u *InfluxUnifi) batchUSW(r report, s *unifi.USW) {
tags := map[string]string{ tags := map[string]string{
"mac": s.Mac, "mac": s.Mac,
"site_name": s.SiteName, "site_name": s.SiteName,
"source": s.SourceName,
"name": s.Name, "name": s.Name,
"version": s.Version, "version": s.Version,
"model": s.Model, "model": s.Model,
@ -71,6 +72,7 @@ func (u *InfluxUnifi) batchPortTable(r report, t map[string]string, pt []unifi.P
tags := map[string]string{ tags := map[string]string{
"site_name": t["site_name"], "site_name": t["site_name"],
"device_name": t["name"], "device_name": t["name"],
"source": t["source"],
"name": p.Name, "name": p.Name,
"poe_mode": p.PoeMode, "poe_mode": p.PoeMode,
"port_poe": p.PortPoe.Txt, "port_poe": p.PortPoe.Txt,

View File

@ -17,6 +17,7 @@ import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
"golift.io/cnfg" "golift.io/cnfg"
"golift.io/cnfg/cnfgfile"
"golift.io/unifi" "golift.io/unifi"
) )
@ -103,14 +104,13 @@ func (u *UnifiPoller) ParseConfigs() error {
// parseInterface parses the config file and environment variables into the provided interface. // parseInterface parses the config file and environment variables into the provided interface.
func (u *UnifiPoller) parseInterface(i interface{}) error { func (u *UnifiPoller) parseInterface(i interface{}) error {
cnfg.ENVTag = "xml" // xml tag is better formatted for slices.
// Parse config file into provided interface. // Parse config file into provided interface.
if err := cnfg.ParseFile(i, u.Flags.ConfigFile); err != nil { if err := cnfgfile.Unmarshal(i, u.Flags.ConfigFile); err != nil {
return err return err
} }
// Parse environment variables into provided interface. // Parse environment variables into provided interface.
_, err := cnfg.ParseENV(i, ENVConfigPrefix) _, err := cnfg.UnmarshalENV(i, ENVConfigPrefix)
return err return err
} }

View File

@ -42,7 +42,7 @@ type uclient struct {
func descClient(ns string) *uclient { func descClient(ns string) *uclient {
labels := []string{"name", "mac", "site_name", "gw_name", "sw_name", "vlan", labels := []string{"name", "mac", "site_name", "gw_name", "sw_name", "vlan",
"ip", "oui", "network", "sw_port", "ap_name", "wired"} "ip", "oui", "network", "sw_port", "ap_name", "wired", "source"}
labelW := append([]string{"radio_name", "radio", "radio_proto", "channel", "essid", "bssid", "radio_desc"}, labels...) labelW := append([]string{"radio_name", "radio", "radio_proto", "channel", "essid", "bssid", "radio_desc"}, labels...)
return &uclient{ return &uclient{
@ -85,7 +85,7 @@ func descClient(ns string) *uclient {
func (u *promUnifi) exportClient(r report, c *unifi.Client) { func (u *promUnifi) exportClient(r report, c *unifi.Client) {
labels := []string{c.Name, c.Mac, c.SiteName, c.GwName, c.SwName, c.Vlan.Txt, labels := []string{c.Name, c.Mac, c.SiteName, c.GwName, c.SwName, c.Vlan.Txt,
c.IP, c.Oui, c.Network, c.SwPort.Txt, c.ApName, ""} c.IP, c.Oui, c.Network, c.SwPort.Txt, c.ApName, "", c.SourceName}
labelW := append([]string{c.RadioName, c.Radio, c.RadioProto, c.Channel.Txt, labelW := append([]string{c.RadioName, c.Radio, c.RadioProto, c.Channel.Txt,
c.Essid, c.Bssid, c.RadioDescription}, labels...) c.Essid, c.Bssid, c.RadioDescription}, labels...)

View File

@ -134,6 +134,7 @@ func (u *promUnifi) ScrapeHandler(w http.ResponseWriter, r *http.Request) {
Path: r.URL.Query().Get("path"), // url: "https://127.0.0.1:8443" Path: r.URL.Query().Get("path"), // url: "https://127.0.0.1:8443"
Role: r.URL.Query().Get("role"), // configured role in up.conf. Role: r.URL.Query().Get("role"), // configured role in up.conf.
}} }}
if t.Name == "" { if t.Name == "" {
u.Collector.LogErrorf("input parameter missing on scrape from %v", r.RemoteAddr) u.Collector.LogErrorf("input parameter missing on scrape from %v", r.RemoteAddr)
http.Error(w, `'input' parameter must be specified (try "unifi")`, 400) http.Error(w, `'input' parameter must be specified (try "unifi")`, 400)

View File

@ -34,7 +34,7 @@ type site struct {
} }
func descSite(ns string) *site { func descSite(ns string) *site {
labels := []string{"subsystem", "status", "site_name"} labels := []string{"subsystem", "status", "site_name", "source"}
nd := prometheus.NewDesc nd := prometheus.NewDesc
return &site{ return &site{
@ -68,7 +68,7 @@ func descSite(ns string) *site {
func (u *promUnifi) exportSite(r report, s *unifi.Site) { func (u *promUnifi) exportSite(r report, s *unifi.Site) {
for _, h := range s.Health { for _, h := range s.Health {
switch labels := []string{h.Subsystem, h.Status, s.SiteName}; labels[0] { switch labels := []string{h.Subsystem, h.Status, s.SiteName, s.SourceName}; labels[0] {
case "www": case "www":
r.send([]*metric{ r.send([]*metric{
{u.Site.TxBytesR, gauge, h.TxBytesR, labels}, {u.Site.TxBytesR, gauge, h.TxBytesR, labels},

View File

@ -80,9 +80,9 @@ type uap struct {
} }
func descUAP(ns string) *uap { func descUAP(ns string) *uap {
labelA := []string{"stat", "site_name", "name"} // stat + labels[1:] labelA := []string{"stat", "site_name", "name", "source"} // stat + labels[1:]
labelV := []string{"vap_name", "bssid", "radio", "radio_name", "essid", "usage", "site_name", "name"} labelV := []string{"vap_name", "bssid", "radio", "radio_name", "essid", "usage", "site_name", "name", "source"}
labelR := []string{"radio_name", "radio", "site_name", "name"} labelR := []string{"radio_name", "radio", "site_name", "name", "source"}
nd := prometheus.NewDesc nd := prometheus.NewDesc
return &uap{ return &uap{
@ -165,7 +165,7 @@ func (u *promUnifi) exportUAP(r report, d *unifi.UAP) {
return return
} }
labels := []string{d.Type, d.SiteName, d.Name} labels := []string{d.Type, d.SiteName, d.Name, d.SourceName}
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt}
u.exportUAPstats(r, labels, d.Stat.Ap, d.BytesD, d.TxBytesD, d.RxBytesD, d.BytesR) u.exportUAPstats(r, labels, d.Stat.Ap, d.BytesD, d.TxBytesD, d.RxBytesD, d.BytesR)
u.exportVAPtable(r, labels, d.VapTable) u.exportVAPtable(r, labels, d.VapTable)
@ -185,8 +185,8 @@ func (u *promUnifi) exportUAPstats(r report, labels []string, ap *unifi.Ap, byte
return return
} }
labelU := []string{"user", labels[1], labels[2]} labelU := []string{"user", labels[1], labels[2], labels[3]}
labelG := []string{"guest", labels[1], labels[2]} labelG := []string{"guest", labels[1], labels[2], labels[3]}
r.send([]*metric{ r.send([]*metric{
// ap only stuff. // ap only stuff.
{u.Device.BytesD, counter, bytes[0], labels}, // not sure if these 3 Ds are counters or gauges. {u.Device.BytesD, counter, bytes[0], labels}, // not sure if these 3 Ds are counters or gauges.
@ -234,7 +234,7 @@ func (u *promUnifi) exportVAPtable(r report, labels []string, vt unifi.VapTable)
continue continue
} }
labelV := []string{v.Name, v.Bssid, v.Radio, v.RadioName, v.Essid, v.Usage, labels[1], labels[2]} labelV := []string{v.Name, v.Bssid, v.Radio, v.RadioName, v.Essid, v.Usage, labels[1], labels[2], labels[3]}
r.send([]*metric{ r.send([]*metric{
{u.UAP.VAPCcq, gauge, float64(v.Ccq) / 1000.0, labelV}, {u.UAP.VAPCcq, gauge, float64(v.Ccq) / 1000.0, labelV},
{u.UAP.VAPMacFilterRejections, counter, v.MacFilterRejections, labelV}, {u.UAP.VAPMacFilterRejections, counter, v.MacFilterRejections, labelV},
@ -281,7 +281,7 @@ func (u *promUnifi) exportVAPtable(r report, labels []string, vt unifi.VapTable)
func (u *promUnifi) exportRADtable(r report, labels []string, rt unifi.RadioTable, rts unifi.RadioTableStats) { func (u *promUnifi) exportRADtable(r report, labels []string, rt unifi.RadioTable, rts unifi.RadioTableStats) {
// radio table // radio table
for _, p := range rt { for _, p := range rt {
labelR := []string{p.Name, p.Radio, labels[1], labels[2]} labelR := []string{p.Name, p.Radio, labels[1], labels[2], labels[3]}
labelRUser := append(labelR, "user") labelRUser := append(labelR, "user")
labelRGuest := append(labelR, "guest") labelRGuest := append(labelR, "guest")

View File

@ -31,7 +31,7 @@ type unifiDevice struct {
} }
func descDevice(ns string) *unifiDevice { func descDevice(ns string) *unifiDevice {
labels := []string{"type", "site_name", "name"} labels := []string{"type", "site_name", "name", "source"}
infoLabels := []string{"version", "model", "serial", "mac", "ip", "id", "bytes", "uptime"} infoLabels := []string{"version", "model", "serial", "mac", "ip", "id", "bytes", "uptime"}
return &unifiDevice{ return &unifiDevice{
@ -65,7 +65,7 @@ func (u *promUnifi) exportUDM(r report, d *unifi.UDM) {
return return
} }
labels := []string{d.Type, d.SiteName, d.Name} labels := []string{d.Type, d.SiteName, d.Name, d.SourceName}
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt}
// Shared data (all devices do this). // Shared data (all devices do this).
u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes) u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes)

View File

@ -36,7 +36,7 @@ type usg struct {
} }
func descUSG(ns string) *usg { func descUSG(ns string) *usg {
labels := []string{"port", "site_name", "name"} labels := []string{"port", "site_name", "name", "source"}
return &usg{ return &usg{
WanRxPackets: prometheus.NewDesc(ns+"wan_receive_packets_total", "WAN Receive Packets Total", labels, nil), WanRxPackets: prometheus.NewDesc(ns+"wan_receive_packets_total", "WAN Receive Packets Total", labels, nil),
@ -74,7 +74,7 @@ func (u *promUnifi) exportUSG(r report, d *unifi.USG) {
return return
} }
labels := []string{d.Type, d.SiteName, d.Name} labels := []string{d.Type, d.SiteName, d.Name, d.SourceName}
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt}
// Gateway System Data. // Gateway System Data.
@ -95,8 +95,8 @@ func (u *promUnifi) exportUSGstats(r report, labels []string, gw *unifi.Gw, st u
return return
} }
labelLan := []string{"lan", labels[1], labels[2]} labelLan := []string{"lan", labels[1], labels[2], labels[3]}
labelWan := []string{"all", labels[1], labels[2]} labelWan := []string{"all", labels[1], labels[2], labels[3]}
r.send([]*metric{ r.send([]*metric{
{u.USG.LanRxPackets, counter, gw.LanRxPackets, labelLan}, {u.USG.LanRxPackets, counter, gw.LanRxPackets, labelLan},
@ -121,7 +121,7 @@ func (u *promUnifi) exportWANPorts(r report, labels []string, wans ...unifi.Wan)
continue // only record UP interfaces. continue // only record UP interfaces.
} }
labelWan := []string{wan.Name, labels[1], labels[2]} labelWan := []string{wan.Name, labels[1], labels[2], labels[3]}
r.send([]*metric{ r.send([]*metric{
{u.USG.WanRxPackets, counter, wan.RxPackets, labelWan}, {u.USG.WanRxPackets, counter, wan.RxPackets, labelWan},

View File

@ -47,8 +47,8 @@ type usw struct {
func descUSW(ns string) *usw { func descUSW(ns string) *usw {
pns := ns + "port_" pns := ns + "port_"
labelS := []string{"site_name", "name"} labelS := []string{"site_name", "name", "source"}
labelP := []string{"port_id", "port_num", "port_name", "port_mac", "port_ip", "site_name", "name"} labelP := []string{"port_id", "port_num", "port_name", "port_mac", "port_ip", "site_name", "name", "source"}
nd := prometheus.NewDesc nd := prometheus.NewDesc
return &usw{ return &usw{
@ -97,7 +97,7 @@ func (u *promUnifi) exportUSW(r report, d *unifi.USW) {
return return
} }
labels := []string{d.Type, d.SiteName, d.Name} labels := []string{d.Type, d.SiteName, d.Name, d.SourceName}
infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt} infoLabels := []string{d.Version, d.Model, d.Serial, d.Mac, d.IP, d.ID, d.Bytes.Txt, d.Uptime.Txt}
u.exportUSWstats(r, labels, d.Stat.Sw) u.exportUSWstats(r, labels, d.Stat.Sw)
@ -161,7 +161,7 @@ func (u *promUnifi) exportPRTtable(r report, labels []string, pt []unifi.Port) {
} }
// Copy labels, and add four new ones. // Copy labels, and add four new ones.
labelP := []string{labels[2] + " Port " + p.PortIdx.Txt, p.PortIdx.Txt, p.Name, p.Mac, p.IP, labels[1], labels[2]} labelP := []string{labels[2] + " Port " + p.PortIdx.Txt, p.PortIdx.Txt, p.Name, p.Mac, p.IP, labels[1], labels[2], labels[3]}
if p.PoeEnable.Val && p.PortPoe.Val { if p.PoeEnable.Val && p.PortPoe.Val {
r.send([]*metric{ r.send([]*metric{

View File

@ -21,12 +21,12 @@ type mysqlConfig struct {
// Pointers are ignored during ENV variable unmarshal, avoid pointers to your config. // Pointers are ignored during ENV variable unmarshal, avoid pointers to your config.
// Only capital (exported) members are unmarshaled when passed into poller.NewOutput(). // Only capital (exported) members are unmarshaled when passed into poller.NewOutput().
type application struct { type plugin struct {
Config mysqlConfig `json:"mysql" toml:"mysql" xml:"mysql" yaml:"mysql"` Config mysqlConfig `json:"mysql" toml:"mysql" xml:"mysql" yaml:"mysql"`
} }
func init() { func init() {
u := &application{Config: mysqlConfig{}} u := &plugin{Config: mysqlConfig{}}
poller.NewOutput(&poller.Output{ poller.NewOutput(&poller.Output{
Name: "mysql", Name: "mysql",
@ -39,7 +39,7 @@ func main() {
fmt.Println("this is a unifi-poller plugin; not an application") fmt.Println("this is a unifi-poller plugin; not an application")
} }
func (a *application) Run(c poller.Collect) error { func (a *plugin) Run(c poller.Collect) error {
c.Logf("mysql plugin is not finished") c.Logf("mysql plugin is not finished")
return nil return nil
} }