mirror of
https://github.com/bashclub/check-unifi-controller.git
synced 2024-11-07 20:31:58 +01:00
Update to 0.83
This commit is contained in:
parent
1573ea24c2
commit
7c039651c2
@ -158,7 +158,7 @@ def discovery_unifi_sites(section):
|
|||||||
for _item in section.values():
|
for _item in section.values():
|
||||||
yield Service(item=f"{_item.desc}")
|
yield Service(item=f"{_item.desc}")
|
||||||
|
|
||||||
def check_unifi_sites(item,section):
|
def check_unifi_sites(item,params,section):
|
||||||
site = next(filter(lambda x: x.desc == item,section.values()))
|
site = next(filter(lambda x: x.desc == item,section.values()))
|
||||||
yield Metric("satisfaction",max(0,_safe_int(site.satisfaction)))
|
yield Metric("satisfaction",max(0,_safe_int(site.satisfaction)))
|
||||||
|
|
||||||
@ -169,7 +169,8 @@ def check_unifi_sites(item,section):
|
|||||||
#yield Metric("if_in_bps",_safe_int(site.lan_rx_bytes_r)*8)
|
#yield Metric("if_in_bps",_safe_int(site.lan_rx_bytes_r)*8)
|
||||||
yield Metric("if_out_octets",_safe_int(site.lan_tx_bytes_r))
|
yield Metric("if_out_octets",_safe_int(site.lan_tx_bytes_r))
|
||||||
#yield Metric("if_out_bps",_safe_int(site.lan_tx_bytes_r)*8)
|
#yield Metric("if_out_bps",_safe_int(site.lan_tx_bytes_r)*8)
|
||||||
|
yield Metric("lan_active_sw",_safe_int(site.lan_num_sw))
|
||||||
|
yield Metric("lan_total_sw",_safe_int(site.lan_num_adopted))
|
||||||
yield Result(
|
yield Result(
|
||||||
state=_unifi_status2state(site.lan_status),
|
state=_unifi_status2state(site.lan_status),
|
||||||
summary=f"LAN: {site.lan_num_sw}/{site.lan_num_adopted} Switch ({site.lan_status})"
|
summary=f"LAN: {site.lan_num_sw}/{site.lan_num_adopted} Switch ({site.lan_status})"
|
||||||
@ -185,6 +186,8 @@ def check_unifi_sites(item,section):
|
|||||||
yield Metric("wlan_iot_sta",_safe_int(site.wlan_num_iot))
|
yield Metric("wlan_iot_sta",_safe_int(site.wlan_num_iot))
|
||||||
yield Metric("wlan_if_in_octets",_safe_int(site.wlan_rx_bytes_r))
|
yield Metric("wlan_if_in_octets",_safe_int(site.wlan_rx_bytes_r))
|
||||||
yield Metric("wlan_if_out_octets",_safe_int(site.wlan_tx_bytes_r))
|
yield Metric("wlan_if_out_octets",_safe_int(site.wlan_tx_bytes_r))
|
||||||
|
yield Metric("wlan_active_ap",_safe_int(site.wlan_num_ap))
|
||||||
|
yield Metric("wlan_total_ap",_safe_int(site.wlan_num_adopted))
|
||||||
yield Result(
|
yield Result(
|
||||||
state=_unifi_status2state(site.wlan_status),
|
state=_unifi_status2state(site.wlan_status),
|
||||||
summary=f"WLAN: {site.wlan_num_ap}/{site.wlan_num_adopted} AP ({site.wlan_status})"
|
summary=f"WLAN: {site.wlan_num_ap}/{site.wlan_num_adopted} AP ({site.wlan_status})"
|
||||||
@ -208,8 +211,14 @@ def check_unifi_sites(item,section):
|
|||||||
state=_unifi_status2state(site.vpn_status),
|
state=_unifi_status2state(site.vpn_status),
|
||||||
notice=f"WWW Status: {site.vpn_status}"
|
notice=f"WWW Status: {site.vpn_status}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if params.get("ignore_alarms"):
|
||||||
|
_alarmstate = State.OK
|
||||||
|
else:
|
||||||
|
_alarmstate = _expect_number(site.num_new_alarms)
|
||||||
|
|
||||||
yield Result(
|
yield Result(
|
||||||
state=_expect_number(site.num_new_alarms),
|
state=_alarmstate,
|
||||||
notice=f"{site.num_new_alarms} new Alarm"
|
notice=f"{site.num_new_alarms} new Alarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -223,6 +232,8 @@ register.check_plugin(
|
|||||||
name='unifi_sites',
|
name='unifi_sites',
|
||||||
service_name='Site %s',
|
service_name='Site %s',
|
||||||
discovery_function=discovery_unifi_sites,
|
discovery_function=discovery_unifi_sites,
|
||||||
|
check_default_parameters={},
|
||||||
|
check_ruleset_name="unifi_sites",
|
||||||
check_function=check_unifi_sites,
|
check_function=check_unifi_sites,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -258,6 +269,7 @@ register.inventory_plugin(
|
|||||||
|
|
||||||
############ DEVICE ###########
|
############ DEVICE ###########
|
||||||
def discovery_unifi_device(section):
|
def discovery_unifi_device(section):
|
||||||
|
yield Service(item="Device Status")
|
||||||
yield Service(item="Unifi Device")
|
yield Service(item="Unifi Device")
|
||||||
yield Service(item="Uptime")
|
yield Service(item="Uptime")
|
||||||
yield Service(item="Active-User")
|
yield Service(item="Active-User")
|
||||||
@ -271,8 +283,16 @@ def discovery_unifi_device(section):
|
|||||||
yield Service(item="Speedtest")
|
yield Service(item="Speedtest")
|
||||||
|
|
||||||
def check_unifi_device(item,section):
|
def check_unifi_device(item,section):
|
||||||
if section.state != "1":
|
_device_state = UNIFI_DEVICE_STATES.get(section.state,"unknown")
|
||||||
yield IgnoreResults(f"device not active State: {section.state}")
|
## connected OK / pending Warn / Rest Crit
|
||||||
|
_hoststatus = State.OK if section.state == "1" else State.WARN if section.state == "2" else State.CRIT
|
||||||
|
if item == "Device Status":
|
||||||
|
yield Result(
|
||||||
|
state=_hoststatus,
|
||||||
|
summary=f"Status: {_device_state}"
|
||||||
|
)
|
||||||
|
#if section.state != "1":
|
||||||
|
# yield IgnoreResults(f"device not active State: {section.state}")
|
||||||
|
|
||||||
if item == "Unifi Device":
|
if item == "Unifi Device":
|
||||||
yield Result(
|
yield Result(
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
## SOFTWARE.
|
## SOFTWARE.
|
||||||
|
|
||||||
###
|
###
|
||||||
__VERSION__ = 0.80
|
__VERSION__ = 0.83
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
@ -591,7 +591,7 @@ class unifi_controller_api(object):
|
|||||||
def request(self,method,url=None,path=None,site=None,json=None,**kwargs):
|
def request(self,method,url=None,path=None,site=None,json=None,**kwargs):
|
||||||
if not url:
|
if not url:
|
||||||
if self.is_unifios:
|
if self.is_unifios:
|
||||||
url = f"{self.url}/proxy/network/api/"
|
url = f"{self.url}/proxy/network/api"
|
||||||
else:
|
else:
|
||||||
url = f"{self.url}/api"
|
url = f"{self.url}/api"
|
||||||
if site is not None:
|
if site is not None:
|
||||||
|
@ -121,6 +121,44 @@ graph_info["lan_user_sta_combined"] = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
metric_info["lan_active_sw"] = {
|
||||||
|
"title": _("Active Switches"),
|
||||||
|
"unit": "count",
|
||||||
|
"color": "13/b",
|
||||||
|
}
|
||||||
|
metric_info["lan_total_sw"] = {
|
||||||
|
"title": _("Total Switches"),
|
||||||
|
"unit": "count",
|
||||||
|
"color": "13/a",
|
||||||
|
}
|
||||||
|
|
||||||
|
graph_info["lan_active_sw_combined"] = {
|
||||||
|
"title" : _("Active Switches"),
|
||||||
|
"metrics" : [
|
||||||
|
("lan_active_sw","area"),
|
||||||
|
("lan_total_sw","line"),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
metric_info["wlan_active_ap"] = {
|
||||||
|
"title": _("Active Accesspoints"),
|
||||||
|
"unit": "count",
|
||||||
|
"color": "13/b",
|
||||||
|
}
|
||||||
|
metric_info["wlan_total_ap"] = {
|
||||||
|
"title": _("Total Accesspoints"),
|
||||||
|
"unit": "count",
|
||||||
|
"color": "13/a",
|
||||||
|
}
|
||||||
|
|
||||||
|
graph_info["wlan_active_ap_combined"] = {
|
||||||
|
"title" : _("Active Accesspoints"),
|
||||||
|
"metrics" : [
|
||||||
|
("wlan_active_ap","area"),
|
||||||
|
("wlan_total_ap","line"),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
metric_info["wlan_user_sta"] = {
|
metric_info["wlan_user_sta"] = {
|
||||||
"title": _("WLAN User"),
|
"title": _("WLAN User"),
|
||||||
"unit": "count",
|
"unit": "count",
|
||||||
|
@ -25,11 +25,13 @@
|
|||||||
from cmk.gui.i18n import _
|
from cmk.gui.i18n import _
|
||||||
from cmk.gui.plugins.wato import (
|
from cmk.gui.plugins.wato import (
|
||||||
HostRulespec,
|
HostRulespec,
|
||||||
|
CheckParameterRulespecWithItem,
|
||||||
IndividualOrStoredPassword,
|
IndividualOrStoredPassword,
|
||||||
rulespec_registry,
|
rulespec_registry,
|
||||||
)
|
)
|
||||||
from cmk.gui.valuespec import (
|
from cmk.gui.valuespec import (
|
||||||
Dictionary,
|
Dictionary,
|
||||||
|
Tuple,
|
||||||
Alternative,
|
Alternative,
|
||||||
NetworkPort,
|
NetworkPort,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
@ -72,3 +74,28 @@ rulespec_registry.register(
|
|||||||
valuespec=_valuespec_special_agent_unifi_controller,
|
valuespec=_valuespec_special_agent_unifi_controller,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
def _item_spec_unifi_site():
|
||||||
|
return TextAscii(
|
||||||
|
title=_("Site"),
|
||||||
|
help=_("help Site Text")
|
||||||
|
)
|
||||||
|
|
||||||
|
def _parameter_valuespec_unifi_site():
|
||||||
|
return Dictionary(
|
||||||
|
title = _("Unifi Site"),
|
||||||
|
optional_keys=[],
|
||||||
|
elements = [
|
||||||
|
('ignore_alarms', Checkbox(title=_("Ignore Site Alarms"), default_value=False)),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
rulespec_registry.register(
|
||||||
|
CheckParameterRulespecWithItem(
|
||||||
|
check_group_name = "unifi_sites",
|
||||||
|
group=RulespecGroupCheckParametersNetworking,
|
||||||
|
item_spec = _item_spec_unifi_site,
|
||||||
|
match_type = "dict",
|
||||||
|
parameter_valuespec=_parameter_valuespec_unifi_site,
|
||||||
|
title=lambda: _("Unifi Site Parameter")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user