| 12345678910111213141516171819202122232425262728 |
- #!/usr/bin/env bash
- cpu_perc=$(awk '
- /^Average/ {
- printf("%i", 100 - $12)
- }
- ' <(mpstat 1 1 --dec=0)
- )
- cpu_temp=$(awk '
- /^Package/ {
- p=substr($4, 2, length($4))
- }
- /^temp5/ {
- t=substr($2, 2, length($2))
- }
- END {
- if (p) {
- print p
- exit
- }
- print t
- }
- ' <(sensors)
- )
- echo "CPU $cpu_perc% $cpu_temp"
- [ $cpu_perc -qt 65 ] && exit 33
|