From 7e0aef04d5397b6e78cb6ae0b7037c87cbdf8287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Gu=C3=B0j=C3=B3n=20Sigur=C3=B0sson?= Date: Mon, 1 Mar 2010 22:09:31 +0000 Subject: [PATCH] check_dataprotector added --- check_dataprotector/trunk/check_dp_backups | 78 +++++++++++++++++++ check_dataprotector/trunk/check_dp_idb | 17 ++++ .../trunk/check_dp_mountrequest | 24 ++++++ check_dataprotector/trunk/check_dp_pool | 40 ++++++++++ check_dataprotector/trunk/check_dp_services | 12 +++ check_dataprotector/trunk/check_dp_tablespace | 28 +++++++ .../trunk/nrpe_local/dataprotector.cfg | 7 ++ 7 files changed, 206 insertions(+) create mode 100755 check_dataprotector/trunk/check_dp_backups create mode 100755 check_dataprotector/trunk/check_dp_idb create mode 100755 check_dataprotector/trunk/check_dp_mountrequest create mode 100755 check_dataprotector/trunk/check_dp_pool create mode 100755 check_dataprotector/trunk/check_dp_services create mode 100755 check_dataprotector/trunk/check_dp_tablespace create mode 100644 check_dataprotector/trunk/nrpe_local/dataprotector.cfg diff --git a/check_dataprotector/trunk/check_dp_backups b/check_dataprotector/trunk/check_dp_backups new file mode 100755 index 0000000..5d3b399 --- /dev/null +++ b/check_dataprotector/trunk/check_dp_backups @@ -0,0 +1,78 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import subprocess +import datetime +import sys +now = datetime.datetime.now() + + +# return code 3 = No sessions matching the search criteria were found. +omnistat_returncode_no_sessions_found=3 +class GenericObject: + def __init__(self): + self.dict = {} + +def runCommand(command): + proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE,) + stdout, stderr = proc.communicate('through stdin to stdout') + if proc.returncode > 0 and proc.returncode != omnistat_returncode_no_sessions_found: + print "Error running '%s' command:\n %s" % (command, stderr) + print proc.returncode + print stderr, stdout + sys.exit(1) + else: + return stdout + +def getSessions(): + sessions = [] + date = "%s/%s/%s" % ( now.year, now.month, now.day ) + output = runCommand( '/opt/omni/bin/omnistat -previous -since %s' % date ) + for line in output.split('\n')[1:]: + tmp = line.split() + if len(tmp) < 4: continue + sessionID = tmp[0] + sessions.append( sessionID ) + #print sessionID + return sessions + +def parseSessions(session_list): + parsedSessions = [] + for sessionID in session_list: + output = runCommand('/opt/omni/bin/omnidb -rpt %s -detail' % sessionID ) + session = GenericObject() + parsedSessions.append ( session ) + for line in output.split('\n'): + tmp = line.split(':') + if len(tmp) != 2: continue + key,value = tmp + key = key.strip() + value = value.strip() + session.dict[key] = value + return parsedSessions + +sessions = getSessions() +parsedSessions = parseSessions( sessions ) + + +total_errors = 0 +total_warnings = 0 +total_size = 0 +total_sessions = 0 +for session in parsedSessions: + errors = int( session.dict['Number of errors'] ) + warnings = int( session.dict['Number of warnings'] ) + try: + size = 1024 * int( session.dict['Session size'].split()[0] ) + except: + size = 0 + total_errors = total_errors + errors + total_warnings = total_warnings + warnings + total_size = total_size + size + total_sessions += 1 + +print "Everything is ok | errors=%d warnings=%d size=%dB num_sessions=%dc" % (total_errors,total_warnings,total_size,total_sessions) + + + + diff --git a/check_dataprotector/trunk/check_dp_idb b/check_dataprotector/trunk/check_dp_idb new file mode 100755 index 0000000..a283426 --- /dev/null +++ b/check_dataprotector/trunk/check_dp_idb @@ -0,0 +1,17 @@ +#!/bin/sh + +WARNING=5 +CRITICAL=2 + + +/opt/omni/bin/omnirpt -tab -report obj_lastbackup -days -$WARNING | grep -w IDB > /dev/null +RESULT=$? + + +if [ $RESULT -gt 0 ]; then + echo "Warning, Last Dataprotector backup is more than $WARNING days old" + exit 1 +fi + +echo "Last Dataprotector backup is less than $WARNING days old" + diff --git a/check_dataprotector/trunk/check_dp_mountrequest b/check_dataprotector/trunk/check_dp_mountrequest new file mode 100755 index 0000000..f6c73ce --- /dev/null +++ b/check_dataprotector/trunk/check_dp_mountrequest @@ -0,0 +1,24 @@ +#!/bin/sh + + +OUTPUT=$(/opt/omni/bin/omnistat) +RESULT=$? + +echo $OUTPUT | grep -q "No currently running sessions." +RESULT=$? + +if [ $RESULT -eq 0 ]; then + echo "OK - No running sessions" + exit 0 +fi + +echo $OUTPUT | grep -q "Mount Request" +RESULT=$? + +if [ $RESULT -eq 0 ]; then + echo "Warning, Dataprotector has mount requests" + exit 1 +fi + +echo -n $OUTPUT +exit 0 diff --git a/check_dataprotector/trunk/check_dp_pool b/check_dataprotector/trunk/check_dp_pool new file mode 100755 index 0000000..4bc35bb --- /dev/null +++ b/check_dataprotector/trunk/check_dp_pool @@ -0,0 +1,40 @@ +#!/bin/sh + +POOL="$1" +WARNING=5 +CRITICAL=2 + +if [ "$POOL" = "" ]; then + echo "Unknown - No Media pool specified" + exit 3 +fi + +OUTPUT=$(/opt/omni/bin/omnimm -list_pool "$POOL") +RESULT=$? + +if [ $RESULT -eq 3 ]; then + echo "Unknown - Media pool '$POOL' was not found" + exit 3 +fi + +if [ $RESULT -ne 0 ]; then + echo "Unknown - exit code from omnimm=$RESULT, output: $OUTPUT" + exit 3 +fi + +FREE_MEDIA=$(echo "$OUTPUT" | tail -n +4 | wc -l) + +PERFDATA="'$POOL'=$FREE_MEDIA" + +if [ $FREE_MEDIA -lt $CRITICAL ]; then + echo "Critical: $FREE_MEDIA available media in pool $POOL | $PERFDATA" + exit 2 +fi + +if [ $FREE_MEDIA -lt $WARNING ]; then + echo "Warning: $FREE_MEDIA available media in pool $POOL | $PERFDATA" + exit 1 +fi + +echo "OK: $FREE_MEDIA available media in pool $POOL | $PERFDATA" +exit 0 diff --git a/check_dataprotector/trunk/check_dp_services b/check_dataprotector/trunk/check_dp_services new file mode 100755 index 0000000..95edef9 --- /dev/null +++ b/check_dataprotector/trunk/check_dp_services @@ -0,0 +1,12 @@ +#!/bin/sh + +/opt/omni/sbin/omnisv -status | grep "Status: All Data Protector relevant processes/services up and running." + +RESULT=$? + +if [ $RESULT -gt 0 ]; then + echo "Critical, some Data Protector services are in stopped state" + exit 1 +fi + + diff --git a/check_dataprotector/trunk/check_dp_tablespace b/check_dataprotector/trunk/check_dp_tablespace new file mode 100755 index 0000000..b5b0fd7 --- /dev/null +++ b/check_dataprotector/trunk/check_dp_tablespace @@ -0,0 +1,28 @@ +#!/bin/sh + + +#/opt/omni/bin/omnirpt -report db_size + +echo $USER > /tmp/check_dp_tablespace.debug +echo $@ >> /tmp/check_dp_tablespace.debug + + +OUTPUT=$(/opt/omni/bin/omnirpt -report db_size) +RESULT=$? + +if [ $RESULT -gt 0 ]; then + echo -n $OUTPUT + exit 1 +fi +echo $OUTPUT | grep -q "No database devices with low disk space." + +RESULT=$? + +if [ $RESULT -gt 0 ]; then + echo "Warning - Some dataprotector tablespaces are running low" + exit 1 +else + echo "OK - No database devices with low disk space." + exit 0 +fi + diff --git a/check_dataprotector/trunk/nrpe_local/dataprotector.cfg b/check_dataprotector/trunk/nrpe_local/dataprotector.cfg new file mode 100644 index 0000000..b227e9a --- /dev/null +++ b/check_dataprotector/trunk/nrpe_local/dataprotector.cfg @@ -0,0 +1,7 @@ + + +command[check_dp_pool]=/usr/lib/nagios/plugins/contrib/check_dp_pool "free" +command[check_dp_tablespace]=/usr/lib/nagios/plugins/contrib/check_dp_tablespace +command[check_dp_services]=/usr/lib/nagios/plugins/contrib/check_dp_services +command[check_dp_mountrequest]=/usr/lib/nagios/plugins/contrib/check_dp_mountrequest +command[check_dp_idb]=/usr/lib/nagios/plugins/contrib/check_dp_idb