Skip to content

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.

Notifications You must be signed in to change notification settings

AntoOnline/bash-script-monitor-docker-high-cpu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

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.
./monitor_cpu_load.sh <threshold> [slack_webhook]

Example:

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

Example cron job:

*/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, DEV Community or LinkedIn if you have any questions or suggestions.

Or just visit my website to see what I do.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages