(only one server currrently available, but supports multi-system monitoring)
Resource Radar is a Flask-based web application designed to monitor and visualize real-time metrics for distributed systems. It supports user authentication via Google OAuth, provides role-based access control (RBAC), and includes an admin panel for user management. Currently supports monitoring for up to 4 devices.
- Real-time Monitoring: Visualizes system metrics for distributed systems
- Historical Data: Admin-only access to historical performance metrics
- User Management: Administrative interface for managing users
- Authentication: Secure login via Google OAuth
- Role-Based Access Control: Different permission levels for various users
- Data Visualization: Interactive charts for metric display
.
├── app/ # Contains the main application code
│ ├── __init__.py # Initializes the Flask app, sets up extensions, and registers blueprints
│ ├── admin.py # Configures Flask-Admin for user management
│ ├── auth.py # Handles user authentication via Google OAuth
│ ├── data_retrieval.py # Manages data collection from systems
│ ├── metric_collector.py # Collects system metrics
│ ├── models.py # Defines the database schema, including the User model
│ ├── routes.py # Defines the main application routes
│ ├── tasks.py # Handles background tasks for data collection
│ ├── static/ # Contains static files (CSS, JavaScript)
│ └── templates/ # Contains HTML templates
├── config.py # Stores configuration settings
└── requirements.txt # Lists project dependencies
- Python 3.8+ installed on your system
- SQLite for the database (pre-installed with Python)
- Web browser with JavaScript enabled
-
Fork and clone the repository:
git clone https://gitlab.com/sampauly/cop4521-flask.git cd cop4521-flask -
Create a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
Note: Use the path to your Python installation if different
-
Install dependencies:
python -m pip install -r requirements.txt
- Go to Google Cloud Console and create a new project
- In APIs & Services > OAuth consent screen, set up your app with External audience
- Go to APIs & Services > Credentials and create a new OAuth Client ID
- Set Application type as Web Application and add
http://127.0.0.1:8000/callbackas an Authorized redirect URI - Create a
.envfile in the project root with:GOOGLE_CLIENT_ID=your-client-id GOOGLE_CLIENT_SECRET=your-client-secret SECRET_KEY=unique-flask-app-identifier - Generate a secure SECRET_KEY with:
python -c "import secrets; print(secrets.token_hex(32))"
Initialize and apply database migrations:
flask db init
flask db migrate -m "Initial migration"
flask db upgradeTo run the application with Gunicorn:
gunicorn --workers 1 --bind unix:/run/flask.sock "app:create_app()"For development purposes:
flask run --debugThe application runs background tasks that:
- Collect system metrics every 10 minutes
- Log data to the SQLite database
- Dashboard: Available to all authenticated users
- Historical Data: Available to admin users only
- User Management: Available to admin users only
When you first launch the application, you'll see a "Login with Google" button. After logging in, you may receive an "Unauthorized" message because your email isn't recognized in the database yet.
To manually add the first admin user:
-
Open the Flask shell:
flask shell
-
Import the necessary modules:
from app.models import db, User
-
Create and add a user:
user = User(username="new_username", email="youremail@gmail.com", type="Admin") db.session.add(user) db.session.commit()
Once your email is added, Google authentication will verify you, and the app will grant you admin access. To add more users, you can use the "Manage Users" link within the application.