From 3d02b9c1544363c6bd8f3aa848766e3bbd642423 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Wed, 23 Jan 2019 16:50:34 +0100 Subject: Seperate config from the python script Seperate the server calls in a config file. Small thrift call bugfix Small layout fixes --- bwLpStatus.py | 56 +++++++++++++++++++++++++++++------------------ bwlp.config | 20 +++++++++++++++++ bwlpMonitor_template.html | 2 -- style.css | 7 +++--- 4 files changed, 59 insertions(+), 26 deletions(-) create mode 100644 bwlp.config diff --git a/bwLpStatus.py b/bwLpStatus.py index d9c20c6..882ec1f 100755 --- a/bwLpStatus.py +++ b/bwLpStatus.py @@ -31,7 +31,7 @@ class Status: # Status of the check. (Online, Offline, Temporaily not available, Some services unavailable, ...) <-- This text is shown on the website self.status = status - # Type of the service. (ping, https, http, mysql, ...) + # Type of the service. (ping, https, tftp, thrift, ...) self.service = service # Message e.g. error message @@ -124,19 +124,22 @@ def thrift(name, ip, port, server): organisations = [] # Different clients for SAT / Master is needed. try: - if server is 'SAT': + if server == 'SAT': satserver = make_client(bwlp_thrift.SatelliteServer, ip, port, trans_factory=TFramedTransportFactory()) organisations = satserver.getAllOrganizations() - elif server is 'MASTER': + elif server == 'MASTER': masterserver = make_client(bwlp_thrift.MasterServer, ip, port, trans_factory=TFramedTransportFactory()) organisations = masterserver.getOrganizations() - + print(organisations) organisationList = [] for org in organisations: organisationList.append(Organisation(org.organizationId, org.displayName)) - statusList.append(Status(name, host, 'success', 'Online (' + str(len(organisationList)) + ')', 'thrift', msg=str(len(organisationList)) + " organizations",data=organisationList)) + if len(organisationList) == 0: + statusList.append(Status(name, host, 'warning', 'Online (' + str(len(organisationList)) + ')', 'thrift', msg=str(len(organisationList)) + " organizations found",data=organisationList)) + else: + statusList.append(Status(name, host, 'success', 'Online (' + str(len(organisationList)) + ')', 'thrift', msg=str(len(organisationList)) + " organizations found",data=organisationList)) print('\033[92m' + 'success' + '\033[0m') except ConnectionResetError: statusList.append(Status(name, host, 'error', 'Offline', 'thrift', msg="ConnectionResetError: [Errno 104] Connection reset by peer")) @@ -177,26 +180,37 @@ def logStatus(status): date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') logEntries.append(LogEntry(date, status.service, status.state, status.host, status.msg, status.data)) +# Reads the config and executes the calls. +def readConfig(): + if not (os.path.exists('bwlp.config')): + return + with open('bwlp.config', 'r') as config: + for line in config: + line = line.strip() + entry = line.split('\t') + if entry[0] == '#': continue + check(entry) + +# Calls the check method. +def check(entry): + if entry[0] == 'ping': + if (len(entry) < 3): return + ping(entry[1], entry[2]) + elif entry[0] == 'https': + if (len(entry) < 3): return + https(entry[1], entry[2]) + elif entry[0] == 'thrift': + if (len(entry) < 5): return + thrift(entry[1], entry[2], int(entry[3]), entry[4]) + elif entry[0] == 'tftp': + if (len(entry) < 5): return + tftp(entry[1], entry[2], int(entry[3]), entry[4]) + # Parse the logfile. parseLog() # Call the checks. -https('Masterserver HTTPS Service', 'https://bwlp-masterserver.ruf.uni-freiburg.de') -https('Fail Test', '5121236') -https('Fail Test', 'https://www.amazony.de/') -ping('Masterserver IP Ping', '132.230.4.16') -ping('Fileserver Ping', 'files.bwlp.ks.uni-freiburg.de') -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 MASTER', '132.230.4.16', 9091, 'MASTER') -ping('BAS Ping', 'bas.intra.uni-freiburg.de') -ping('yc', '127.0.0.2') -ping('yx', '127.0.0.3') -tftp('TFTP bwlp lpxelinux', 'bwlp-pxe.ruf.uni-freiburg.de', 69, 'lpxelinux.0') -tftp('TFTP bas ipxe', 'bas.intra.uni-freiburg.de', 69, 'ipxe.0') -tftp('TFTP bas fail test', 'bas.intra.uni-freiburg.de', 69, 'failtest.0') +readConfig() # Write the new logfile. writeLog() diff --git a/bwlp.config b/bwlp.config new file mode 100644 index 0000000..207f2ca --- /dev/null +++ b/bwlp.config @@ -0,0 +1,20 @@ +# ping name host +# https name host +# thrift name host port SAT/MASTER +# tftp name host port filename +https Masterserver HTTPS Service https://bwlp-masterserver.ruf.uni-freiburg.de +https Fail Test 5121236 +https Fail Test https://www.amazony.de/ +ping Masterserver IP Ping 132.230.4.16 +ping Fileserver Ping files.bwlp.ks.uni-freiburg.de +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 MASTER 132.230.4.16 9091 MASTER +ping BAS Ping bas.intra.uni-freiburg.de +ping yc 127.0.0.2 +ping yx 127.0.0.3 +tftp TFTP bwlp lpxelinux bwlp-pxe.ruf.uni-freiburg.de 69 lpxelinux.0 +tftp TFTP bas ipxe bas.intra.uni-freiburg.de 69 ipxe.0 +tftp TFTP bas fail test bas.intra.uni-freiburg.de 69 failtest.0 diff --git a/bwlpMonitor_template.html b/bwlpMonitor_template.html index 19a804b..01bb0fb 100644 --- a/bwlpMonitor_template.html +++ b/bwlpMonitor_template.html @@ -92,9 +92,7 @@ var autorefresh = urlParams.get('autorefresh') var autorefresh = parseInt(autorefresh) - console.log(Number.isInteger(autorefresh)) if (Number.isInteger(autorefresh)) { - console.log(autorefresh) setTimeout(function() { location.reload(); }, autorefresh * 1000); diff --git a/style.css b/style.css index 5d49e2a..7fdccf8 100644 --- a/style.css +++ b/style.css @@ -87,7 +87,6 @@ a:hover { flex-direction: column; align-items: center; margin-top: 60px; - min-height: 300px; padding: 30px; } @@ -156,7 +155,7 @@ a:hover { #log_wrapper { display: flex; - min-height: 150px; + min-height: 50px; max-height: 80vh; margin-top: 60px; box-shadow: 0 2px 4px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12); @@ -210,10 +209,12 @@ a:hover { margin-left: 40px; margin-top: 0px; max-width: 60vw; - max-height: 80vh; + max-height: calc(100vh - 120px); } #content { width: 30%; + height: calc(100vh - 120px); + min-height: 51px; } } -- cgit v1.2.3-55-g7522