You are mistaken. Admin can get all devices (see all
parameter).
Manage to get results for starting Nagios add-on, will share soon.
Get one unit : http://url:8082/api/devices?all=true&id=1
Get all units:
http://url:8082/api/devices?all=true
Nagios - Device online / Offline Status with RestAPI
#!/usr/bin/env python
import json
import sys
import requests
# Nagios Exit statuses
UNKNOWN = -1
OK = 0
WARNING = 1
CRITICAL = 2
uid = (sys.argv[1])
url = 'http://myurl.co.za'
user = 'admin'
password = 'password'
payload = {'all': 'true', 'id': uid}
response = requests.get(url + ':8082/api/devices', auth=(user, password), params=payload, timeout=5.000)
data = json.loads(response.content)[0]
if response.status_code != 200:
exitmessage = "UNKNOWN - "
state = UNKNOWN
value = "Unknown"
else:
if data['status'] == 'online':
exitmessage = "OK - "
state = OK
value = "Online"
elif data['status'] == 'offline':
exitmessage = "CRITICAL - "
state = CRITICAL
value = "Offline"
elif data['status'] == 'unknown':
exitmessage = "WARNING - "
state = WARNING
value = "Unknown"
print exitmessage, value, ' |'
raise SystemExit, state
Hope This Helps Someone . . .
I want to create a nagios add on that wil show all trackers status. I thought this will be easy until i saw that not even admin can get all devices through api and you can not create duplicate identifier. Any ideas?