Module: check_mk
Branch: master
Commit: 7bf4cbe44c403ac55acf4b3f91981df8e37d919a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7bf4cbe44c403a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon May 6 10:51:49 2013 +0200
oracle_rman_backups: New check to monitor state of ORACLE RMAN backups
---
ChangeLog | 1 +
agents/plugins/mk_oracle | 13 ++++++++
checkman/oracle_rman_backups | 21 ++++++++++++
checks/oracle_rman_backups | 72 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 107 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 2d17310..e6c07e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -54,6 +54,7 @@
* 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
+ * oracle_rman_backups: New check to monitor state of ORACLE RMAN backups
* 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 ae35dea..98a3604 100755
--- a/agents/plugins/mk_oracle
+++ b/agents/plugins/mk_oracle
@@ -180,6 +180,19 @@ for SID in $SIDS; do
EOF
fi
+ if [ '$EXCLUDE' = '${EXCLUDE/rman_backups/}' ]; then
+ echo '<<<oracle_rman_backups>>>'
+ sqlplus "$SID" <<EOF
+ SELECT b.COMMAND_ID, a.STATUS,
+ to_char(a.START_TIME, 'YYYY-mm-dd_HH24:MI:SS') AS START_TIME,
+ to_char(a.END_TIME, 'YYYY-mm-dd_HH24:MI:SS') AS END_TIME,
b.INPUT_TYPE
+ FROM SYS.V_\\\$RMAN_BACKUP_JOB_DETAILS a,
+ (SELECT input_type, max(command_id) as command_id
+ FROM SYS.V_\\\$RMAN_BACKUP_JOB_DETAILS WHERE
STATUS<>'RUNNING' GROUP BY input_type) b
+ WHERE a.COMMAND_ID = b.COMMAND_ID;
+EOF
+ fi
+
if [ '$EXCLUDE' = '${EXCLUDE/tablespaces/}' ]; then
echo '<<<oracle_tablespaces>>>'
sqlplus "$SID" <<EOF | sed 's/READ
ONLY/READONLY/g'
diff --git a/checkman/oracle_rman_backups b/checkman/oracle_rman_backups
new file mode 100644
index 0000000..4c58d0a
--- /dev/null
+++ b/checkman/oracle_rman_backups
@@ -0,0 +1,21 @@
+title: Oracle RMAN Backups
+agents: linux
+author: Lars Michelsen <lm(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ This check monitors backup jobs configured with RMAN
+ (Recovery Manager) in ORACLE databases. It checks the state
+ of the last executed backup and outputs the execution times.
+
+ This check needs the Check_MK {mk_oracle}-plugin installed in
+ the agent. Please refer to the online documentation
+ for how to install that plugin.
+
+item:
+ The SID of the database (as appearing in the process
+ name of the pmon_... process) concatenated with the name
+ of the job separated by a single dot.
+
+inventory:
+ One separate check for each configured backup job will be created.
diff --git a/checks/oracle_rman_backups b/checks/oracle_rman_backups
new file mode 100644
index 0000000..e9f2fa5
--- /dev/null
+++ b/checks/oracle_rman_backups
@@ -0,0 +1,72 @@
+#!/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_rman_backups>>>
+# IODBSZ1 2013-04-08T16:33:53 COMPLETED 2013-04-08_16:33:54 2013-04-08_17:56:42 DB FULL
+# IODBSZ1 2013-04-23T15:28:26 RUNNING 2013-04-23_15:28:28 2013-04-23_15:31:02 ARCHIVELOG
+
+def inventory_oracle_rman_backups(info):
+ inventory = []
+ for line in info:
+ inventory.append(("%s.%s" % (line[0], " ".join(line[5:])),
{}))
+ return inventory
+
+def check_oracle_rman_backups(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 " ".join(line[5:]) == jobname:
+ data = line
+ break
+ if not data:
+ return (3, 'Unable to find the job')
+
+ state = 0
+ output = []
+
+ job_state = line[2]
+
+ txt = "State: %s" % job_state
+ if job_state not in [ "COMPLETED", "RUNNING" ]:
+ txt += " (!!)"
+ state = max(state, 2)
+ output.append(txt)
+
+ output.append("Start-Time: %s" % line[3])
+ if job_state != "RUNNING":
+ output.append("End-Time: %s" % line[4])
+
+ return (state, ", ".join(output))
+
+check_info['oracle_rman_backups'] = {
+ "service_description" : "ORA %s RMAN Backup",
+ "check_function" : check_oracle_rman_backups,
+ "inventory_function" : inventory_oracle_rman_backups,
+}