diff options
author | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | 2003-05-27 13:10:01 +0000 |
---|---|---|
committer | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | 2003-05-27 13:10:01 +0000 |
commit | 817eed9c0f8814b2b364eb945cbab665389b1d05 (patch) | |
tree | 7059c42e5ca70076421e1524189272de02da1938 /contrib | |
parent | 64d1ef0db6c347f7a04cd6967f736995d19981ce (diff) | |
download | monitoring-plugins-817eed9c0f8814b2b364eb945cbab665389b1d05.tar.gz |
check_sap.sh plugin to check SAP /R3 servers from Karel Salavec and Tom De Blende.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@523 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/check_sap.sh | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/contrib/check_sap.sh b/contrib/check_sap.sh index eadf977e..726d7502 100755 --- a/contrib/check_sap.sh +++ b/contrib/check_sap.sh | |||
@@ -3,10 +3,17 @@ | |||
3 | # | 3 | # |
4 | # CHECK_SAP plugin for Nagios | 4 | # CHECK_SAP plugin for Nagios |
5 | # | 5 | # |
6 | # Written by Karel Salavec (karel.salavec@ct.cz) | 6 | # Originally Written by Karel Salavec (karel.salavec@ct.cz) |
7 | # Last Modified: 20Apr2000 | 7 | # |
8 | # Last Modified: 26 May 2003 by Tom De Blende (tom.deblende@village.uunet.be) | ||
9 | # | ||
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. | ||
8 | # | 13 | # |
9 | # Command line: CHECK_SAP <typ_of_check> <param1> <param2> [<param3>] | 14 | # Version 1.0 (Karel Salavec) |
15 | # | ||
16 | # Command line: check_sap.sh <typ_of_check> <param1> <param2> [<param3>] | ||
10 | # | 17 | # |
11 | # Description: | 18 | # Description: |
12 | # This plugin will attempt to open an SAP connection with the message | 19 | # This plugin will attempt to open an SAP connection with the message |
@@ -14,11 +21,9 @@ | |||
14 | # It need the sapinfo program installed on your server (see Notes). | 21 | # It need the sapinfo program installed on your server (see Notes). |
15 | # | 22 | # |
16 | # Notes: | 23 | # Notes: |
17 | # - This plugin requires that the saprfc-devel-45A-1.i386.rpm (or higher) | 24 | # - This plugin requires that the sapinfo program is installed. |
18 | # package be installed on your machine. Sapinfo program | 25 | # - Sapinfo is part of a client package that can be found |
19 | # is a part of this package. | 26 | # at ftp://ftp.sap.com/pub/linuxlab/contrib/. |
20 | # - You can find this package at SAP ftp server in | ||
21 | # /general/misc/unsupported/linux | ||
22 | # | 27 | # |
23 | # | 28 | # |
24 | # Parameters: | 29 | # Parameters: |
@@ -39,8 +44,16 @@ | |||
39 | # | 44 | # |
40 | ############################################################################## | 45 | ############################################################################## |
41 | 46 | ||
47 | sapinfocmd='/usr/sap/rfcsdk/bin/sapinfo' | ||
48 | grepcmd=`which grep` | ||
49 | wccmd=`which wc` | ||
50 | cutcmd=`which cut` | ||
51 | awkcmd=`which awk` | ||
52 | |||
53 | ############################################################################## | ||
54 | |||
42 | if [ $# -lt 3 ]; then | 55 | if [ $# -lt 3 ]; then |
43 | echo "Need min. 3 parameters" | 56 | echo "Usage: $0 <typ_of_check> <param1> <param2> [<param3>]" |
44 | exit 2 | 57 | exit 2 |
45 | fi | 58 | fi |
46 | 59 | ||
@@ -58,13 +71,19 @@ case "$1" | |||
58 | params="ashost=$2 sysnr=$3" | 71 | params="ashost=$2 sysnr=$3" |
59 | ;; | 72 | ;; |
60 | *) | 73 | *) |
61 | echo "The first parametr must be ms (message server) or as (application server)!" | 74 | echo "The first parameter must be ms (message server) or as (application server)!" |
62 | exit 2 | 75 | exit 2 |
63 | ;; | 76 | ;; |
64 | esac | 77 | esac |
65 | 78 | ||
66 | if /usr/sap/rfcsdk/bin/sapinfo $params | grep -i ERROR ; then | 79 | output="$($sapinfocmd $params)" |
67 | exit 2 | 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. | ||
84 | exit 2 | ||
68 | else | 85 | else |
69 | exit 0 | 86 | output="$(echo "$output" | $grepcmd Destination | $awkcmd '{ print $2 }')" |
87 | echo "OK - SAP server $output available." | ||
88 | exit 0 | ||
70 | fi | 89 | fi |