Initial Commit
This commit is contained in:
parent
37e9360e54
commit
1080857bba
|
|
@ -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)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 307 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 307 KiB |
|
|
@ -0,0 +1,130 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Status</title>
|
||||
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.png') }}">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Play:wght@400&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Play&display=swap');
|
||||
body {
|
||||
font-family: 'Play', sans-serif;
|
||||
background-color: #292929; /* Hintergrundfarbe */
|
||||
color: #fff; /* Textfarbe */
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 60px;
|
||||
padding: 10px;
|
||||
}
|
||||
.time-date {
|
||||
font-size: 30px; /* Schriftgröße für Uhr und Datum */
|
||||
}
|
||||
.logo {
|
||||
height: 50px; /* Höhe des Logos */
|
||||
width: auto; /* Breite automatisch anpassen */
|
||||
margin: 0 20px; /* Abstand um das Logo */
|
||||
}
|
||||
.divider {
|
||||
width: 100%;
|
||||
height: 3px;
|
||||
background-color: #ccc; /* Farbe des Trenners */
|
||||
}
|
||||
.status-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap; /* Umbrüche ermöglichen */
|
||||
justify-content: center; /* Zentrieren der Karten */
|
||||
padding: 20px;
|
||||
}
|
||||
.status-card {
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5); /* Etwas dunklerer Schatten für besseren Kontrast */
|
||||
margin: 10px;
|
||||
padding: 20px;
|
||||
width: 200px;
|
||||
text-align: center;
|
||||
transition: background-color 0.3s ease; /* Sanfter Übergang bei Farbänderung */
|
||||
}
|
||||
.status-card h2 {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.url {
|
||||
font-size: 0.8em;
|
||||
color: #acabab; /* Helle Farbe für die URL */
|
||||
}
|
||||
.online {
|
||||
background-color: #008800; /* Sanftes Grün */
|
||||
}
|
||||
.offline {
|
||||
background-color: #990000; /* Sanftes Rot */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div id="date" class="time-date"></div>
|
||||
<img src="{{ url_for('static', filename='Bild.png') }}" alt="Logo" class="logo">
|
||||
<div id="clock" class="time-date"></div>
|
||||
</div>
|
||||
<div class="divider"></div>
|
||||
<div class="status-container">
|
||||
{% 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>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
function updateStatus() {
|
||||
$.getJSON('/update_status', function(data) {
|
||||
data.forEach(function(site, index) {
|
||||
var card = $('#card-' + (index + 1));
|
||||
var statusElement = card.find('.status');
|
||||
statusElement.text(site.status ? 'Online' : 'Offline');
|
||||
|
||||
// Hintergrundfarbe basierend auf dem Status ändern
|
||||
if (site.status) {
|
||||
card.removeClass('offline').addClass('online');
|
||||
} else {
|
||||
card.removeClass('online').addClass('offline');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function updateTime() {
|
||||
var now = new Date();
|
||||
var timeString = now.toLocaleTimeString('de-DE');
|
||||
var dateString = now.toLocaleDateString('de-DE');
|
||||
$('#clock').text(timeString);
|
||||
$('#date').text(dateString);
|
||||
}
|
||||
|
||||
// Initial update
|
||||
updateStatus();
|
||||
updateTime();
|
||||
|
||||
// Update status every 5 seconds
|
||||
setInterval(updateStatus, 5000);
|
||||
|
||||
// Update time every second
|
||||
setInterval(updateTime, 1000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user