mdlayher / edgemax

Package edgemax implements a client for Ubiquiti EdgeMAX devices. MIT Licensed.
MIT License
14 stars 2 forks source link

Fix unmarshal error in Interfaces #2

Closed vaga closed 6 years ago

vaga commented 6 years ago

Hi,

I've got an error to unmarshal Interfaces json.

json: cannot unmarshal string into Go struct field .addresses of type []string

Some interfaces have an addresses field with string instead of []string

 "eth2":
        {
            "up": "true",
            "l1up": "false",
            "autoneg": "true",
            "duplex": "half",
            "speed": "10",
            "on_switch": "false",
            "is_combo": "false",
            "is_sfp": "false",
            "mac": "xx:xx:xx:xx:xx:xx",
            "mtu": "1500",
            "addresses": "",
            "stats":
            {
                "rx_packets": "1748",
                "tx_packets": "4564",
                "rx_bytes": "292088",
                "tx_bytes": "495976",
                "rx_errors": "0",
                "tx_errors": "0",
                "rx_dropped": "0",
                "tx_dropped": "0",
                "multicast": "5",
                "rx_bps": "0",
                "tx_bps": "0"
            }
        },

Thanks for this package and edgemax_exporter package :+1:

mdlayher commented 6 years ago

LGTM, but as you've probably noticed, ubiquiti changes things on us pretty frequently, and we can't guarantee that it'll keep working. Happy to accept patches, but I've given up on trying to do EdgeMAX metrics with Prometheus myself.