cpu 437 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. cpu_perc=$(awk '
  3. /^Average/ {
  4. printf("%i", 100 - $12)
  5. }
  6. ' <(mpstat 1 1 --dec=0)
  7. )
  8. cpu_temp=$(awk '
  9. /^Package/ {
  10. p=substr($4, 2, length($4))
  11. }
  12. /^temp5/ {
  13. t=substr($2, 2, length($2))
  14. }
  15. END {
  16. if (p) {
  17. print p
  18. exit
  19. }
  20. print t
  21. }
  22. ' <(sensors)
  23. )
  24. echo "CPU $cpu_perc% $cpu_temp"
  25. [ $cpu_perc -qt 65 ] && exit 33