system-prompts-and-models-o.../Storage Dashboard/backend/app.py
Claude 563a800fad
Add comprehensive Storage Device Performance Dashboard
This commit introduces a complete web-based dashboard for monitoring storage device performance metrics in real-time.

Features:
- Real-time monitoring with auto-refresh every 5 seconds
- Comprehensive metrics collection (disk usage, I/O stats, IOPS, SMART data)
- Interactive visualizations using Chart.js
- Modern dark-themed responsive UI
- Python Flask backend with REST API
- System information and uptime tracking
- Historical performance trend charts

Tech Stack:
- Backend: Python 3.8+, Flask, psutil, pySMART
- Frontend: HTML5, CSS3, JavaScript ES6+, Chart.js
- Cross-platform support with startup scripts for Linux/Windows

The dashboard provides system administrators and monitoring enthusiasts with a powerful tool to track storage performance, identify bottlenecks, and monitor disk health.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-20 21:06:04 +00:00

71 lines
1.9 KiB
Python

from flask import Flask, jsonify, send_from_directory
from flask_cors import CORS
from metrics_collector import StorageMetricsCollector
import os
app = Flask(__name__, static_folder='../frontend')
CORS(app)
# Initialize metrics collector
collector = StorageMetricsCollector()
@app.route('/')
def index():
"""Serve the main dashboard page"""
return send_from_directory('../frontend', 'index.html')
@app.route('/api/metrics')
def get_metrics():
"""Get all storage metrics"""
try:
metrics = collector.get_all_metrics()
return jsonify(metrics)
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/partitions')
def get_partitions():
"""Get disk partition information"""
try:
partitions = collector.get_disk_partitions()
return jsonify(partitions)
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/io-stats')
def get_io_stats():
"""Get I/O statistics"""
try:
io_stats = collector.get_io_stats()
return jsonify(io_stats)
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/smart')
def get_smart():
"""Get SMART data for disks"""
try:
smart_data = collector.get_smart_data()
return jsonify(smart_data)
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/system-info')
def get_system_info():
"""Get system information"""
try:
system_info = collector.get_system_info()
return jsonify(system_info)
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/<path:path>')
def serve_static(path):
"""Serve static files"""
return send_from_directory('../frontend', path)
if __name__ == '__main__':
print("Starting Storage Dashboard Server...")
print("Access the dashboard at: http://localhost:5000")
app.run(debug=True, host='0.0.0.0', port=5000)