Personal tools
You are here: Home → DB2 → Scripts DB2 → Nagios Plugins to monitor DB2 events → Checking tablespace utilization
Navigation
Log in


Forgot your password?
 
Document Actions

Checking tablespace utilization

by Felipe Alkain de Souza — last modified 2010-08-06 17:56

This script checks DB2 tablespace utilization

What
When 2010-08-06
from 17:56 to 17:56
Add event to calendar vCal
iCal

#!/usr/bin/ksh
############################################################################
# Author: Felipe Alkain de Souza
#
# Script Name: check_tablespace_size.sh
#
# Functionality: This script checks DB2 tablespace utilization
#
# Usage: ./check_tablespace_size.sh <db_name> <tablespace_name>
#
############################################################################

. $HOME/sqllib/db2profile

STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2

db2 connect to $1 > /dev/null


if [ $? -ne 0 ] ; then
        echo " The database did not connect, or the database name is wrong"
        exit 3
fi

tbs_size=`db2 connect to $1 >/dev/null 2>&1; db2 "select (SUBSTR(CHAR(DECIMAL(USED_PAGES, 10, 2)/ \
DECIMAL(TOTAL_PAGES,10,2)*100),9,5)) as PERCENT_USED \
from table (snapshot_tbs_cfg('$1', 0)) as t \
where TABLESPACE_NAME='$2'" |grep ^[0-9]`

int_tbs_size=`echo $tbs_size |cut -d"." -f 1`

if [ $int_tbs_size -gt 95 ]; then
   echo "$STATE_CRITICAL&DB2 - TableSpace $2 with [ $int_tbs_size% ] Hit Threshold"
    exit $STATE_CRITICAL
elif [ $int_tbs_size -gt 90 -a $int_tbs_size -lt 95 ] ; then
   echo "$STATE_WARNING&DB2 - TableSpace $2 with [ $int_tbs_size% ] Hit Threshold"
    exit $STATE_WARNING
else
    echo "$STATE_OK&DB2 - TableSpace $2 OK"
   exit $STATE_OK
fi

Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls