Skip to content

Commit d349bd8

Browse files
author
Anze
committed
Include sensor data
1 parent 548b740 commit d349bd8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

grafolean-worker-snmp.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,23 @@ def fetch_accounts_entities(self, protocol):
3737

3838
credential = None
3939
if entity_info["protocols"][protocol]["credential"]:
40-
credential_id = entity_info["protocols"]["snmp"]["credential"]
40+
credential_id = entity_info["protocols"][protocol]["credential"]
4141
r = requests.get('{}/accounts/{}/credentials/{}?b={}'.format(self.backend_url, account_id, credential_id, self.bot_token))
4242
if r.status_code != 200:
4343
raise Exception("Network error, got status {} while retrieving {}/accounts/{}/credentials/{}".format(r.status_code, self.backend_url, account_id, credential_id))
4444
credential = r.json()
4545

46+
sensors = []
47+
for sensor in entity_info["protocols"][protocol]["sensors"]:
48+
r = requests.get('{}/accounts/{}/sensors/{}?b={}'.format(self.backend_url, account_id, sensor["sensor"], self.bot_token))
49+
if r.status_code != 200:
50+
raise Exception("Network error, got status {} while retrieving {}/accounts/{}/sensors/{}".format(r.status_code, self.backend_url, account_id, sensor["sensor"]))
51+
sensors.append({
52+
"sensor": r.json(),
53+
"interval": sensor["interval"],
54+
})
55+
entity_info["protocols"][protocol]["sensors"] = sensors
56+
4657
yield account_id, entity_info, credential
4758

4859

0 commit comments

Comments
 (0)