Module: check_mk
Branch: master
Commit: 5cc14b9854c88ba5dd86054237ef53ee30fac8e4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5cc14b9854c88b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon May 6 10:36:49 2013 +0200
oracle_jobs: New check to monitor oracle database job execution
---
ChangeLog | 1 +
agents/plugins/mk_oracle | 14 +++++++
checks/oracle_jobs | 105 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 120 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 26c5507..eee2b89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -53,6 +53,7 @@
* if64_tplink: special new check for TP Link switches with broken SNMP output
* job: Monitoring states and performance indicators of any jobs on linux systems
* oracle_asm_diskgroups: Added missing agent plugin + asmcmd wrapper script
+ * oracle_jobs: New check to monitor oracle database job execution
* cisco_qos: adhere qos-bandwidth policies
* check_disk_smb: WATO formalization for active check check_disk_smb
* if.include: new configurable parameters for assumed input and output speed
diff --git a/agents/plugins/mk_oracle b/agents/plugins/mk_oracle
index 92781ff..ae35dea 100755
--- a/agents/plugins/mk_oracle
+++ b/agents/plugins/mk_oracle
@@ -166,6 +166,20 @@ for SID in $SIDS; do
echo \"select count(1) from v\\\$loghist where first_time >
sysdate - 1/24;\" | sqlplus \"$SID\"
fi
+ if [ '$EXCLUDE' = '${EXCLUDE/jobs/}' ]; then
+ echo '<<<oracle_jobs>>>'
+ sqlplus "$SID" <<EOF
+ SELECT j.OWNER, j.JOB_NAME, j.STATE,
+ (TRUNC(sysdate) + j.LAST_RUN_DURATION - TRUNC(sysdate)) * 86400 AS
LAST_RUN_DURATION,
+ j.RUN_COUNT, j.ENABLED, NVL(j.NEXT_RUN_DATE,
to_date('1970-01-01', 'YYYY-mm-dd')),
+ NVL(j.SCHEDULE_NAME, '-'), d.STATUS
+ FROM dba_scheduler_jobs j, dba_scheduler_job_run_details d
+ WHERE d.owner=j.OWNER AND d.JOB_NAME=j.JOB_NAME
+ AND d.LOG_ID=(SELECT max(LOG_ID) FROM dba_scheduler_job_run_details
dd
+ WHERE dd.owner=j.OWNER and dd.JOB_NAME=j.JOB_NAME);
+EOF
+ fi
+
if [ '$EXCLUDE' = '${EXCLUDE/tablespaces/}' ]; then
echo '<<<oracle_tablespaces>>>'
sqlplus "$SID" <<EOF | sed 's/READ
ONLY/READONLY/g'
diff --git a/checks/oracle_jobs b/checks/oracle_jobs
new file mode 100644
index 0000000..394e247
--- /dev/null
+++ b/checks/oracle_jobs
@@ -0,0 +1,105 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# <<<oracle_jobs>>>
+# IODBSZ1 SYS SM$CLEAN_AUTO_SPLIT_MERGE SCHEDULED 0 763 TRUE 24.04.13 00:00:00,600000
EUROPE/VIENNA - SUCCEEDED 0
+# IODBSZ1 SYS RSE$CLEAN_RECOVERABLE_SCRIPT SCHEDULED 0 763 TRUE 24.04.13 00:00:00,100000
EUROPE/VIENNA - SUCCEEDED 0
+# IODBSZ1 SYS BSLN_MAINTAIN_STATS_JOB SCHEDULED 0 110 TRUE 29.04.13 00:00:00,300000
+01:00 BSLN_MAINTAIN_STATS_SCHED SUCCEEDED 0
+# IODBSZ1 SYS DRA_REEVALUATE_OPEN_FAILURES SCHEDULED 0 97 TRUE 01.01.70 00:00:00,000000
+02:00 MAINTENANCE_WINDOW_GROUP SUCCEEDED 0
+# IODBSZ1 SYS ORA$AUTOTASK_CLEAN SCHEDULED 0 763 TRUE 24.04.13 03:00:00,900000
EUROPE/VIENNA DAILY_PURGE_SCHEDULE SUCCEEDED 0
+# IODBSZ1 SYS PURGE_LOG SCHEDULED 0 763 TRUE 24.04.13 03:00:00,800000 EUROPE/VIENNA
DAILY_PURGE_SCHEDULE SUCCEEDED 0
+# IODBSZ1 ORACLE_OCM MGMT_CONFIG_JOB SCHEDULED 0 97 TRUE 01.01.70 00:00:00,000000 +02:00
MAINTENANCE_WINDOW_GROUP SUCCEEDED 1
+# IODBSZ1 ORACLE_OCM MGMT_STATS_CONFIG_JOB SCHEDULED 0 3 TRUE 01.05.13 01:01:01,000000
+01:00 - SUCCEEDED 1
+# IODBSZ1 EXFSYS RLM$SCHDNEGACTION SCHEDULED 0 18954 TRUE 23.04.13 14:51:57,000000 +02:00
- SUCCEEDED 0
+# IODBSZ1 EXFSYS RLM$EVTCLEANUP SCHEDULED 0 18202 TRUE 23.04.13 13:41:48,200000 +01:00 -
SUCCEEDED 0
+
+def inventory_oracle_jobs(info):
+ inventory = []
+ for line in info:
+ if line[6] == "TRUE": # only add enabled jobs
+ inventory.append(("%s.%s" % (line[0], line[2]), {}))
+ return inventory
+
+def check_oracle_jobs(item, params, info):
+ try:
+ sid, jobname = item.split('.')
+ except ValueError:
+ return (3, 'Invalid check item given (must be
<SID>.<job_name>)')
+
+ data = None
+ for line in info:
+ if line[0] == sid and line[2] == jobname:
+ data = line
+ break
+ if not data:
+ return (3, 'Unable to find the job')
+
+ state = 0
+ output = []
+ perfdata = []
+
+ job_state = line[3]
+
+ txt = "Job-State: %s" % job_state
+ if job_state == "BROKEN":
+ txt += " (!!)"
+ state = max(state, 2)
+ output.append(txt)
+
+ txt = "Enabled: %s" % (line[6] == "TRUE" and "Yes" or
"No")
+ if line[6] != "TRUE":
+ txt += " (!)"
+ state = max(state, 1)
+ output.append(txt)
+
+ last_duration = int(line[4])
+ output.append("Last Duration: %s" % get_age_human_readable(last_duration))
+ perfdata.append(("duration", last_duration))
+
+ # 01.05.13 01:01:01,000000 +01:00
+ next_run = " ".join(line[7:9])
+ if next_run.startswith("01.01.70 00:00:00"):
+ if line[-1] == "-":
+ next_run = "not scheduled (!)"
+ state = max(state, 1)
+ else:
+ next_run = line[10]
+ output.append("Next Run: %s" % next_run)
+
+ txt = "Last Run Status: %s" % (line[11])
+ if line[11] != "SUCCEEDED":
+ txt += " (!!)"
+ state = max(state, 2)
+ output.append(txt)
+
+ return (state, ", ".join(output), perfdata)
+
+check_info['oracle_jobs'] = {
+ "service_description" : "ORA %s Job",
+ "check_function" : check_oracle_jobs,
+ "inventory_function" : inventory_oracle_jobs,
+ "has_perfdata" : True,
+}