Closed UrbanDavid closed 1 year ago
Hi @UrbanDavid. Please provide some more details about your python environment or the controller itself:
python -V
pip list
curl -k https://$controller_ip/status
Hi,
same error here.
Command: ./check_unifi.py --host 10.x.x.x --user monitoring --password secret --port 443 --ssl --insecure
Error:
Traceback (most recent call last):
File "/usr/lib/nagios/plugins/./check_unifi.py", line 292, in
Python: Python 3.9.2
Curl on https://ip/status: <!doctype html>
I have a hunch that you are not dealing with the UniFi Network Application. Do you have a appliance? Because i developed this check against the UniFi Network Application.
Hi, I use UDM Pro, but the Network Appliance part should be the same, shouldn't it?
The REST endpoints seems to be different. Unfortunately, since i don't have a HW appliance so i can't test this.
Thanks for your reply. May be we can work on this together?
When i curl the API with /api/auth/login I get this back:
curl -k -X POST --data '{"username": "monitoring", "password": "xxxxxxxxxxxxx"}' --header 'Content-Type: application/json' -b cookie.txt https://10.10.10.1:443/api/auth/login
{
"unique_id": "3833fc1c-9ca6-407a-a225-xxxxxxxxxxxxx",
"first_name": "Icinga",
"last_name": "Monitor",
"full_name": "Icinga Monitor",
"email": "",
"email_status": "UNVERIFIED",
"email_is_null": true,
"phone": "",
"avatar_relative_path": "",
"avatar_rpath2": "",
"status": "ACTIVE",
"employee_number": "",
"create_time": 1677574770,
"extras": {},
"login_time": 1677577904,
"username": "monitoring",
"local_account_exist": true,
"password_revision": 1677624143,
"sso_account": "",
"sso_uuid": "",
"sso_username": "",
"sso_picture": "",
"uid_sso_id": "",
"uid_sso_account": "",
"groups": [
{
"unique_id": "0f6bf923-4646-4202-9542-xxxxxxxxxxxxx",
"name": "Dream Machine Pro",
"up_id": "",
"up_ids": [],
"system_name": "Dream Machine Pro",
"create_time": "2021-10-04T21:06:13+02:00"
}
],
"roles": [
{
"unique_id": "6cccd773-45a6-4e2b-86dd-xxxxxxxxxxxxx",
"name": "Viewer",
"system_role": true,
"system_key": "viewer",
"level": 4,
"create_time": "2021-10-04T21:00:58+02:00",
"update_time": "2021-10-04T21:00:58+02:00"
}
],
"permissions": {
"access.management": [
"readonly"
],
"led.management": [
"readonly"
],
"network.management": [
"readonly"
],
"protect.management": [
"readonly"
],
"system.management.location": [
"readonly"
],
"system.management.user": [
"readonly"
],
"talk.management": [
"readonly"
]
},
"scopes": [
"write:protect.user:$",
"view:user_timezone",
"view:user",
"view:systemlog",
"view:settings",
"view:role",
"view:permission",
"view:notification",
"view:location_policy",
"view:location_device",
"view:location_activity",
"view:location",
"view:holiday_timezone",
"view:holiday",
"view:group",
"view:door_group",
"view:controller:talk",
"view:controller:protect",
"view:controller:network",
"view:controller:led",
"view:controller:access",
"view:cloud_access",
"view:app:users",
"view:app:settings",
"view:app:locations",
"view:access:user",
"view:access.visitor",
"view:access.systemlog",
"view:access.settings",
"view:access.schedule",
"view:access.policy",
"view:access.pin_code",
"view:access.nfc_card",
"view:access.face",
"view:access.device",
"view:access.dashboard",
"systemlog:user",
"systemlog:system",
"systemlog:location",
"systemlog:access",
"readmedia:protect.camera",
"read:protect.viewer",
"read:protect.user:$",
"read:protect.sensor",
"read:protect.nvr",
"read:protect.light",
"read:protect.doorlock",
"read:protect.display",
"read:protect.deviceGroup",
"read:protect.chime",
"read:protect.camera",
"read:protect.bridge",
"read:network-site:all",
"read:network-site:615b4f998ba8a2068e4f260a",
"notify:user",
"notify:location",
"notify:access",
"edit:feedback",
"delete:protect.user:$",
"create:protect.liveview"
],
"cloud_access_granted": false,
"update_time": 1677624143,
"avatar": null,
"nfc_token": "",
"nfc_display_id": "",
"nfc_card_type": "",
"nfc_card_status": "",
"id": "3833fc1c-9ca6-407a-a225-xxxxxxxxxxxxx",
"isOwner": false,
"isSuperAdmin": false,
"isMember": false,
"deviceToken": "xxxxxxxxxxxxx",
"ssoAuth": {}
Here is an (unoffical) documentation of UDM Pro API: https://ubntwiki.com/products/software/unifi-controller/api#controller_endpoints
Sorry for my late reply. I would appreciate the cooperation very much, because unfortunately I can not test against the UDM device. I suggest to close the issue and create a new issue for it as a feature request.
Dear I found you plugin and I am trying to configure it.
I am using linux distribution centos. I installed: pip2 install requests
If I am trying to run command : /usr/lib64/nagios/plugins/check_unifi.py --host xx.xx.xx.xx --port 443 --ssl --insecure
I got error:
Traceback (most recent call last): File "/usr/lib64/nagios/plugins/check_unifi.py", line 291, in
main()
File "/usr/lib64/nagios/plugins/check_unifi.py", line 285, in main
fmt_output(check_health(args))
File "/usr/lib64/nagios/plugins/check_unifi.py", line 138, in check_health
blob = resp.json() if resp.json() else {}
File "/usr/lib/python3.6/site-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib64/python3.6/json/init.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Thank you