This project consists of two scripts that monitor the system’s CPU usage, memory usage, disk usage, and host IP address and predict future CPU usage.
The scripts require the following Python libraries:
- psutil
- datetime
- math
- pandas
- sklearn.linear_model
You can install these using pip:
pip install psutil datetime math pandas sklearn
-
Run the system monitoring script in your terminal. You will be prompted to enter the following parameters:
- Memory max usage: The maximum memory usage in percent. If the system’s memory usage reaches this threshold, a warning will be logged.
- Refresh time: The time interval in seconds at which the system parameters will be checked.
- Number of samples: The number of times the system parameters should be checked.
-
The script will then start monitoring the system parameters and log them in a file named
log_<current_date>.txt
. If the memory usage exceeds the specified threshold, a warning will be logged in a separate file named<current_date>-notification.log
. -
Run the CPU usage prediction script. This script reads the log file generated by the system monitoring script and uses linear regression to predict the CPU usage for the next day. The prediction is printed to the console every 5 minutes.
The output log file contains lines in the following format:
<date>, <time>, <CPU usage>, <memory usage>, <disk usage>, <host IP>
The scripts calculate average CPU usage over the specified refresh time interval and memory and disk usage are reported in gigabytes (GB). Please ensure that you have the necessary permissions to read system parameters and write files in your environment before running these scripts.