diff --git a/main.py b/main.py new file mode 100644 index 0000000..959a703 --- /dev/null +++ b/main.py @@ -0,0 +1,67 @@ +from flask import Flask, render_template, jsonify, url_for +import requests +from concurrent.futures import ThreadPoolExecutor +import socket + +app = Flask(__name__) + +def check_status(site): + url = site['url'] + if url.startswith('http'): + return check_http_status(site) + elif ':22' in url: + return check_ssh_status(site) + else: + return {'url': url, 'title': site['title'], 'status': False} + +def check_http_status(site): + try: + response = requests.get(site['url'], timeout=5) + return {'url': site['url'], 'title': site['title'], 'status': response.status_code == 200} + except: + return {'url': site['url'], 'title': site['title'], 'status': False} + +def check_ssh_status(site): + host = site['url'].split(':')[0] + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(2) + result = sock.connect_ex((host, 22)) + status = result == 0 + sock.close() + return {'url': site['url'], 'title': site['title'], 'status': status} + except: + return {'url': site['url'], 'title': site['title'], 'status': False} + +#Add your URL´s here. +#For SSH-URL´s please don´t add the http:// and check the Port the SSH Server is running on +#For Normal URL´s please use http:// and the Port the Website runs on + +websites = [ + {'url': '192.168.3.11:22', 'title': 'PVE Main'}, + {'url': '192.168.3.12:22', 'title': 'PVE Small'}, + {'url': 'http://192.168.3.10:80', 'title': 'WLED'}, + {'url': 'http://192.168.2.6:8123', 'title': 'HomeAssistant'}, + {'url': 'http://192.168.2.3:9999', 'title': 'Stash'}, + {'url': 'http://192.168.2.4:3000', 'title': 'GitTea'}, + {'url': 'http://192.168.2.8:81', 'title': 'Proxymanager'}, + {'url': '192.168.3.14:22', 'title': 'Docker'}, + {'url': 'http://192.168.3.17:5000', 'title': 'FoxNAS'}, + {'url': '192.168.3.20:22', 'title': 'BackupNAS'}, + {'url': 'http://192.168.3.21:8080', 'title': 'AMP'}, + {'url': '192.168.100.16:22', 'title': 'VPN Tunnel'}, + {'url': '192.168.3.30:22', 'title': 'Nextcloud'}, +] + +@app.route('/') +def status_page(): + return render_template('status.html', websites=websites) + +@app.route('/update_status') +def update_status(): + with ThreadPoolExecutor(max_workers=10) as executor: + results = list(executor.map(check_status, websites)) + return jsonify(results) + +if __name__ == '__main__': + app.run(debug=True) diff --git a/static/Bild.png b/static/Bild.png new file mode 100644 index 0000000..6377e60 Binary files /dev/null and b/static/Bild.png differ diff --git a/static/favicon.png b/static/favicon.png new file mode 100644 index 0000000..6377e60 Binary files /dev/null and b/static/favicon.png differ diff --git a/templates/status.html b/templates/status.html new file mode 100644 index 0000000..7d0a812 --- /dev/null +++ b/templates/status.html @@ -0,0 +1,130 @@ + + +
+ + +
+
+ Checking...
+