-
Notifications
You must be signed in to change notification settings - Fork 0
/
extractValue.py
28 lines (24 loc) · 985 Bytes
/
extractValue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class ExtractValue():
def __init__(self, json_packet, hostname):
self.json_packet=json_packet
self.hostname=hostname
self.value=None
def get_average(json_packet, hostname):
import json
for this_hostname in json_packet['facets']:
if this_hostname['name']==hostname:
value=this_hostname['results'][0]['average']
return(value)
# Not found hostname
print("get_average didn't find hostname="+hostname)
return(None)
# Differentiate between 'average' and 'result' responses
def get_result(json_packet, hostname):
import json
for this_hostname in json_packet['facets']:
if this_hostname['name']==hostname:
value=this_hostname['results'][0]['result']
return(value)
# Not found hostname
print("get_result didn't find hostname="+hostname)
return(None)