1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-11-24 11:23:47 +01:00

check_dataprotector added

This commit is contained in:
Páll Guðjón Sigurðsson 2010-03-01 22:09:31 +00:00
parent 36e96ec1d0
commit 7e0aef04d5
7 changed files with 206 additions and 0 deletions

View File

@ -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)

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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