fis / nano-exporter

A minimalistic exporter of node metrics for the Prometheus monitoring system.
Apache License 2.0
6 stars 1 forks source link

New collector: openwrt #1

Open fis opened 5 years ago

fis commented 5 years ago

OpenWrt has a system bus called uBus. We could add an (optional, enabled by default in the OpenWrt build) collector similar to the node_exporter systemd collector, reporting service/system statistics available over the bus.

fis commented 5 years ago

What's on the uBus?

The following dump is from a minimal OpenWrt r8614-78ca6a5578 build on Linksys WRT32X. Only potentially interesting calls (from the monitoring perspective) are included; there's a lot of calls that modify device state.

Potentially interesting calls

ubus call dnsmasq metrics

{
        "dns_cache_inserted": 547229,
        "dns_cache_live_freed": 0,
        "dns_queries_forwarded": 187265,
        "dns_auth_answered": 0,
        "dns_local_answered": 263961,
        "bootp": 0,
        "pxe": 0,
        "dhcp_ack": 107,
        "dhcp_decline": 0,
        "dhcp_discover": 45,
        "dhcp_inform": 0,
        "dhcp_nak": 0,
        "dhcp_offer": 45,
        "dhcp_release": 0,
        "dhcp_request": 107,
        "noanswer": 0,
        "leases_allocated_4": 14,
        "leases_pruned_4": 12,
        "leases_allocated_6": 0,
        "leases_pruned_6": 0
}

ubus call hostapd.wlanX get_clients

{
        "freq": 5180,
        "clients": {
                "xx:xx:xx:xx": { auth, assoc, authorized, preauth, wds, wmm, ht, vht, wps, mfp, rrm, aid },
                ...
        }
}

ubus call {network.device status / network.interface.X status}

These are more or less redundant with the netdev collector, so probably don't need to be included.

ubus call network.wireless status

Mostly static state, not so interesting as metrics. Though the radioX.config.channel might be a plausible metric, if it reflects an automatically assigned channel state.

ubus call service list

{
        ...,
        "nano-exporter": {
                "instances": {
                        "instance1": {
                                "running": true,
                                "pid": 11606,
                                "command": [
                                        "\/usr\/sbin\/nano-exporter",
                                        "--foreground"
                                ],
                                "term_timeout": 5
                        }
                }
        },
        ...

ubus call system board

{
        "kernel": "4.14.82",
        "hostname": "OpenWrt",
        "system": "ARMv7 Processor rev 1 (v7l)",
        "model": "Linksys WRT32X",
        "board_name": "armada-385-linksys-venom",
        "release": {
                "distribution": "OpenWrt",
                "version": "SNAPSHOT",
                "revision": "r8614-78ca6a5578",
                "target": "mvebu\/cortexa9",
                "description": "OpenWrt SNAPSHOT r8614-78ca6a5578"
        }
}

ubus call system info

{
        "localtime": 1543982110,
        "uptime": 345449,
        "load": [
                0,
                0,
                0
        ],
        "memory": {
                "total": 523218944,
                "free": 330235904,
                "shared": 102400,
                "buffered": 3940352
        },
        "swap": {
                "total": 0,
                "free": 0
        }
}
fis commented 5 years ago

Possible metrics