Nagios Plugins
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. #
  3. NAGIOS_OK=0
  4. NAGIOS_ERROR=2
  5. #
  6. NAGIOS_NAME="$2"
  7. PROCESS_NAME="$4"
  8. PROCESS_REGEX="$5"
  9. #
  10. PIDs=$(pidof $PROCESS_NAME)
  11. if [[ -z $PIDs ]]; then
  12. # no such process running
  13. echo "ERROR - No $NAGIOS_NAME process is running!"
  14. exit $NAGIOS_ERROR
  15. else
  16. # there is such a process
  17. ps x -q "$PIDs" | grep "$PROCESS_REGEX" 2>&1 > /dev/null
  18. if [[ $? -eq 0 ]]; then
  19. echo "OK - The required $NAGIOS_NAME process is running"
  20. exit $NAGIOS_OK
  21. else
  22. echo "ERROR - There are processes fitting to $PROCESS_NAME, but none of them fit to the required regex"
  23. exit $NAGIOS_ERROR
  24. fi
  25. fi