check_sap.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. ################################################################################
  3. #
  4. # CHECK_SAP plugin for Nagios
  5. #
  6. # Written by Karel Salavec (karel.salavec@ct.cz)
  7. # Last Modified: 20Apr2000
  8. #
  9. # Command line: CHECK_SAP <typ_of_check> <param1> <param2> [<param3>]
  10. #
  11. # Description:
  12. # This plugin will attempt to open an SAP connection with the message
  13. # server or application server.
  14. # It need the sapinfo program installed on your server (see Notes).
  15. #
  16. # Notes:
  17. # - This plugin requires that the saprfc-devel-45A-1.i386.rpm (or higher)
  18. # package be installed on your machine. Sapinfo program
  19. # is a part of this package.
  20. # - You can find this package at SAP ftp server in
  21. # /general/misc/unsupported/linux
  22. #
  23. #
  24. # Parameters:
  25. # $1 - type of checking - valid values: "ms" = message server
  26. # "as" = application server
  27. # $2 - SAP server identification - can be IP address, DNS name or SAP
  28. # connect string (for example: /H/saprouter/S/sapdp01/H/sapserv3)
  29. # $3 - for $1="ms" - SAP system name (for example: DEV, TST, ... )
  30. # for $1="as" - SAP system number - note: central instance have sysnr=00
  31. # $4 - valid only for $1="ms" - logon group name - default: PUBLIC
  32. #
  33. # Example of command definitions for nagios:
  34. #
  35. # command[check_sap_ms]=/usr/local/nagios/libexec/check_sap ms $HOSTADDRESS$ $ARG1$ $ARG2$
  36. # command[check_sap_as]=/usr/local/nagios/libexec/check_sap as $HOSTADDRESS$ $ARG1$
  37. # command[check_sap_ex]=/usr/local/nagios/libexec/check_sap as $ARG1$ $ARG2$
  38. # (for ARG1 see SAP OOS1 transaction)
  39. #
  40. ##############################################################################
  41. if [ $# -lt 3 ]; then
  42. echo "Need min. 3 parameters"
  43. exit 2
  44. fi
  45. case "$1"
  46. in
  47. ms)
  48. if [ $4 ]
  49. then
  50. params="r3name=$3 mshost=$2 group=$4"
  51. else
  52. params="r3name=$3 mshost=$2"
  53. fi
  54. ;;
  55. as)
  56. params="ashost=$2 sysnr=$3"
  57. ;;
  58. *)
  59. echo "The first parametr must be ms (message server) or as (application server)!"
  60. exit 2
  61. ;;
  62. esac
  63. if /usr/sap/rfcsdk/bin/sapinfo $params | grep -i ERROR ; then
  64. exit 2
  65. else
  66. exit 0
  67. fi