2 ################################################################################
4 # CHECK_SAP plugin for Nagios
6 # Originally Written by Karel Salavec (karel.salavec@ct.cz)
8 # Last Modified: 26 May 2003 by Tom De Blende (tom.deblende@village.uunet.be)
10 # Version 1.1 (Tom De Blende)
11 # - Added output to feed to Nagios instead of just an exit code.
12 # - Changed info on where to get the SAP client tools for Linux.
14 # Version 1.0 (Karel Salavec)
16 # Command line: check_sap.sh <typ_of_check> <param1> <param2> [<param3>]
19 # This plugin will attempt to open an SAP connection with the message
20 # server or application server.
21 # It need the sapinfo program installed on your server (see Notes).
24 # - This plugin requires that the sapinfo program is installed.
25 # - Sapinfo is part of a client package that can be found
26 # at ftp://ftp.sap.com/pub/linuxlab/contrib/.
30 # $1 - type of checking - valid values: "ms" = message server
31 # "as" = application server
32 # $2 - SAP server identification - can be IP address, DNS name or SAP
33 # connect string (for example: /H/saprouter/S/sapdp01/H/sapserv3)
34 # $3 - for $1="ms" - SAP system name (for example: DEV, TST, ... )
35 # for $1="as" - SAP system number - note: central instance have sysnr=00
36 # $4 - valid only for $1="ms" - logon group name - default: PUBLIC
38 # Example of command definitions for nagios:
40 # command[check_sap_ms]=/usr/local/nagios/libexec/check_sap ms $HOSTADDRESS$ $ARG1$ $ARG2$
41 # command[check_sap_as]=/usr/local/nagios/libexec/check_sap as $HOSTADDRESS$ $ARG1$
42 # command[check_sap_ex]=/usr/local/nagios/libexec/check_sap as $ARG1$ $ARG2$
43 # (for ARG1 see SAP OOS1 transaction)
45 ##############################################################################
47 sapinfocmd
='/usr/sap/rfcsdk/bin/sapinfo'
53 ##############################################################################
56 echo "Usage: $0 <typ_of_check> <param1> <param2> [<param3>]"
65 params
="r3name=$3 mshost=$2 group=$4"
67 params
="r3name=$3 mshost=$2"
71 params
="ashost=$2 sysnr=$3"
74 echo "The first parameter must be ms (message server) or as (application server)!"
79 output
="$($sapinfocmd $params)"
80 error
="$(echo "$output" | $grepcmd ERROR | $wccmd -l)"
81 if [ "$error" -gt "0" ]; then
82 output
="$(echo "$output" | $grepcmd Key | $cutcmd -dy -f2)"
83 echo "CRITICAL - SAP server not ready: " $output.
86 output
="$(echo "$output" | $grepcmd Destination | $awkcmd '{ print $2 }')"
87 echo "OK - SAP server $output available."