This script provides real-time monitoring of CPU, memory, and disk usage on a Unix-like system. It is designed to be easy to use and highly configurable.
- Real-Time Monitoring: Displays CPU, memory, and disk usage every few seconds.
- Customizable Interval: Users can set the refresh interval.
- Multiple Disk Monitoring: Supports monitoring multiple disk mount points.
- Configuration File: Allows loading configuration from an external file.
- Graceful Exit: Handles
SIGINT
(Ctrl+C) andSIGTERM
signals to exit gracefully.
-
Clone the Repository
git clone https://github.com/elliotsecops/System-Monitor.git cd System-Monitor
-
Make the Script Executable
chmod u+x system_monitor.sh
-
Install the Script
./install.sh
To run the script with default settings:
system_monitor
-
Set Interval: Use the
-i
or--interval
option to set the refresh interval in seconds.system_monitor -i 10
-
Add Disk Mount Points: Use the
-d
or--disk
option to add disk mount points to monitor.system_monitor -d /mnt/data -d /mnt/backup
-
Load Configuration File: Use the
-c
or--config
option to load configuration from a file.system_monitor -c config.sh
-
Display Help: Use the
-h
or--help
option to display the help message.system_monitor -h
You can create a configuration file to set default values for interval and disk mount points. Here is an example config.sh
:
INTERVAL=5
DISKS="/ /mnt/data /mnt/backup" # Space-separated
Place this file in the same directory as the script or specify its path when running the script with the -c
option.
To monitor CPU, memory, and disk usage every 10 seconds, including /mnt/data
and /mnt/backup
mount points, using a configuration file:
-
Create a configuration file
config.sh
:INTERVAL=10 DISKS="/mnt/data /mnt/backup"
-
Run the script with the configuration file:
system_monitor -c config.sh
- Script Not Found: Ensure the script is executable and located in your current directory or specify the full path.
- Invalid Interval: The interval must be a positive integer. If you encounter an error, check the interval value.
- Disk Mount Points: Ensure the specified disk mount points exist and are accessible.
Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License. See the LICENSE
file for more details.