52 lines
1.1 KiB
Python
52 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
|
|
from django.http import HttpResponse
|
|
from django.shortcuts import render
|
|
import json
|
|
import requests
|
|
|
|
def get_status():
|
|
with open('conf.json') as conf:
|
|
status = json.load(conf)["api"] + '/status'
|
|
try: res = requests.get(status)
|
|
except: res = 'connection can\'t be established'
|
|
return res.content
|
|
|
|
def node():
|
|
pass
|
|
|
|
def health():
|
|
pass
|
|
|
|
def mount():
|
|
pass
|
|
|
|
def unmount():
|
|
pass
|
|
|
|
def resolve():
|
|
pass
|
|
|
|
def get_metrics():
|
|
#with open('conf.json') as conf:
|
|
# api = json.load(conf)["api"]
|
|
#try: res = requests.get(api + metrics)
|
|
#return api
|
|
with open('conf.json') as conf:
|
|
metrics = json.load(conf)["api"] + '/metrics'
|
|
res = requests.get(metrics)
|
|
print res
|
|
#except: res = 'connection can\'t be established'
|
|
return res.content
|
|
|
|
def panel(request):
|
|
with open('conf.json') as conf:
|
|
ws = json.load(conf)["ws"]
|
|
metrics = json.loads(get_metrics())
|
|
status = get_status()
|
|
return render(request, 'rbmd/index.html', {'ws' : ws, 'metrics' : metrics, 'status' : status})
|
|
|
|
|
|
|