summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bwlp.config2
-rwxr-xr-xmain.py23
2 files changed, 14 insertions, 11 deletions
diff --git a/bwlp.config b/bwlp.config
index 9a9ce84..af5a214 100644
--- a/bwlp.config
+++ b/bwlp.config
@@ -12,7 +12,7 @@ ping Backup fileserver Ping bwlp-backup.ruf.uni-freiburg.de
ping Ping Fail 0.0.0.1
thrift Thrift SAT 132.230.8.192 9090 SAT
thrift Thrift MASTER 132.230.4.16 9090 MASTER
-thrift Thrift Timeout 132.230.4.16 9092 MASTER
+# thrift Thrift Timeout 132.230.4.16 9092 MASTER
thrift Thrift SSL test 132.230.4.16 9091 MASTER ssl/CA.pem ssl/client.crt ssl/client.key
ping BAS Ping bas.intra.uni-freiburg.de
ping yc 127.0.0.2
diff --git a/main.py b/main.py
index 48c21da..4811db2 100755
--- a/main.py
+++ b/main.py
@@ -1,15 +1,16 @@
#!/usr/bin/python3
+import datetime
+import logging
+import os
+import shutil
import subprocess
-import urllib.request
-import urllib.error
+import tftpy
import thriftpy
from thriftpy.rpc import make_client
from thriftpy.transport import TFramedTransportFactory
-import shutil
-import datetime
-import os
-import tftpy
-import logging
+import time
+import urllib.error
+import urllib.request
# Global variables
statusList = []
@@ -185,7 +186,8 @@ def getLogEntry(status):
def logStatus(status):
obj = getLogEntry(status)
if (obj is None) or (status.state != obj.state):
- date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+ # Save unix timestamps
+ date = str(int(time.time()))
logEntries.append(LogEntry(date, status.service, status.state, status.host, status.msg, status.data))
# Reads the config and executes the calls.
@@ -233,7 +235,7 @@ for status in statusList:
# Prepare and calculate the time since the server is online / offline
obj = getLogEntry(status)
now = datetime.datetime.now()
- date = datetime.datetime.strptime(obj.date, '%Y-%m-%d %H:%M:%S')
+ date = datetime.datetime.fromtimestamp(int(obj.date))
time = now - date
days = time.days
hours = time.seconds // 3600
@@ -262,8 +264,9 @@ cut_amount = 0
if len(logEntries) >= n:
cut_amount = len(logEntries) - n
for entry in reversed(logEntries[cut_amount:]):
+ parsed_date = datetime.datetime.fromtimestamp(int(entry.date)).strftime('%Y-%m-%d %H:%M:%S')
log += ('<div class="log_item"><div class="log_item_part time"><div class="content_item_part_title">['
- + entry.date + ']</div></div><div class="log_item_part service"><div class="content_item_part_title">['
+ + parsed_date + ']</div></div><div class="log_item_part service"><div class="content_item_part_title">['
+ entry.service + ']</div></div><div class="log_item_part '
+ entry.state + '"><div class="content_item_part_title">['
+ entry.state + ']</div></div><div class="log_item_part"><div class="content_item_part_title">['