check_oracle: Fix --tns bad string matching

- Adding 10_check_oracle_tns_bad_string.dpatch
This commit is contained in:
Jan Wagner 2014-08-03 14:45:55 +02:00
parent ec235b0316
commit b2a29995ab
2 changed files with 36 additions and 0 deletions

View file

@ -1,2 +1,3 @@
02_check_icmp_links.dpatch
# commited upstream
10_check_oracle_tns_bad_string.dpatch

View file

@ -0,0 +1,35 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 02_10_check_oracle_tns_bad_string.dpatch by Jan Wagner <waja@cyconet.org>
##
## DP: Create symlinks for check_icmp to provide default values for some situations
From: Frederic Krueger
Subject: Fix check_oracle --tns bad string matching
check_oracle in the 1.4.15 release doesn't correctly parse the output gotten
from at least Oracle 11 (with german locales). I guess it's probably more.
Also it completely needlessly uses sed where basic bash string parsing actually
does more than suffice (and does not run into possible problems with locales
like sed ;)).
Origin: upstream, https://github.com/monitoring-plugins/monitoring-plugins/pull/1191.patch
Bug: https://github.com/monitoring-plugins/monitoring-plugins/issues/1015
@DPATCH@
---
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
index ceac95d..1873a3c 100755
--- a/plugins-scripts/check_oracle.sh
+++ b/plugins-scripts/check_oracle.sh
@@ -137,7 +137,7 @@ case "$cmd" in
tnschk=` tnsping $2`
tnschk2=` echo $tnschk | grep -c OK`
if [ ${tnschk2} -eq 1 ] ; then
- tnschk3=` echo $tnschk | sed -e 's/.*(//' -e 's/).*//'`
+ tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*}
echo "OK - reply time ${tnschk3} from $2"
exit $STATE_OK
else
--
2.0.3