summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2019-04-04 17:21:12 +0200
committerJannik Schönartz2019-04-04 17:21:12 +0200
commitb7e21c617453e89c13ebb24ebb00d96ebba554ce (patch)
tree58d955d47f5132ee314138f8f5381bd2f92a00ce
parentThrift: Verify SSL cert (diff)
downloadbwlp-monitoring-b7e21c617453e89c13ebb24ebb00d96ebba554ce.tar.gz
bwlp-monitoring-b7e21c617453e89c13ebb24ebb00d96ebba554ce.tar.xz
bwlp-monitoring-b7e21c617453e89c13ebb24ebb00d96ebba554ce.zip
Ping requests now consideres the exitcode of the subprocess
removed config file and add template.
-rw-r--r--bwlp.config22
-rw-r--r--bwlp.config.template4
-rwxr-xr-xmain.py12
3 files changed, 13 insertions, 25 deletions
diff --git a/bwlp.config b/bwlp.config
deleted file mode 100644
index 4dcf744..0000000
--- a/bwlp.config
+++ /dev/null
@@ -1,22 +0,0 @@
-# ping name host
-# https name host
-# thrift name host port SAT/MASTER
-# tftp name host port filename ssl(true/false)
-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 false
-# thrift Thrift Timeout 132.230.4.16 9092 MASTER false
-thrift Thrift SAT SSL test 132.230.8.192 9091 SAT true
-thrift Thrift MASTER SSL test 132.230.4.16 9091 MASTER true
-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 \ No newline at end of file
diff --git a/bwlp.config.template b/bwlp.config.template
new file mode 100644
index 0000000..b12cf1f
--- /dev/null
+++ b/bwlp.config.template
@@ -0,0 +1,4 @@
+# ping <NAME> <HOST>
+# https <NAME> <HOST>
+# thrift <NAME> <HOST> <PORT> SAT/MASTER
+# tftp <NAME> <HOST> <PORT> <FILENAME> ssl(true/false)
diff --git a/main.py b/main.py
index d685b7c..a719fc6 100755
--- a/main.py
+++ b/main.py
@@ -68,13 +68,19 @@ def ping(name, hostname):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
+ response.wait()
+ exit_code = response.returncode
response = response.communicate()
error = response[1].decode('utf-8')
-
# Error happend
- if error != '':
+ if error != '' or exit_code != 0:
+ err_msg = ''
+ if exit_code == 1:
+ err_msg = 'Destination Host Unreachable'
+ elif exit_code == 2:
+ err_msg = error.rstrip()
print('\033[91m' + 'error' + '\033[0m')
- statusList.append(Status(name, hostname, 'error', 'Offline', 'ping', error.rstrip()))
+ statusList.append(Status(name, hostname, 'error', 'Offline', 'ping', err_msg))
else:
print('\033[92m' + 'success' + '\033[0m')
statusList.append(Status(name, hostname, 'success', 'Online', 'ping'))