Code

fix for ePN
[nagiosplug.git] / contrib / check_sap.sh
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 ##############################################################################
42 if [ $# -lt 3 ]; then
43 echo "Need min. 3 parameters"
44 exit 2
45 fi
47 case "$1"
48   in
49     ms)
50         if [ $4 ]
51           then
52             params="r3name=$3 mshost=$2 group=$4"
53         else
54           params="r3name=$3 mshost=$2"
55         fi
56         ;;
57     as)
58         params="ashost=$2 sysnr=$3"
59         ;;
60     *)
61         echo "The first parametr must be ms (message server) or as (application server)!"
62         exit 2
63         ;;
64 esac
66 if /usr/sap/rfcsdk/bin/sapinfo $params | grep -i ERROR ; then
67 exit 2
68 else
69 exit 0
70 fi