check_sensors.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
  3. PROGNAME=`basename $0`
  4. PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
  5. REVISION="@NP_VERSION@"
  6. . $PROGPATH/utils.sh
  7. print_usage() {
  8. echo "Usage: $PROGNAME"
  9. }
  10. print_help() {
  11. print_revision $PROGNAME $REVISION
  12. echo ""
  13. print_usage
  14. echo ""
  15. echo "This plugin checks hardware status using the lm_sensors package."
  16. echo ""
  17. support
  18. exit 0
  19. }
  20. case "$1" in
  21. --help)
  22. print_help
  23. exit 0
  24. ;;
  25. -h)
  26. print_help
  27. exit 0
  28. ;;
  29. --version)
  30. print_revision $PROGNAME $REVISION
  31. exit 0
  32. ;;
  33. -V)
  34. print_revision $PROGNAME $REVISION
  35. exit 0
  36. ;;
  37. *)
  38. sensordata=`sensors 2>&1`
  39. status=$?
  40. if test "$1" = "-v" -o "$1" = "--verbose"; then
  41. echo ${sensordata}
  42. fi
  43. if test ${status} -eq 127; then
  44. echo "SENSORS UNKNOWN - command not found (did you install lmsensors?)"
  45. exit -1
  46. elif test ${status} -ne 0 ; then
  47. echo "WARNING - sensors returned state $status"
  48. exit 1
  49. fi
  50. if echo ${sensordata} | egrep ALARM > /dev/null; then
  51. echo SENSOR CRITICAL - Sensor alarm detected!
  52. exit 2
  53. else
  54. echo sensor ok
  55. exit 0
  56. fi
  57. ;;
  58. esac