admin can select tags for data now
This commit is contained in:
parent
3a392f2084
commit
04c5895667
1 changed files with 17 additions and 10 deletions
27
main.py
27
main.py
|
@ -42,6 +42,9 @@ def pkt_loss(data):
|
||||||
|
|
||||||
def tag_selection(data):
|
def tag_selection(data):
|
||||||
tags = DB_TAGS
|
tags = DB_TAGS
|
||||||
|
if tags is None:
|
||||||
|
return None
|
||||||
|
# tag_switch takes in _data and attaches CLIoutput to more readable ids
|
||||||
tag_switch = {
|
tag_switch = {
|
||||||
'isp': data['isp'],
|
'isp': data['isp'],
|
||||||
'interface': data['interface']['name'],
|
'interface': data['interface']['name'],
|
||||||
|
@ -59,15 +62,14 @@ def tag_selection(data):
|
||||||
'speedtest_id': data['result']['id'],
|
'speedtest_id': data['result']['id'],
|
||||||
'speedtest_url': data['result']['url']
|
'speedtest_url': data['result']['url']
|
||||||
}
|
}
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
if tags == '':
|
tags = tags.split(',')
|
||||||
return None
|
for tag in tags:
|
||||||
else:
|
# split the tag string, strip and add selected tags to {options} with corresponding tag_switch data
|
||||||
tags = tags.split(',')
|
tag = tag.strip()
|
||||||
for tag in tags:
|
options[tag] = tag_switch[tag]
|
||||||
tag = tag.strip()
|
return options
|
||||||
options[tag] = tag_switch[tag]
|
|
||||||
return options
|
|
||||||
|
|
||||||
|
|
||||||
def format_for_influx(cliout):
|
def format_for_influx(cliout):
|
||||||
|
@ -110,8 +112,13 @@ def format_for_influx(cliout):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
tags = tag_selection(data)
|
||||||
return influx_data
|
if tags is None:
|
||||||
|
return influx_data
|
||||||
|
else:
|
||||||
|
for measurement in influx_data:
|
||||||
|
measurement['tags'] = tags
|
||||||
|
return influx_data
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in a new issue