Skip to content

Instantly share code, notes, and snippets.

@bindiego
Created March 11, 2020 05:17
Show Gist options
  • Select an option

  • Save bindiego/ff286f00b8fb363e44449e9ff0aa19b4 to your computer and use it in GitHub Desktop.

Select an option

Save bindiego/ff286f00b8fb363e44449e9ff0aa19b4 to your computer and use it in GitHub Desktop.
Linux cpu monitoring

CPU monitoring

5 seconds average, threshold: 90%

#!/bin/bash

CPU=$(sar 1 5 | grep "Average" | sed 's/^.* //')
CPU=$( printf "%.0f" $CPU )

if [ "$CPU" -lt 10 ]
then
        echo "CPU usage is high!" | sendmail [email protected]
fi

run every minute

* * * * * /path/to/cpu-alert.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment