This repository contains a Bash script for monitoring system performance, including CPU and memory usage, and logging the results. The script generates JSON log entries with timestamps for tracking system performance over time.
To use this script, follow these steps:
-
Clone the repository to your local machine:
git clone https://github.com/loydle/performance-monitoring-script.git
-
Make the script executable:
chmod +x monitor-performances.sh
-
Set up a Cron Job:
The script will start monitoring and logging performance data with timestamps. You can modify the script as needed to customize the log format or data collected.
crontab -e
Add an entry to run the script at your desired intervals. For example, to run the script every 15 minutes:
*/15 * * * * /path/to/monitor-performances.sh
Save the crontab file. The script will now be executed automatically at the specified intervals.
The script logs data in JSON format. Here's an example of a log entry:
{
"timestamp": "2023-11-02T09:30:00Z",
"cpu_usage": {
"User": "1.0",
"System": "3.0",
"Idle": "96.0"
},
"memory_usage": {
"Total": "7.8Gi",
"Used": "1.1Gi",
"Free": "5.2Gi",
"Available": "6.3Gi"
}
}