added Readme and second URL Row
This commit is contained in:
parent
1080857bba
commit
6f9d7aef85
44
main.py
44
main.py
|
|
@ -1,7 +1,9 @@
|
|||
from flask import Flask, render_template, jsonify, url_for
|
||||
from flask import Flask, render_template, jsonify
|
||||
import requests
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import socket
|
||||
import subprocess
|
||||
import platform
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
|
@ -12,7 +14,7 @@ def check_status(site):
|
|||
elif ':22' in url:
|
||||
return check_ssh_status(site)
|
||||
else:
|
||||
return {'url': url, 'title': site['title'], 'status': False}
|
||||
return check_ping_status(site)
|
||||
|
||||
def check_http_status(site):
|
||||
try:
|
||||
|
|
@ -33,9 +35,20 @@ def check_ssh_status(site):
|
|||
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
|
||||
def check_ping_status(site):
|
||||
host = site['url'].split(':')[0]
|
||||
param = '-n' if platform.system().lower() == 'windows' else '-c'
|
||||
command = ['ping', param, '1', host]
|
||||
try:
|
||||
output = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
status = output.returncode == 0
|
||||
return {'url': site['url'], 'title': site['title'], 'status': status}
|
||||
except Exception as e:
|
||||
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'},
|
||||
|
|
@ -51,17 +64,30 @@ websites = [
|
|||
{'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'},
|
||||
{'url': '1.1.1.1', 'title': 'Outside'},
|
||||
|
||||
]
|
||||
# Add the second Row of URL´s in the same Sceme
|
||||
websites2 = [
|
||||
{'url': '192.168.100.65', 'title': 'MacBook'},
|
||||
{'url': '192.168.100.68', 'title': 'Desktop'},
|
||||
{'url': '192.168.100.80', 'title': 'iPhone'},
|
||||
{'url': '192.168.100.84', 'title': 'iPad'},
|
||||
]
|
||||
|
||||
@app.route('/')
|
||||
def status_page():
|
||||
return render_template('status.html', websites=websites)
|
||||
return render_template('status.html', websites=websites, websites2=websites2)
|
||||
|
||||
@app.route('/update_status')
|
||||
def update_status():
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
results = list(executor.map(check_status, websites))
|
||||
return jsonify(results)
|
||||
results1 = list(executor.map(check_status, websites))
|
||||
results2 = list(executor.map(check_status, websites2))
|
||||
|
||||
# Combine results from both lists
|
||||
combined_results = results1 + results2
|
||||
return jsonify(combined_results)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
app.run(debug=True)
|
||||
47
readme.md
47
readme.md
|
|
@ -0,0 +1,47 @@
|
|||
## FoxStatus™
|
||||
|
||||
Das Programm ist eine Webanwendung, die den Status verschiedener Webseiten und Server überwacht. Es verwendet Flask, ein leichtgewichtiges Web-Framework für Python, um eine Benutzeroberfläche zu erstellen, die den aktuellen Status von angegebenen URLs anzeigt. Die Anwendung prüft, ob die Webseiten online oder offline sind und aktualisiert diese Informationen in Echtzeit.
|
||||
|
||||
### Funktionsweise
|
||||
|
||||
1. **Webseitenüberwachung**:
|
||||
- Das Programm überprüft den Status von Webseiten und Servern, indem es verschiedene Protokolle wie HTTP, SSH und Ping verwendet.
|
||||
- Für jede URL wird die entsprechende Überprüfungsmethode aufgerufen:
|
||||
- **HTTP-Status**: Überprüfung, ob die Webseite erreichbar ist (Statuscode 200).
|
||||
- **SSH-Status**: Überprüfung, ob der SSH-Dienst auf dem angegebenen Port läuft.
|
||||
- **Ping-Status**: Überprüfung der Erreichbarkeit über das ICMP-Protokoll.
|
||||
|
||||
2. **Benutzeroberfläche**:
|
||||
- Die HTML-Seite zeigt die aktuelle Uhrzeit und das Datum an.
|
||||
- Der Status jeder Webseite wird in Kartenform dargestellt, wobei der Hintergrund je nach Status (online oder offline) farblich angepasst wird.
|
||||
|
||||
3. **Echtzeit-Updates**:
|
||||
- Die Anwendung aktualisiert den Status der Webseiten alle 5 Sekunden und die Uhrzeit jede Sekunde durch AJAX-Anfragen an den Server.
|
||||
|
||||
### Installationsanleitung
|
||||
|
||||
Um das Programm zu installieren und auszuführen, folgen Sie diesen Schritten:
|
||||
|
||||
1. **Voraussetzungen**:
|
||||
- Stellen Sie sicher, dass Python 3.x installiert ist.
|
||||
- Installieren Sie Flask und Requests mit pip:
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
3. **URLs anpassen**:
|
||||
- Bearbeiten Sie die `websites` und `websites2` Listen in `main.py`, um Ihre eigenen URLs hinzuzufügen.
|
||||
|
||||
4. **Server starten**:
|
||||
- Führen Sie das Programm aus:
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
- Der Server sollte nun auf `http://127.0.0.1:5000` laufen.
|
||||
|
||||
5. **Zugriff auf die Anwendung**:
|
||||
- Öffnen Sie einen Webbrowser und navigieren Sie zur URL `http://127.0.0.1:5000`, um die Benutzeroberfläche anzuzeigen.
|
||||
|
||||
### Fazit
|
||||
|
||||
Dieses Programm bietet eine einfache Möglichkeit zur Überwachung des Status von Webseiten und Servern in einer benutzerfreundlichen Oberfläche. Durch regelmäßige Aktualisierungen bleibt der Benutzer stets informiert über den Zustand seiner Dienste.
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Flask==3.1.0
|
||||
Requests==2.32.3
|
||||
|
|
@ -82,11 +82,21 @@
|
|||
{% for website in websites %}
|
||||
<div class="status-card" id="card-{{ loop.index }}">
|
||||
<h2>{{ website.title }}</h2>
|
||||
<!-- <p class="url">{{ website.url }}</p> -->
|
||||
<p class="status">Checking...</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
<div class="status-container">
|
||||
{% for website in websites2 %}
|
||||
<div class="status-card" id="card-{{ loop.index + websites|length }}">
|
||||
<h2>{{ website.title }}</h2>
|
||||
<p class="status">Checking...</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user