Skip to content

Commit 1cdc9fd

Browse files
committed
add health function
returns site health info
1 parent d38f3e1 commit 1cdc9fd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

ubiquiti/unifi.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,32 @@ def list_clients(self, filters: Dict[str, Union[str, Pattern]]=None, order_by: s
9898
data = sorted(data, key=lambda x: x[order_by] if order_by in x.keys() else x['_id'])
9999

100100
return data
101+
102+
def health(self) -> dict:
103+
"""
104+
List site health information.
105+
:return: A dict of network health information (see below)
106+
num_adopted
107+
num_ap
108+
num_disabled
109+
num_disconnected
110+
num_guest
111+
num_iot
112+
num_pending
113+
num_user
114+
rx_bytes-r
115+
status
116+
subsystem
117+
tx_bytes-r
118+
"""
119+
r = self._session.get("{}/api/s/{}/stat/health".format(self._baseurl, self._site, verify=False), data="json={}")
120+
self._current_status_code = r.status_code
121+
if self._current_status_code == 401:
122+
raise LoggedInException("Invalid login, or login has expired")
123+
124+
data = r.json()['data']
125+
126+
return data[0]
101127
if self._current_status_code == 401:
102128
raise LoggedInException("Invalid login, or login has expired")
103129

0 commit comments

Comments
 (0)