summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2024-01-29 10:38:52 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-01-29 11:18:18 +0100
commita45f664905a6bb0d6e6e1510507ef62402f4d21e (patch)
tree1e653429aecb0d7261932b32284abfb667263fbe /ogcp/views.py
parent7c86ecf9a1280d6994527bfb970e45a9f181549a (diff)
dashboard: Show all servers, online or offline
Show in dashboard the list of all servers, regardless if they are online or offline. If they are offline, uptime appears as 'offline' Modify dashboard template to make it work with offline servers
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: