Module: check_mk
Branch: master
Commit: 03fe5ba2c19f5e1c52d66a061d6b556efb322c96
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=03fe5ba2c19f5e…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Jun 16 15:15:34 2017 +0200
4785 FIX oracle_locks: New SQL for check
The behavior of this check has been changed. There is no output
for object_owner and object_name anymore. This has been removed
for performance reasons. The check is moved from ASYNC to SYNC, due
to very easy SQL for getting the data. The problem with lot of wrong
alarms has been solved as well.
The old SQL is still existing for users who wants the object_owner
and object_name in check result. Please be aware that the old problems
are still there. Please make sure that the old check is configured
as ASYNC-Check. Otherwise you risk high performance issues in mk_oracle!
Please define the following lines in mk_oracle.cfg to get the old
behavior:
SYNC_SECTIONS="instance sessions logswitches undostat recovery_area processes
recovery_status longactivesessions dataguard_stats performance"
ASYNC_SECTIONS="tablespaces rman jobs ts_quotas resumable locks_old"
Change-Id: Ia3a4df0459f895e521f96668f69e79f97f4ff5fb
---
.werks/4785 | 25 +++++++++++++++++++++++++
agents/plugins/mk_oracle | 40 ++++++++++++++++++++++++++++++++++++++--
checks/oracle_locks | 22 +++++++++++++++++++---
3 files changed, 82 insertions(+), 5 deletions(-)
diff --git a/.werks/4785 b/.werks/4785
new file mode 100644
index 0000000..b804fdf
--- /dev/null
+++ b/.werks/4785
@@ -0,0 +1,25 @@
+Title: oracle_locks: New SQL for check
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1497618876
+
+The behavior of this check has been changed. There is no output
+for object_owner and object_name anymore. This has been removed
+for performance reasons. The check is moved from ASYNC to SYNC, due
+to very easy SQL for getting the data. The problem with lot of wrong
+alarms has been solved as well.
+
+The old SQL is still existing for users who wants the object_owner
+and object_name in check result. Please be aware that the old problems
+are still there. Please make sure that the old check is configured
+as ASYNC-Check. Otherwise you risk high performance issues in mk_oracle!
+
+Please define the following lines in mk_oracle.cfg to get the old
+behavior:
+SYNC_SECTIONS="instance sessions logswitches undostat recovery_area processes
recovery_status longactivesessions dataguard_stats performance"
+ASYNC_SECTIONS="tablespaces rman jobs ts_quotas resumable locks_old"
diff --git a/agents/plugins/mk_oracle b/agents/plugins/mk_oracle
index edcd2c0..b199eea 100755
--- a/agents/plugins/mk_oracle
+++ b/agents/plugins/mk_oracle
@@ -72,12 +72,12 @@ fi
# '----------------------------------------------------------------------'
# Sections that run fast and do no caching
-SYNC_SECTIONS="instance sessions logswitches undostat recovery_area processes
recovery_status longactivesessions dataguard_stats performance"
+SYNC_SECTIONS="instance sessions logswitches undostat recovery_area processes
recovery_status longactivesessions dataguard_stats performance locks"
# Sections that are run in the background and at a larger interval.
# Note: sections not listed in SYNC_SECTIONS or ASYNC_SECTIONS will not be
# executed at all!
-ASYNC_SECTIONS="tablespaces rman jobs ts_quotas resumable locks"
+ASYNC_SECTIONS="tablespaces rman jobs ts_quotas resumable"
# Sections that are run in the background and at a larger interval.
# Note: _ASM_ sections are only executed when SID starts with '+'
@@ -577,6 +577,42 @@ sql_logswitches()
sql_locks()
{
+ if [ "$AT_LEAST_ORACLE_102" = 'yes' ] ; then
+ echo 'prompt <<<oracle_locks:sep(124)>>>'
+ echo "select upper(i.instance_name)
+ || '|' || b.sid
+ || '|' || b.serial#
+ || '|' || b.machine
+ || '|' || b.program
+ || '|' || b.process
+ || '|' || b.osuser
+ || '|' || b.username
+ || '|' || b.SECONDS_IN_WAIT
+ || '|' || b.BLOCKING_SESSION_STATUS
+ || '|' || bs.inst_id
+ || '|' || bs.sid
+ || '|' || bs.serial#
+ || '|' || bs.machine
+ || '|' || bs.program
+ || '|' || bs.process
+ || '|' || bs.osuser
+ || '|' || bs.username
+ from v\$session b
+ join v\$instance i on 1=1
+ join gv\$session bs on bs.inst_id = b.BLOCKING_INSTANCE
+ and bs.sid = b.BLOCKING_SESSION
+ where b.BLOCKING_SESSION is not null
+;
+ select upper(i.instance_name)
+ || '|||||||||||||||||'
+ from v\$instance i
+;
+ "
+ fi
+}
+
+sql_locks_old()
+{
if [ "$AT_LEAST_ORACLE_101" = 'yes' ] ; then
echo 'prompt <<<oracle_locks:sep(124)>>>'
echo "SET SERVEROUTPUT ON feedback off
diff --git a/checks/oracle_locks b/checks/oracle_locks
index 5c67f74..549f2dc 100644
--- a/checks/oracle_locks
+++ b/checks/oracle_locks
@@ -26,8 +26,8 @@
# <<<oracle_locks>>>
# TUX12C|273|2985|ora12c.local|sqlplus(a)ora12c.local (TNS
V1-V3)|46148|oracle|633|NULL|NULL
+# newdb|25|15231|ol6131|sqlplus@ol6131 (TNS
V1-V3)|13275|oracle|SYS|3782|VALID|1|407|1463|ol6131|sqlplus@ol6131 (TNS
V1-V3)|13018|oracle|SYS
-# oracle_sid, sid#, serial#, machine, program, process, osuser, ctime object_owner
object_name
factory_settings["oracle_locks_defaults"] = {
"levels" : (1800, 3600),
@@ -51,8 +51,24 @@ def check_oracle_locks(item, params, info):
elif isinstance(err, tuple):
return err
- sid, sidnr, serial, machine, program, process, osuser, ctime, \
- object_owner, object_name = line
+ if len(line) == 10:
+
+ # old format from locks_old in current plugin
+ sid, sidnr, serial, machine, program, process, osuser, ctime, \
+ object_owner, object_name = line
+
+ elif len(line) == 18:
+
+ sid, sidnr, serial, machine, program, process, osuser, dbusername, ctime,
\
+ block_status, blk_inst_id, blk_sid, blk_serial, blk_machine, blk_program,
\
+ blk_process, blk_osuser, blk_dbusername = line
+
+ object_owner = ''
+ object_name = ''
+
+ else:
+
+ raise MKCounterWrapped("Unknow number of items in agent
output")
ctime = int(ctime)