Skip to content

Monitor MaxDB data volume usage

While I was configuring some monitoring on our SAP servers, I was looking for a way to do some automated volume usage checks. It turns out there's no real command provided to do so. However, a system table stores all related information about the configured data (and log) volumes. This command will provide the necessary information to monitor data volume usage on a MaxDB database. Be sure to replace 'XX' with a numeric treshold value (e.g. 90 will print volumes that have at least used 90% of a volume disk):

dbmcli -u username,password -d database \
"sql_execute SELECT PATH,USEDSIZEPERCENTAGE from SYSINFO.DATAVOLUMES 
WHERE MODE='NORMAL' and USEDSIZEPERCENTAGE>=XX"

I've created a Nagios script that will check if the average volume usage is higher than a given treshold:

#!/bin/bash
# checks the average volume usage in MaxDB
# output optimized for nagios

if [ $# -ne 1 ] ; then
	echo "Usage: $0 "
	exit 1
fi

maxVolUsage=$1
volUsage=$(/opt/sdb/programs/bin/dbmcli -u control,ND1_sap01 -d ND1 
sql_execute "select sum(USEDSIZEPERCENTAGE)/count(PATH) 
from SYSINFO.DATAVOLUMES WHERE MODE='NORMAL'" | tail +3)
roundVolUsage="$(echo $volUsage | sed 's/\.[0-9][0-9]*//g')"

if [ $roundVolUsage -ge $maxVolUsage ] ; then
	echo "CRITICAL: Average volume usage: $roundVolUsage%"
        exit 2
else
	echo "OK: Average volume usage: $roundVolUsage%"
        exit 0
fi
exit 0