summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py40
1 files changed, 29 insertions, 11 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index f0049fc..24df2e3 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -391,17 +391,35 @@ def index():
dashboard_servers[server_id]['oglive_list'] = i['json']
all_stats = multi_request('get', '/stats')
- for i in all_stats:
- server_id = i['server'].id
- stats = i['json']
- dashboard_servers[server_id]['stats'] = stats
-
- timestamp = datetime.datetime.fromtimestamp(stats.get('time').get('now'))
- now = timestamp.strftime('%Y-%m-%d %H:%M:%S')
- boot = display_time(stats.get('time').get('boot'))
- start = display_time(stats.get('time').get('start'))
- time_dict = {'now': now, 'boot': boot, 'start': start}
- dashboard_servers[server_id]['time_dict'] = time_dict
+ for server in servers:
+ active = False
+ stat = None
+ for i in all_stats:
+ if i['server'].id == server.id:
+ active = True
+ stat = i
+ break
+ if active:
+ server_id = stat['server'].id
+ dashboard_servers[server_id]['online'] = True
+ stats = stat['json']
+ dashboard_servers[server_id]['stats'] = stats
+ timestamp = datetime.datetime.fromtimestamp(stats.get('time').get('now'))
+ now = timestamp.strftime('%Y-%m-%d %H:%M:%S')
+ boot = display_time(stats.get('time').get('boot'))
+ start = display_time(stats.get('time').get('start'))
+ time_dict = {'now': now, 'boot': boot, 'start': start}
+ dashboard_servers[server_id]['time_dict'] = time_dict
+ else:
+ dashboard_servers[server.id] = {}
+ dashboard_servers[server.id]['online'] = False
+ dashboard_servers[server.id]['name'] = server.name
+ dashboard_servers[server.id]['time_dict'] = {'now': None, 'boot': 'Offline', 'start': None}
+ dashboard_servers[server.id]['clients'] = []
+ dashboard_servers[server.id]['images'] = []
+ dashboard_servers[server.id]['disk'] = {'total': 0, 'free':0}
+ dashboard_servers[server.id]['stats'] = {'memory': {'free': 0, 'size':0}, 'swap': ''}
+ dashboard_servers[server.id]['oglive_list'] = []
clients_response = multi_request('get', '/clients')
for i in clients_response: