diff --git a/README.md b/README.md index bf2066e..22cc514 100644 --- a/README.md +++ b/README.md @@ -59,4 +59,4 @@ Each node collects: ### Additional Features - Alarm suppression capabilities -- Ticket creation system integration +- Ticket creation system integration \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..bd6b2f2 --- /dev/null +++ b/app.py @@ -0,0 +1,20 @@ +from flask import Flask, jsonify, render_template +from monitor.node import check_network_health, measure_latency, check_bandwidth + +app = Flask(__name__) + +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/api/metrics') +def get_metrics(): + metrics = { + 'network_health': check_network_health(), + 'latency': measure_latency(), + 'bandwidth': check_bandwidth() + } + return jsonify(metrics) + +if __name__ == '__main__': + app.run(debug=True) diff --git a/static/app.js b/static/app.js new file mode 100644 index 0000000..e2c05ee --- /dev/null +++ b/static/app.js @@ -0,0 +1,34 @@ +function updateMetrics() { + fetch('/api/metrics') + .then(response => response.json()) + .then(data => { + document.getElementById('network-health').innerHTML = ` +
+

Network Health

+

CPU: ${data.network_health.cpu_percent}%

+

Memory: ${data.network_health.memory_percent}%

+

Connections: ${data.network_health.network_connections}

+
+ `; + + document.getElementById('latency').innerHTML = ` +
+

Latency

+

${data.latency.toFixed(2)} ms

+
+ `; + + document.getElementById('bandwidth').innerHTML = ` +
+

Bandwidth

+

Download: ${data.bandwidth.download.toFixed(2)} Mbps

+

Upload: ${data.bandwidth.upload.toFixed(2)} Mbps

+
+ `; + }); +} + +// Update metrics every 30 seconds +setInterval(updateMetrics, 30000); +// Initial update +updateMetrics(); diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..a5d0bac --- /dev/null +++ b/static/style.css @@ -0,0 +1,19 @@ +.container { + max-width: 1200px; + margin: 0 auto; + padding: 20px; +} + +.metrics-container { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); + gap: 20px; + margin-top: 20px; +} + +.metric-card { + background: #f5f5f5; + padding: 20px; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); +} diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..e47dd89 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,18 @@ + + + + GANDALF Network Monitor + + + +
+

GANDALF Network Monitor

+
+
+
+
+
+
+ + +