more updates
This commit is contained in:
parent
c06b7e3f98
commit
4ac0fe6690
1 changed files with 39 additions and 12 deletions
|
@ -30,25 +30,27 @@ auth = (username, password)
|
||||||
url_base = f"{grafana_url.rstrip('/')}/api"
|
url_base = f"{grafana_url.rstrip('/')}/api"
|
||||||
|
|
||||||
varken_datasource = []
|
varken_datasource = []
|
||||||
|
datasource_name = "Varken-Script"
|
||||||
try:
|
try:
|
||||||
datasources = session.get(url_base + '/datasources', auth=auth, verify=verify).json()
|
datasources = session.get(url_base + '/datasources', auth=auth, verify=verify).json()
|
||||||
varken_datasource = [source for source in datasources if source['database'] == 'varken']
|
varken_datasource = [source for source in datasources if source['database'] == 'varken']
|
||||||
if varken_datasource:
|
if varken_datasource:
|
||||||
print(f'varken datasource already exists with the name "{varken_datasource[0]["name"]}"')
|
print(f'varken datasource already exists with the name "{varken_datasource[0]["name"]}"')
|
||||||
|
datasource_name = varken_datasource[0]["name"]
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
exit(f"Could not talk to grafana at {grafana_url}. Check URL/Username/Password")
|
exit(f"Could not talk to grafana at {grafana_url}. Check URL/Username/Password")
|
||||||
|
|
||||||
datasource_data = {
|
|
||||||
"name": "Varken-Script",
|
|
||||||
"type": "influxdb",
|
|
||||||
"url": f"http://{'influxdb' if docker else host_ip}:8086",
|
|
||||||
"access": "proxy",
|
|
||||||
"basicAuth": False,
|
|
||||||
"database": 'varken'
|
|
||||||
}
|
|
||||||
if not varken_datasource:
|
if not varken_datasource:
|
||||||
|
datasource_data = {
|
||||||
|
"name": datasource_name,
|
||||||
|
"type": "influxdb",
|
||||||
|
"url": f"http://{'influxdb' if docker else host_ip}:8086",
|
||||||
|
"access": "proxy",
|
||||||
|
"basicAuth": False,
|
||||||
|
"database": 'varken'
|
||||||
|
}
|
||||||
post = session.post(url_base + '/datasources', auth=auth, verify=verify, json=datasource_data).json()
|
post = session.post(url_base + '/datasources', auth=auth, verify=verify, json=datasource_data).json()
|
||||||
print(f'Created Varken-Script datasource (id:{post["datasource"]["id"]})')
|
print(f'Created {datasource_name} datasource (id:{post["datasource"]["id"]})')
|
||||||
|
|
||||||
our_dashboard = session.get(url_base + '/gnet/dashboards/9585', auth=auth, verify=verify).json()['json']
|
our_dashboard = session.get(url_base + '/gnet/dashboards/9585', auth=auth, verify=verify).json()['json']
|
||||||
dashboard_data = {
|
dashboard_data = {
|
||||||
|
@ -62,7 +64,7 @@ dashboard_data = {
|
||||||
"type": "datasource",
|
"type": "datasource",
|
||||||
"pluginId": "influxdb",
|
"pluginId": "influxdb",
|
||||||
"pluginName": "InfluxDB",
|
"pluginName": "InfluxDB",
|
||||||
"value": "Varken-Script"
|
"value": datasource_name
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "VAR_MOVIESLIBRARY",
|
"name": "VAR_MOVIESLIBRARY",
|
||||||
|
@ -92,6 +94,20 @@ dashboard_data = {
|
||||||
"value": fourk_tv_shows_library,
|
"value": fourk_tv_shows_library,
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "VAR_MUSICLIBRARY",
|
||||||
|
"type": "constant",
|
||||||
|
"label": "Music Library Name",
|
||||||
|
"value": music_library,
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "VAR_USGNAME",
|
||||||
|
"type": "constant",
|
||||||
|
"label": "Unifi USG Name",
|
||||||
|
"value": usg_name,
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "VAR_OMBIURL",
|
"name": "VAR_OMBIURL",
|
||||||
"type": "constant",
|
"type": "constant",
|
||||||
|
@ -126,8 +142,19 @@ dashboard_data = {
|
||||||
"label": "Sickchill URL",
|
"label": "Sickchill URL",
|
||||||
"value": sickchill_url,
|
"value": sickchill_url,
|
||||||
"description": ""
|
"description": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "VAR_LIDARRURL",
|
||||||
|
"type": "constant",
|
||||||
|
"label": "lidarr URL",
|
||||||
|
"value": lidarr_url,
|
||||||
|
"description": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
make_dashboard = session.post(url_base + '/dashboards/import', json=dashboard_data, auth=auth, verify=verify)
|
try:
|
||||||
print('Created dashboard "Varken-Script"')
|
make_dashboard = session.post(url_base + '/dashboards/import', json=dashboard_data, auth=auth, verify=verify)
|
||||||
|
if make_dashboard.status_code == 200 and make_dashboard.json().get('imported'):
|
||||||
|
print(f'Created dashboard "{our_dashboard["title"]}"')
|
||||||
|
except:
|
||||||
|
print('Shit...')
|
||||||
|
|
Loading…
Reference in a new issue