Hallo Zusammen nach etwas Abstinenz wieder mal da
Folgendes wenn ich ein Gerät überwachen will und die Daten nicht via SNMP sondern via REST API abfragen will wie fange ich am besten an ???
Der allgemeine Ablauf ist ja so:
CMK --[runs]–> script --[calls REST API]–> Host --[JSON answer]–> script --[converts to cmk format]–> CMK --[sends output]–> check plugin --[processes output]–> CMK --[creates]–> services <–[Parameters]-- WATO rule plugin
Die Abfrage wäre ja z.B.
curl -v -X GET -u <username>:<password> "http://192.168.1.1/appAll.json"
der Output sieht so aus:
API Response Details
API Response Details:
Response content type: 'application/json'
Response Sample Format:
{
"data": {
"all": [{
"device": {
"unit": "Device-8106",
"model": "E-MICRO-T(RHP) ",
"uptime": "3 days, 2 hours, 8 mins",
"firmware": "3.1"
}
},
{
"network": {
"mac": "00:0c:82:00:00:06",
"dhcp": 0,
"addr": "192.168.1.1",
"mask": "255.255.255.0",
"gtw": "192.168.1.0",
"dns1": "192.168.1.52",
"dns2": "192.168.1.53"
}
},
{
"isens": [{
"idx": 0,
"desc": "temperature",
"type": 1,
"unit": 0,
"val": "30.5 C"
}, {
"idx": 1,
"desc": "Humidity1",
"type": 2,
NOTE: API commands are case sensitive
NTI Micro Environment Monitoring System
53
"unit": 0,
"val": "35.5 %"
}, {
"idx": 2,
"desc": "Dew Point",
"type": 24,
"unit": 0,
"val": "13.6 C"
}]
},
{
"esens": [{
"idx": 0,
"desc": "Temperature #1",
"type": 1,
"unit": 0,
"val": "27.9 C"
}, {
"idx": 1,
"desc": "Humidity #1",
"type": 2,
"unit": 0,
"val": "39.2 %"
}, {
"idx": 2,
"desc": "Dew Point #1",
"type": 24,
"unit": 0,
"val": "12.7 C"
}, {
"idx": 3,
"desc": "Temperature #2",
"type": 1,
"unit": 0,
"val": "27.8 C"
}, {
"idx": 4,
"desc": "Humidity #2",
"type": 2,
"unit": 0,
"val": "39.8 %"
}, {
"idx": 5,
"desc": "Dew Point #2",
"type": 24,
"unit": 0,
"val": "12.9 C"
}]
},
{
"diginp": [{
"idx": 0,
"desc": "Digital Input #1",
"type": 19,
"val": "Open"
}, {
"idx": 1,
"desc": "Digital Input #2",
"type": 19,
"val": "Open"
}]
},
{
"ipdev": [{
"idx": 0,
"desc": "IP Device #1",
"ip": "8.8.8.8",
"val": "Responding",
"retries": 3,
"timeout": 5,
"repeat": 60
NTI Micro Environment Monitoring System
54
}]
},
{
"alerts": [{
"idx": 0,
"sensor": "Humidity1",
"status": "2",
"alertMsg": "Sensor value greater than 25.0",
"alertStatus": "Alarm",
"val": "35.5 %",
"sensorType": 1,
"sensorClass": 0,
"sensorId": 1
}]
},
{
"smalerts": [{
"idx": 0,
"status": "Alarm"
}]
}
]
},
"msg": "Request Successful",
"code": 200
}
Wie bekomme ich nun die Infos zu einem Check bzw. Metric zugeteilt?
Kennt einer einen Beispiel Check oder so der die REST-API eines Gerätes abfragt und verarbeitet ???
Beschreibung der API ab Seite 52
lG Bernd