Skip to content
Snippets Groups Projects
Unverified Commit 028b1998 authored by Nico's avatar Nico
Browse files

expose zyxel location

parent 46f3d9b4
No related branches found
No related tags found
No related merge requests found
......@@ -28,10 +28,11 @@ class ZyxelCollector:
self.targets = targets
def collect(self):
channel = prometheus_client.core.InfoMetricFamily("channel", "Channel the radio is operating on", labels=["ap", "ip", "radio"])
client_count = prometheus_client.core.GaugeMetricFamily('client_count', "Number of clients on this radio", labels=["ap", "ip", "radio"])
uptime = prometheus_client.core.GaugeMetricFamily('zyxel_uptime', "Number of seconds device is running", labels=["ap", "ip", "radio"])
util = prometheus_client.core.GaugeMetricFamily('zyxel_chan_util', "Utilization of radio channel", labels=["ap", "ip", "radio"])
labels = ["ap", "ip", "radio", "location"]
channel = prometheus_client.core.InfoMetricFamily("channel", "Channel the radio is operating on", labels=labels)
client_count = prometheus_client.core.GaugeMetricFamily('client_count', "Number of clients on this radio", labels=labels)
uptime = prometheus_client.core.GaugeMetricFamily('zyxel_uptime', "Number of seconds device is running", labels=labels)
util = prometheus_client.core.GaugeMetricFamily('zyxel_chan_util', "Utilization of radio channel", labels=labels)
for target in self.targets:
try:
......@@ -40,10 +41,11 @@ class ZyxelCollector:
stats = c.collect()
for stat in stats:
client_count.add_metric([stat.hostname, stat.ip, stat.type], stat.client_count)
channel.add_metric([stat.hostname, stat.ip, stat.type], {"channel": stat.channel})
uptime.add_metric([stat.hostname, stat.ip, stat.type], stat.uptime)
util.add_metric([stat.hostname, stat.ip, stat.type], stat.util)
label_values = [stat.hostname, stat.ip, stat.type, stat.location]
client_count.add_metric(label_values, stat.client_count)
channel.add_metric(label_values, {"channel": stat.channel})
uptime.add_metric(label_values, stat.uptime)
util.add_metric(label_values, stat.util)
c.close()
logging.info("Done scaping for %s", target["host"])
except Exception as e:
......
......@@ -7,6 +7,7 @@ TYPE_5G = "5ghz"
@dataclass
class WifiStats:
hostname : str
location : str
ip : str
uptime : int
channel : str
......
......@@ -52,6 +52,32 @@ class ZyxelClient:
_, ip = line.split(":", maxsplit=1)
ip = ip.strip()
"""
Router> show snmp status
active : no
port : 161
version : v2c
contact : support@zyxel.com.tw
location : Infozelt
get community : public
set community : private
trap : no
informs : no
trap host : none
trap community: public
wireless trap : no
"""
resp = self._run_cmd("show snmp status")
for line in resp.split("\n"):
line = line.strip()
if line.startswith("location"):
_, location = line.split(":", maxsplit=1)
location = location.strip()
"""
Router> show system uptime
system uptime: 05:01:57
"""
resp = self._run_cmd("show system uptime")
for line in resp.split("\n"):
line = line.strip()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment