Module: check_mk
Branch: master
Commit: da23bff22c97cf38328aba3eabcc0e2d33656d91
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=da23bff22c97cf…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Mar 29 15:30:01 2019 +0100
mk_sap_hana: More generic way to find out SID and INSTANCE
Change-Id: I14652079421bf516aab2044da687f627772d967f
---
agents/plugins/mk_sap_hana | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/agents/plugins/mk_sap_hana b/agents/plugins/mk_sap_hana
index caafd7c..946f1e1 100755
--- a/agents/plugins/mk_sap_hana
+++ b/agents/plugins/mk_sap_hana
@@ -486,15 +486,15 @@ function do_query () {
# | |
# '----------------------------------------------------------------------'
-
# pgrep might not be available on older distros:
# shellcheck disable=SC2009
ps -efw | grep "[H]DB.*sapstartsrv" | while read -r line; do
- # (!<= is a look behind assertion, so we find \w{3} <- 3 alpha-numerical
characters, that follow " /usr/sap/" <- note the leading space
- SID=$(echo "$line" | grep -Po '(?<= /usr/sap/)\w{3}')
-
- # same logic as above, but look for 2 \d digits
- INSTANCE=$(echo "$line" | grep -Po "(?<=
/usr/sap/${SID}/HDB)\d{2}")
+ # 'sapstartsrv' may have different base paths:
+ # /hana/shared/ABC/HDB10/exe/sapstartsrv pf=/hana/shared/ABC/profile/ABC_HDB10_FOOBAR
-D -u USER
+ # /usr/sap/ABC/HDB10/exe/sapstartsrv pf=/hana/shared/ABC/profile/ABC_HDB10_FOOBAR -D
-u USER
+ # From these paths we extract: SID=ABC, INSTANCE=10
+ SID=$(echo "$line" | sed
's/.*\/\(.*\)\/.*\/exe\/sapstartsrv.*/\1/g')
+ INSTANCE=$(echo "$line" | sed -e
's/.*\/\(.*\)\/exe\/sapstartsrv.*/\1/g' -e 's/[^0-9]//g')
# grep only the first word = the user running the instance
INSTANCE_USER=$(echo "$line" | grep -Po "^\s*(\w+)")