This lightweight Flask-based web application provides real-time monitoring of AWS EC2 instances or any server resources including CPU, memory, and storage utilization. It also displays the uptime and calculates the ongoing costs based on the EC2 instance type and usage.
- Real-Time Resource Utilization: Monitor CPU, memory, and storage usage in real-time.
- System Uptime: View system uptime in a human-readable format (days, hours, minutes).
- Cost Calculation: Track the cost associated with the EC2 instance up to the current time based on predefined hourly rates.
docker run -d --restart=always -p 8080:8080 --name resources osamayusuf/resource-insight:v1
Server-Insights is now running on http://localhost:8080.
-
Clone the repository or download the source code.
-
Navigate to the app directory and install the required packages:
pip3 install -r requirements.txt
-
Run the Flask app:
python app.py
Server-Insights is now running on http://localhost:8080.
- Open a web browser and navigate to
http://localhost:8080
to view the dashboard. - The
/get_resource_usage
endpoint can be accessed directly to fetch JSON data regarding the resource usage and cost.
GET /
- The main dashboard displaying resource metrics in a graphical interface.GET /get_resource_usage
- Returns JSON data containing CPU, memory, storage usage, uptime, and cost details.
- Resource Usage: Utilizes the
psutil
library to fetch real-time resource metrics. - Uptime: Reads from
/proc/uptime
to calculate the system uptime. - Cost Calculation: Fetches the instance type from EC2 metadata and calculates the cost based on uptime and predefined hourly rates for various EC2 instance types.
To update or modify the hourly rates for EC2 instances, adjust the hourly_rates
dictionary in the get_resource_usage
function with the desired rates corresponding to different EC2 instance types.
Contributions are welcome, and any help that can improve the project is appreciated. Here’s how you can contribute:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -am 'Add some AmazingFeature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a pull request.
Distributed under the MIT License. See LICENSE
for more information.