From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- .../419187-check_oracle_negativewarncrit.patch | 201 +++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 web/attachments/419187-check_oracle_negativewarncrit.patch (limited to 'web/attachments/419187-check_oracle_negativewarncrit.patch') diff --git a/web/attachments/419187-check_oracle_negativewarncrit.patch b/web/attachments/419187-check_oracle_negativewarncrit.patch new file mode 100644 index 0000000..2319b8b --- /dev/null +++ b/web/attachments/419187-check_oracle_negativewarncrit.patch @@ -0,0 +1,201 @@ +--- check_oracle 2010-10-07 17:11:31.000000000 +0200 ++++ check_oracle_negativewarncrit 2011-07-22 19:28:28.000000000 +0200 +@@ -8,10 +8,15 @@ + + PROGNAME=`basename $0` + PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` +-REVISION="1.4.15" ++REVISION="1.4.15-negativewarncrit" + + . $PROGPATH/utils.sh + ++dflt_cachwarn="85%" ++dflt_cachcrit="95%" ++dflt_tswarn="85%" ++dflt_tscrit="95%" ++ + + print_usage() { + echo "Usage:" +@@ -40,11 +45,11 @@ + echo "--login SID" + echo " Attempt a dummy login and alert if not ORA-01017: invalid username/password" + echo "--cache" +- echo " Check local database for library and buffer cache hit ratios" ++ echo " Check local database for library and buffer cache hit ratios (default warn:$dflt_cachwarn,crit:$dflt_cachcrit)" + echo " ---> Requires Oracle user/password and SID specified." + echo " ---> Requires select on v_$sysstat and v_$librarycache" + echo "--tablespace" +- echo " Check local database for tablespace capacity in ORACLE_SID" ++ echo " Check local database for tablespace capacity in ORACLE_SID (default warn:$dflt_tswarn,crit:$dflt_tscrit)" + echo " ---> Requires Oracle user/password specified." + echo " ---> Requires select on dba_data_files and dba_free_space" + echo "--oranames Hostname" +@@ -54,6 +59,10 @@ + echo "--version" + echo " Print version and license information" + echo "" ++ echo " / can either be a percentage (ie. '15%') or a size in Mega/Giga/Terabyte (ie. '2G'; dflt: M)" ++ echo " Prepend the size with minus to be notified for a certain level below the maximum value," ++ echo " ie. '-2G' to be warned 2G before 'SIZE' (-t) or 'MAXBYTES' (-T) tablespace runs out." ++ echo "" + echo "If the plugin doesn't work, check that the ORACLE_HOME environment" + echo "variable is set, that ORACLE_HOME/bin is in your PATH, and the" + echo "tnsnames.ora file is locatable and is properly configured." +@@ -66,6 +75,54 @@ + support + } + ++ ++# convert_warncrit_val( warnlevel/critlevel ): returns in either % or units of M, no matter what input the user provided ++ReturnVal= ++ReturnUnit= ++convert_warncrit_val() { ++ input=$1; totalsize=$2 ++ tmp=""; tmpunit="" ++ [ `expr index "$input" "%"` -gt 1 ] && tmp=`echo "scale=0; ${input%*%} * $totalsize" | bc | sed 's/\.[0-9]*$//g'` && tmpunit="%" ++ if [ "$tmp" = "" ]; then ++ [ `expr index "$input" "G"` -gt 1 ] && tmp=$[ ${input%*G}*1000 ] && tmpunit="M" ++ [ `expr index "$input" "T"` -gt 1 ] && tmp=$[ ${input%*T}*1000*1000 ] && tmpunit="M" ++ if [ "$tmp" = "" ]; then # default: M ++ foo=$input ++ [ `expr index "$input" "M"` -gt 1 ] && foo=$[ ${input%*M} ] && tmpunit="M" ++ tmp=$foo ++ fi ++ fi ++ ++ [ $tmp -lt 0 ] && tmp=$[ $totalsize + $tmp ] # ie. -2G ++ [ $tmp -lt 0 ] && tmp=0 # ie. the result of the line before was below zero => set to zero. ++ ++ ReturnVal=$tmp ++ ReturnUnit=$tmpunit ++ return ++} ++ ++ ++# do_warncrit_test(warnlevel, critlevel) ++do_warncrit_test() { ++ convert_warncrit_val $1 100; tmpwarn=$ReturnVal # use "100" as "size" for percentile checks, since we don't have that already ++ convert_warncrit_val $2 100; tmpcrit=$ReturnVal ++ ++ if [ $tmpwarn -lt 0 ]; then # ie. -2G ++ if [ $tmpwarn -gt $tmpcrit ]; then ++ echo "UNKNOWN - Warning level is less than Crit" ++ exit $STATE_UNKNOWN ++ fi ++ else ++ if [ $tmpwarn -gt $tmpcrit ]; then ++ echo "UNKNOWN - Warning level is more than Crit" ++ exit $STATE_UNKNOWN ++ fi ++ fi ++} ++ ++ ++ ++ + case "$1" in + 1) + cmd='--tns' +@@ -188,10 +245,14 @@ + fi + ;; + --cache) +- if [ ${5} -gt ${6} ] ; then +- echo "UNKNOWN - Warning level is less then Crit" +- exit $STATE_UNKNOWN ++ ++ do_warncrit_test "$6" "$5" ++ ++ if [ `expr index "$6" "%"` -lt 1 ]; then ++ echo "${2} UNKNOWN - cache check can only use % value for warn/crit level." ++ exit $STATE_UNKNOWN + fi ++ + result=`sqlplus -s ${3}/${4}@${2} << EOF + set pagesize 0 + set numf '9999999.99' +@@ -226,23 +287,32 @@ + lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` + lib_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` + +- if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then +- echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" ++ # for actually usable warn/crit levels with higher precision number ++ convert_warncrit_val "$6" 10000; compwarn=$ReturnVal # $ReturnUnit is being used directly, should be of same type. ++ convert_warncrit_val "$5" 10000; compcrit=$ReturnVal ++ # just snip of the % of the input to get perfdata ++ perfwarn=${6%*%} ++ perfcrit=${5%*%} ++ ++ newbufhr=`echo "$buf_hrx * 10000" | bc -l | sed 's/\.[0-9]*$//g'` ++ newlibhr=`echo "$lib_hrx * 10000" | bc -l | sed 's/\.[0-9]*$//g'` ++ ++ if [ $newbufhr -le $compcrit -o $newlibhr -le $compcrit ] ; then ++ echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx$ReturnUnit;$perfwarn$ReturnUnit;$perfcrit$ReturnUnit;0;100 buffer=$buf_hrx$ReturnUnit;$perfwarn$ReturnUnit;$perfcrit$ReturnUnit;0;100" + exit $STATE_CRITICAL + fi +- if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then +- echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" ++ if [ $newbufhr -le $compwarn -o $newlibhr -le $compwarn ] ; then ++ echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx$ReturnUnit;$perfwarn$ReturnUnit;$perfcrit$ReturnUnit;0;100 buffer=$buf_hrx$ReturnUnit;$perfwarn$ReturnUnit;$perfcrit$ReturnUnit;0;100" + exit $STATE_WARNING + fi +- echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" ++ echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx$ReturnUnit;$perfwarn$ReturnUnit;$perfcrit$ReturnUnit;0;100 buffer=$buf_hrx$ReturnUnit;$perfwarn$ReturnUnit;$perfcrit$ReturnUnit;0;100" + + exit $STATE_OK + ;; + --tablespace) +- if [ ${6} -lt ${7} ] ; then +- echo "UNKNOWN - Warning level is more then Crit" +- exit $STATE_UNKNOWN +- fi ++ ++ do_warncrit_test "$7" "$6" ++ + result=`sqlplus -s ${3}/${4}@${2} << EOF + set pagesize 0 + set numf '9999999.99' +@@ -258,7 +328,7 @@ + + if [ -n "`echo $result | grep ORA-`" ] ; then + error=` echo "$result" | grep "ORA-" | head -1` +- echo "CRITICAL - $error" ++ echo "${2} : ${5} CRITICAL - $error" + exit $STATE_CRITICAL + fi + +@@ -266,19 +336,26 @@ + ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'` + ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'` + ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'` ++ ++ convert_warncrit_val "$7" $ts_total; compwarn=$ReturnVal # $ReturnUnit is either % or M for the perfdata ++ convert_warncrit_val "$6" $ts_total; compcrit=$ReturnVal ++ ++ perfused=$ts_pctx ++ [ "$ReturnUnit" != "%" ] && perfused=$[ $ts_total - $ts_free ] && ReturnUnit="M" ++ + if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then +- echo "No data returned by Oracle - tablespace $5 not found?" ++ echo "${2} : ${5} UNKNOWN - No data returned by Oracle - tablespace $5 not found?" + exit $STATE_UNKNOWN + fi +- if [ "$ts_pct" -ge ${6} ] ; then +- echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" ++ if [ "$ts_pct" -ge "$compcrit" ] ; then ++ echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$perfused$ReturnUnit;$compwarn$ReturnUnit;$compcrit$ReturnUnit;0;100" + exit $STATE_CRITICAL + fi +- if [ "$ts_pct" -ge ${7} ] ; then +- echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" ++ if [ "$ts_pct" -ge "$compwarn" ] ; then ++ echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$perfused$ReturnUnit;$compwarn$ReturnUnit;$compcrit$ReturnUnit;0;100" + exit $STATE_WARNING + fi +- echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" ++ echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$perfused$ReturnUnit;$compwarn$ReturnUnit;$compcrit$ReturnUnit;0;100" + exit $STATE_OK + ;; + *) -- cgit v1.2.3-74-g34f1