This Python script provides monitoring functionality for EC2 instances running in AWS. The script collects various data points from the EC2 instances and manages it.
- Python 3.x installed on your local machine.
- AWS CLI installed on your local machine.
- AWS CLI configured with valid AWS credentials and region.
-
Clone or download the repository to your local machine.
git clone https://github.com/PARANOID-09/manage-ec2.git
-
Install the required Python packages by running
pip install -r requirements.txt
. -
Configure your AWS CLI with appropriate credentials and permissions to access EC2 instances.
- Run
python app.py & agent.py &
to start the Flask application and the agent script in the background. - Run
./run_agent.sh
in your terminal to start the EC2 instance monitoring script. The script will start the Flask application and the agent script in the background, and add the agent script as a cron job to run every 5 minutes. - The script will gather data from all the EC2 instances running in the AWS regions and display it in the console.
- You can also access the monitoring information through a web-based interface by navigating to http://localhost:5000 in your web browser.
- To stop the monitoring script, press Ctrl+C.
- The script uses the AWS CLI to gather data from EC2 instances, so make sure you have the AWS CLI installed and configured with appropriate permissions.
- The script requires Python 3.x and the Python packages listed in
requirements.txt
to be installed. - The script uses Flask to display the monitoring information in a web-based interface, so make sure you have Flask installed if you want to use the web-based interface.
- The
run_agent.sh
script has been updated to start the Flask application and the agent script in the background, and add the agent script as a cron job with the correct path to theagent.py
script using pwd which represents the current working directory.