mirror of
https://github.com/bashclub/check-unifi-controller.git
synced 2025-07-03 22:59:09 +02:00
Initial Version 0.75
This commit is contained in:
209
share/check_mk/web/plugins/metrics/unifi_metrics.py
Normal file
209
share/check_mk/web/plugins/metrics/unifi_metrics.py
Normal file
@ -0,0 +1,209 @@
|
||||
from cmk.gui.i18n import _
|
||||
from cmk.gui.plugins.metrics import (
|
||||
metric_info,
|
||||
graph_info,
|
||||
translation
|
||||
)
|
||||
|
||||
|
||||
# Colors:
|
||||
#
|
||||
# red
|
||||
# magenta orange
|
||||
# 11 12 13 14 15 16
|
||||
# 46 21
|
||||
# 45 22
|
||||
# blue 44 23 yellow
|
||||
# 43 24
|
||||
# 42 25
|
||||
# 41 26
|
||||
# 36 35 34 33 32 31
|
||||
# cyan yellow-green
|
||||
# green
|
||||
#
|
||||
# Special colors:
|
||||
# 51 gray
|
||||
# 52 brown 1
|
||||
# 53 brown 2
|
||||
#
|
||||
# For a new metric_info you have to choose a color. No more hex-codes are needed!
|
||||
# Instead you can choose a number of the above color ring and a letter 'a' or 'b
|
||||
# where 'a' represents the basic color and 'b' is a nuance/shading of the basic color.
|
||||
# Both number and letter must be declared!
|
||||
#
|
||||
# Example:
|
||||
# "color" : "23/a" (basic color yellow)
|
||||
# "color" : "23/b" (nuance of color yellow)
|
||||
#
|
||||
|
||||
|
||||
metric_info["satisfaction"] = {
|
||||
"title": _("Satisfaction"),
|
||||
"unit": "%",
|
||||
"color": "16/a",
|
||||
}
|
||||
|
||||
metric_info["poe_current"] = {
|
||||
"title": _("PoE Current"),
|
||||
"unit": "a",
|
||||
"color": "16/a",
|
||||
}
|
||||
metric_info["poe_voltage"] = {
|
||||
"title": _("PoE Voltage"),
|
||||
"unit": "v",
|
||||
"color": "12/a",
|
||||
}
|
||||
metric_info["poe_power"] = {
|
||||
"title": _("PoE Power"),
|
||||
"unit": "w",
|
||||
"color": "16/a",
|
||||
}
|
||||
|
||||
metric_info["user_sta"] = {
|
||||
"title": _("User"),
|
||||
"unit": "",
|
||||
"color": "13/b",
|
||||
}
|
||||
metric_info["guest_sta"] = {
|
||||
"title": _("Guest"),
|
||||
"unit": "",
|
||||
"color": "13/a",
|
||||
}
|
||||
|
||||
graph_info["user_sta_combined"] = {
|
||||
"title" : _("User"),
|
||||
"metrics" : [
|
||||
("user_sta","area"),
|
||||
("guest_sta","stack"),
|
||||
],
|
||||
}
|
||||
|
||||
metric_info["lan_user_sta"] = {
|
||||
"title": _("LAN User"),
|
||||
"unit": "count",
|
||||
"color": "13/b",
|
||||
}
|
||||
metric_info["lan_guest_sta"] = {
|
||||
"title": _("LAN Guest"),
|
||||
"unit": "count",
|
||||
"color": "13/a",
|
||||
}
|
||||
|
||||
graph_info["lan_user_sta_combined"] = {
|
||||
"title" : _("LAN-User"),
|
||||
"metrics" : [
|
||||
("lan_user_sta","area"),
|
||||
("lan_guest_sta","stack"),
|
||||
],
|
||||
}
|
||||
|
||||
metric_info["wlan_user_sta"] = {
|
||||
"title": _("WLAN User"),
|
||||
"unit": "count",
|
||||
"color": "13/b",
|
||||
}
|
||||
metric_info["wlan_guest_sta"] = {
|
||||
"title": _("WLAN Guest"),
|
||||
"unit": "count",
|
||||
"color": "13/a",
|
||||
}
|
||||
metric_info["wlan_iot_sta"] = {
|
||||
"title": _("WLAN IoT Devices"),
|
||||
"unit": "count",
|
||||
"color": "14/a",
|
||||
}
|
||||
|
||||
graph_info["wlan_user_sta_combined"] = {
|
||||
"title" : _("WLAN-User"),
|
||||
"metrics" : [
|
||||
("wlan_user_sta","area"),
|
||||
("wlan_guest_sta","stack"),
|
||||
("wlan_iot_sta","stack"),
|
||||
],
|
||||
}
|
||||
|
||||
metric_info["wlan_24Ghz_num_user"] = {
|
||||
"title": _("User 2.4Ghz"),
|
||||
"unit": "count",
|
||||
"color": "13/b",
|
||||
}
|
||||
metric_info["wlan_5Ghz_num_user"] = {
|
||||
"title": _("User 5Ghz"),
|
||||
"unit": "count",
|
||||
"color": "13/a",
|
||||
}
|
||||
|
||||
graph_info["wlan_user_band_combined"] = {
|
||||
"title" : _("WLAN User"),
|
||||
"metrics" : [
|
||||
("wlan_24Ghz_num_user","area"),
|
||||
("wlan_5Ghz_num_user","stack"),
|
||||
],
|
||||
}
|
||||
|
||||
#na_avg_client_signal
|
||||
#ng_avg_client_signal
|
||||
|
||||
|
||||
metric_info["wlan_if_in_octets"] = {
|
||||
"title": _("Input Octets"),
|
||||
"unit": "bytes/s",
|
||||
"color": "#00e060",
|
||||
}
|
||||
metric_info["wlan_if_out_octets"] = {
|
||||
"title": _("Output Octets"),
|
||||
"unit": "bytes/s",
|
||||
"color": "#00e060",
|
||||
}
|
||||
graph_info["wlan_bandwidth_translated"] = {
|
||||
"title": _("Bandwidth WLAN"),
|
||||
"metrics": [
|
||||
("wlan_if_in_octets,8,*@bits/s", "area", _("Input bandwidth")),
|
||||
("wlan_if_out_octets,8,*@bits/s", "-area", _("Output bandwidth")),
|
||||
],
|
||||
"scalars": [
|
||||
("if_in_octets:warn", _("Warning (In)")),
|
||||
("if_in_octets:crit", _("Critical (In)")),
|
||||
("if_out_octets:warn,-1,*", _("Warning (Out)")),
|
||||
("if_out_octets:crit,-1,*", _("Critical (Out)")),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
metric_info["na_avg_client_signal"] = {
|
||||
"title" :_("Average Signal 5Ghz"),
|
||||
"unit" : "db",
|
||||
"color" : "14/a",
|
||||
}
|
||||
metric_info["ng_avg_client_signal"] = {
|
||||
"title" :_("Average Signal 2.4Ghz"),
|
||||
"unit" : "db",
|
||||
"color" : "#80f000",
|
||||
}
|
||||
graph_info["avg_client_signal_combined"] = {
|
||||
"title" : _("Average Client Signal"),
|
||||
"metrics" : [
|
||||
("na_avg_client_signal","line"),
|
||||
("ng_avg_client_signal","line"),
|
||||
],
|
||||
"range" : (-100,0)
|
||||
}
|
||||
|
||||
|
||||
## different unit ???
|
||||
#graph_info["poe_usage_combined"] = {
|
||||
# "title" : _("PoE Usage"),
|
||||
# "metrics" : [
|
||||
# ("poe_power","area"),
|
||||
# ("poe_voltage","line"),
|
||||
# ],
|
||||
#}
|
||||
|
||||
### fixme default uptime translation?
|
||||
metric_info["unifi_uptime"] = {
|
||||
"title" :_("Uptime"),
|
||||
"unit" : "s",
|
||||
"color" : "#80f000",
|
||||
}
|
||||
|
||||
check_metrics["check_mk-unifi_network_ports_if"] = translation.if_translation
|
15
share/check_mk/web/plugins/perfometer/unifi_performeter.py
Normal file
15
share/check_mk/web/plugins/perfometer/unifi_performeter.py
Normal file
@ -0,0 +1,15 @@
|
||||
from cmk.gui.plugins.metrics import perfometer_info
|
||||
|
||||
perfometer_info.append({
|
||||
"type": "linear",
|
||||
"segments": ["satisfaction"],
|
||||
"total": 100.0,
|
||||
})
|
||||
|
||||
perfometer_info.append({
|
||||
"type": "logarithmic",
|
||||
"metric": "unifi_uptime",
|
||||
"half_value": 2592000.0,
|
||||
"exponent": 2,
|
||||
})
|
||||
|
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- encoding: utf-8; py-indent-offset: 4 -*-
|
||||
|
||||
from cmk.gui.i18n import _
|
||||
from cmk.gui.plugins.wato import (
|
||||
HostRulespec,
|
||||
IndividualOrStoredPassword,
|
||||
rulespec_registry,
|
||||
)
|
||||
from cmk.gui.valuespec import (
|
||||
Dictionary,
|
||||
Alternative,
|
||||
NetworkPort,
|
||||
Checkbox,
|
||||
TextAscii,
|
||||
)
|
||||
|
||||
from cmk.gui.plugins.wato.datasource_programs import RulespecGroupDatasourceProgramsHardware
|
||||
|
||||
def _valuespec_special_agent_unifi_controller():
|
||||
return Dictionary(
|
||||
title = _('Unifi Controller via API'),
|
||||
help = _('This rule selects the Unifi API agent'),
|
||||
optional_keys=['site'],
|
||||
elements=[
|
||||
('user',TextAscii(title = _('API Username.'),allow_empty = False,)),
|
||||
('password',IndividualOrStoredPassword(title = _('API password'),allow_empty = False,)),
|
||||
('site',TextAscii(title = _('Site Name'),allow_empty = False,default_value='default')), ## optional but not empty
|
||||
('port',NetworkPort(title = _('Port'),default_value = 443)),
|
||||
('ignore_cert', Checkbox(title=_("Ignore certificate validation"), default_value=False)),
|
||||
('piggyback',
|
||||
Alternative(
|
||||
title = _('Receive piggyback data by'),
|
||||
elements = [
|
||||
FixedValue("name", title = _("Hostname")),
|
||||
FixedValue("ip", title = _("IP")),
|
||||
FixedValue("none", title = _("None")),
|
||||
],
|
||||
default_value = "name"
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
rulespec_registry.register(
|
||||
HostRulespec(
|
||||
group=RulespecGroupDatasourceProgramsHardware,
|
||||
#IMPORTANT, name must follow special_agents:<name>,
|
||||
#where filename of our special agent located in path local/share/check_mk/agents/special/ is agent_<name>
|
||||
name='special_agents:unifi_controller',
|
||||
valuespec=_valuespec_special_agent_unifi_controller,
|
||||
))
|
Reference in New Issue
Block a user