https://github.com/octonawish-akcodes/system-health-monitoring
A Python script that monitors Linux system health by checking CPU, memory, disk usage, and processes, and logs alerts if any thresholds are exceeded.
https://github.com/octonawish-akcodes/system-health-monitoring
Last synced: 2 months ago
JSON representation
A Python script that monitors Linux system health by checking CPU, memory, disk usage, and processes, and logs alerts if any thresholds are exceeded.
- Host: GitHub
- URL: https://github.com/octonawish-akcodes/system-health-monitoring
- Owner: octonawish-akcodes
- Created: 2024-08-06T05:17:35.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-06T05:26:34.000Z (10 months ago)
- Last Synced: 2025-03-28T01:59:54.836Z (2 months ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# System-Health-Monitoring
**Purpose:**
This Python script monitors system health by checking CPU usage, memory usage, disk usage, and running processes. It logs warnings when values exceed predefined thresholds.**Dependencies:**
* psutil
* logging**Configuration:**
* **CPU_THRESHOLD:** Sets the maximum allowed CPU usage percentage.
* **MEMORY_THRESHOLD:** Sets the maximum allowed memory usage percentage.
* **DISK_THRESHOLD:** Sets the maximum allowed disk usage percentage.
* **LOG_FILE:** Specifies the path to the log file.**How it works:**
1. Imports necessary libraries and sets up logging.
2. Defines functions to check CPU usage, memory usage, disk usage, and running processes.
3. Each function calculates the respective metric and logs a warning if it exceeds the threshold.
4. The `main` function calls all check functions.**Usage:**
1. Ensure required dependencies are installed (`psutil` and `logging`).
2. Adjust configuration parameters as needed.
3. Run the script `python3 app.py`.**Output:**
The script logs warning messages to the specified log file when system health metrics exceed thresholds.**Example Output (Log file):**
```
2024-08-06 10:14:49,056 - WARNING - CPU usage is high: 12.8%
2024-08-06 10:14:49,057 - WARNING - Memory usage is high: 67.1%
2024-08-06 10:14:49,057 - WARNING - Disk usage is high: 31.2%
```