You are here

submit_check_result.txt in Monitoring 7

#!/bin/bash

## Configuration section ##

# Address of the central Icinga server.
central_server="@central_server"

# Host name as defined by the host object definition at the Icinga server.
host_name="@host_name"

# The local send_nsca command.
SEND_NSCA="/usr/sbin/send_nsca"

# The send_nsca config file.
send_nsca_cfg="/etc/send_nsca.cfg"

# Will invoke drush command to get sensors results. Make sure the drush path
# and argument values are correct.
dump=`/path/to/drush --root=@root --uri=@uri monitoring-icinga`

# Alternatively with sudo:
#
# dump=`sudo -u www_user /path/to/drush --root=@root --uri=@uri monitoring-icinga`

## Configuration end ##

IFS='~' read -a array <<< "$dump"

for line in "${array[@]}"
do
  IFS='|' read -a result <<< "$line"

  return_code=-1

  case "${result[1]}" in
    OK)
      return_code=0
      ;;
    WARNING)
      return_code=1
      ;;
    CRITICAL)
      return_code=2
      ;;
    UNKNOWN)
      return_code=-1
      ;;
  esac

  echo "${result[0]}"

  printf "%s\t%s\t%s\t%s\n" "$host_name" "${result[0]}" "$return_code" "${result[2]}" | $SEND_NSCA -H  "$central_server" -c "$send_nsca_cfg"

done

File

modules/monitoring_icinga/config_tpl/submit_check_result.txt
View source
  1. #!/bin/bash
  2. ## Configuration section ##
  3. # Address of the central Icinga server.
  4. central_server="@central_server"
  5. # Host name as defined by the host object definition at the Icinga server.
  6. host_name="@host_name"
  7. # The local send_nsca command.
  8. SEND_NSCA="/usr/sbin/send_nsca"
  9. # The send_nsca config file.
  10. send_nsca_cfg="/etc/send_nsca.cfg"
  11. # Will invoke drush command to get sensors results. Make sure the drush path
  12. # and argument values are correct.
  13. dump=`/path/to/drush --root=@root --uri=@uri monitoring-icinga`
  14. # Alternatively with sudo:
  15. #
  16. # dump=`sudo -u www_user /path/to/drush --root=@root --uri=@uri monitoring-icinga`
  17. ## Configuration end ##
  18. IFS='~' read -a array <<< "$dump"
  19. for line in "${array[@]}"
  20. do
  21. IFS='|' read -a result <<< "$line"
  22. return_code=-1
  23. case "${result[1]}" in
  24. OK)
  25. return_code=0
  26. ;;
  27. WARNING)
  28. return_code=1
  29. ;;
  30. CRITICAL)
  31. return_code=2
  32. ;;
  33. UNKNOWN)
  34. return_code=-1
  35. ;;
  36. esac
  37. echo "${result[0]}"
  38. printf "%s\t%s\t%s\t%s\n" "$host_name" "${result[0]}" "$return_code" "${result[2]}" | $SEND_NSCA -H "$central_server" -c "$send_nsca_cfg"
  39. done