Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/antoonline/bash-script-monitor-docker-high-cpu

This script monitors CPU load on a system running Docker and generates a report if the load exceeds a specified threshold. It displays the top 5 containers contributing to high CPU load, overall CPU usage, and top 50 processes on the host. Optionally, the report can be sent to Slack if a webhook URL is provided.
https://github.com/antoonline/bash-script-monitor-docker-high-cpu

cpu-monitoring docker slack ubuntu

Last synced: 13 days ago
JSON representation

This script monitors CPU load on a system running Docker and generates a report if the load exceeds a specified threshold. It displays the top 5 containers contributing to high CPU load, overall CPU usage, and top 50 processes on the host. Optionally, the report can be sent to Slack if a webhook URL is provided.

Awesome Lists containing this project

README

        

# CPU Load Monitor

This script monitors the average CPU load on a system with Docker installed. If the load exceeds a specified threshold, it will generate a report containing the top 5 containers contributing to the high CPU load and the top 50 processes on the host, sorted by CPU usage. The report can be sent to a Slack channel as an attachment using a Slack webhook URL.

## Requirements

- Docker must be installed on the system.
- Slack webhook URL (optional) for sending reports to a Slack channel.

## Usage

1. Set up the script to run periodically using cron or another scheduling tool.
2. Provide the threshold as a mandatory argument when running the script.
3. Optionally, provide a Slack webhook URL as a second argument to send reports to a Slack channel.

```bash
./monitor_cpu_load.sh [slack_webhook]
```

Example:

```bash
./monitor_cpu_load.sh 40 "https://hooks.slack.com/services/your-webhook-url"
```

Example cron job:

```bash
*/5 * * * * /bin/bash /path/to/monitor_cpu_load.sh 40 "https://hooks.slack.com/services/your-webhook-url"
```

## License

This project is licensed under the MIT License.

## Disclaimer

Use this script at your own risk. The author and contributors are not responsible for any damages or issues caused by the use of this script.

## Want to connect?

Feel free to contact me on [Twitter](https://twitter.com/OnlineAnto), [DEV Community](https://dev.to/antoonline/) or [LinkedIn](https://www.linkedin.com/in/anto-online) if you have any questions or suggestions.

Or just visit my [website](https://anto.online) to see what I do.