diff --git a/owrx/controllers/services.py b/owrx/controllers/services.py index 636903bf..04b631f1 100644 --- a/owrx/controllers/services.py +++ b/owrx/controllers/services.py @@ -7,6 +7,8 @@ from owrx.eibi import EIBI from datetime import datetime import json +import time +import os import re import logging @@ -42,6 +44,14 @@ class ServiceController(AuthorizationMixin, WebpageController): status=ServiceController.renderStatus() ) + @staticmethod + def lastBooted(): + try: + with open('/proc/uptime', 'r') as f: + return time.time() - float(f.readline().split()[0]) + except: + return 0 + @staticmethod def renderTime(ts): ts = datetime.fromtimestamp(ts) @@ -52,6 +62,10 @@ class ServiceController(AuthorizationMixin, WebpageController): @staticmethod def renderStatus(): result = "" + ts = ServiceController.lastBooted() + if ts > 0: + ts = ServiceController.renderTime(ts) + result += "
System booted at {0}.
\n".format(ts) ts = ServiceController.renderTime(EIBI.lastStarted()) result += "
Server started at {0}.
\n".format(ts) ts = EIBI.lastDownloaded()