informix-monitor.sh script
#!/bin/sh -f
#==================================================================================================
# This sample script can be used with the KM to set-up monitoring of Informix database
# The script utilizes the vendor's tool onstat to collect monitoring data on the relevant database.
# Script execution by the KM is done with 2 command line arguments:
# 1. file to source before calling onstat
# 2. type of data to pull from onstat output. the value here supports one of the following values:
# dskreads,isamtot,gp_read,ovlock,bufwaits,ixda-RA,status
# This example shows how a vendor tool reporting multi line output with multiple monitoring objects
# (each one has it's own set of parameters) can be used by this KM.
# Notice how 2nd argument for the script configure it to report on a different set of parameters.
# When used with 2nd argument 'status' then a monitor type is created for monitoring the server's
# running level, where 0 means the server is fully active and anything greater would mean server is
# in a different state.
#==================================================================================================
#
if [ $# != 2 ]; then
exit -1
fi
if [ -f $1 ]; then
. $1
fi
BASENAME=$0
function dskreads_processing
{
echo $* >> /tmp/informix-monitor.debug
if [ $# -gt 16 ]; then
dskreads_delta=`echo ${9} - ${17} | bc`
echo dskreads_delta=${dskreads_delta} >> /tmp/informix-monitor.debug
pagreads_delta=`echo ${10} - ${18} | bc`
bufreads_delta=`echo ${11} - ${19} | bc`
dskwrits_delta=`echo ${13} - ${21} | bc`
pagwrits_delta=`echo ${14} - ${22} | bc`
bufwrits_delta=`echo ${15} - ${23} | bc`
echo bufwrits_delta=${bufwrits_delta} >> /tmp/informix-monitor.debug
echo "InformixDskReads=${INFORMIXSERVER}_(DskReads),\
${1}=${dskreads_delta},\
${2}=${pagreads_delta},\
${3}=${bufreads_delta},\
${4}_reads=${12},\
${5}=${dskwrits_delta},\
${6}=${pagwrits_delta},\
${7}=${bufwrits_delta},\
${8}_writes=${16}"
fi
echo "${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16}" > $BASENAME.dskreads
}
function isamtot_processing
{
echo "InformixIsamTotal=${INFORMIXSERVER}_(IsamTotal),${1}=${10},${2}=${11},${3}=${12},${4}=${13},${5}=${14},${6}=${15},${7}=${16},${8}=${17}"
}
function gp_read_processing
{
echo "InformixGPRead=${INFORMIXSERVER}_(GPRead),${1}=${8},${2}=${9},${3}=${10},${4}=${11},${5}=${12},${6}=${13},${7}=${14}"
}
function ovlock_processing
{
echo "InformixOVLock=${INFORMIXSERVER}_(OVLock),${1}=${8},${2}=${9},${3}=${10},${4}=${11},${5}=${12},${6}=${13},${7}=${14}"
}
function bufwaits_processing
{
echo "InformixBufWaits=${INFORMIXSERVER}_(BufWaits),${1}=${9},${2}=${10},${3}=${11},${4}=${12},${5}=${13},${6}=${14},${7}=${15},${8}=${16}"
}
function ixdaRA_processing
{
echo "InformixIXDARA=${INFORMIXSERVER}_(IXDARA),${1}=${6},${2}=${7},${3}=${8},${4}=${9},${5}=${10}"
}
function dbstatus_processing
{
STATUS=`echo $* | sed 's/ -- /,/g' | cut -d, -f2`
case $STATUS in
"On-Line" )
echo "InformixServer=${INFORMIXSERVER},Status=0"
;;
"Quiescent" )
echo "InformixServer=${INFORMIXSERVER},Status=1"
;;
"Single-User" )
echo "InformixServer=${INFORMIXSERVER},Status=2"
;;
* )
echo "InformixServer=${INFORMIXSERVER},Status=3"
esac
}
for rawLine in $(onstat -p | grep -v "^Profile" | sed 's/^$/+/' | tr '\n' '\t' | tr '+' '\n' | sed -e 's/\t/ /g' -e 's/ /~/g' | tr -s '~')
do
token=`echo $rawLine | cut -d '~' -f 2`
if [ "$token" = "memory" -o "$token" = "IBM" ]; then
token="status"
fi
if [ "$token" = "$2" ]; then
line=`echo $rawLine | sed -e 's/~/ /g' -e 's/\%//g'`
case $token in
"status" )
dbstatus_processing $line
;;
"dskreads" )
if [ -f $BASENAME.dskreads ]; then
dskreads_processing $line `cat $BASENAME.dskreads`
else
dskreads_processing $line
fi
;;
"isamtot" )
isamtot_processing $line
;;
"gp_read" )
gp_read_processing $line
;;
"ovlock" )
ovlock_processing $line
;;
"bufwaits" )
bufwaits_processing $line
;;
"ixda-RA" )
ixdaRA_processing $line
;;
* )
echo "Unknown line" > /dev/null
esac
fi
done
#==================================================================================================
# This sample script can be used with the KM to set-up monitoring of Informix database
# The script utilizes the vendor's tool onstat to collect monitoring data on the relevant database.
# Script execution by the KM is done with 2 command line arguments:
# 1. file to source before calling onstat
# 2. type of data to pull from onstat output. the value here supports one of the following values:
# dskreads,isamtot,gp_read,ovlock,bufwaits,ixda-RA,status
# This example shows how a vendor tool reporting multi line output with multiple monitoring objects
# (each one has it's own set of parameters) can be used by this KM.
# Notice how 2nd argument for the script configure it to report on a different set of parameters.
# When used with 2nd argument 'status' then a monitor type is created for monitoring the server's
# running level, where 0 means the server is fully active and anything greater would mean server is
# in a different state.
#==================================================================================================
#
if [ $# != 2 ]; then
exit -1
fi
if [ -f $1 ]; then
. $1
fi
BASENAME=$0
function dskreads_processing
{
echo $* >> /tmp/informix-monitor.debug
if [ $# -gt 16 ]; then
dskreads_delta=`echo ${9} - ${17} | bc`
echo dskreads_delta=${dskreads_delta} >> /tmp/informix-monitor.debug
pagreads_delta=`echo ${10} - ${18} | bc`
bufreads_delta=`echo ${11} - ${19} | bc`
dskwrits_delta=`echo ${13} - ${21} | bc`
pagwrits_delta=`echo ${14} - ${22} | bc`
bufwrits_delta=`echo ${15} - ${23} | bc`
echo bufwrits_delta=${bufwrits_delta} >> /tmp/informix-monitor.debug
echo "InformixDskReads=${INFORMIXSERVER}_(DskReads),\
${1}=${dskreads_delta},\
${2}=${pagreads_delta},\
${3}=${bufreads_delta},\
${4}_reads=${12},\
${5}=${dskwrits_delta},\
${6}=${pagwrits_delta},\
${7}=${bufwrits_delta},\
${8}_writes=${16}"
fi
echo "${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16}" > $BASENAME.dskreads
}
function isamtot_processing
{
echo "InformixIsamTotal=${INFORMIXSERVER}_(IsamTotal),${1}=${10},${2}=${11},${3}=${12},${4}=${13},${5}=${14},${6}=${15},${7}=${16},${8}=${17}"
}
function gp_read_processing
{
echo "InformixGPRead=${INFORMIXSERVER}_(GPRead),${1}=${8},${2}=${9},${3}=${10},${4}=${11},${5}=${12},${6}=${13},${7}=${14}"
}
function ovlock_processing
{
echo "InformixOVLock=${INFORMIXSERVER}_(OVLock),${1}=${8},${2}=${9},${3}=${10},${4}=${11},${5}=${12},${6}=${13},${7}=${14}"
}
function bufwaits_processing
{
echo "InformixBufWaits=${INFORMIXSERVER}_(BufWaits),${1}=${9},${2}=${10},${3}=${11},${4}=${12},${5}=${13},${6}=${14},${7}=${15},${8}=${16}"
}
function ixdaRA_processing
{
echo "InformixIXDARA=${INFORMIXSERVER}_(IXDARA),${1}=${6},${2}=${7},${3}=${8},${4}=${9},${5}=${10}"
}
function dbstatus_processing
{
STATUS=`echo $* | sed 's/ -- /,/g' | cut -d, -f2`
case $STATUS in
"On-Line" )
echo "InformixServer=${INFORMIXSERVER},Status=0"
;;
"Quiescent" )
echo "InformixServer=${INFORMIXSERVER},Status=1"
;;
"Single-User" )
echo "InformixServer=${INFORMIXSERVER},Status=2"
;;
* )
echo "InformixServer=${INFORMIXSERVER},Status=3"
esac
}
for rawLine in $(onstat -p | grep -v "^Profile" | sed 's/^$/+/' | tr '\n' '\t' | tr '+' '\n' | sed -e 's/\t/ /g' -e 's/ /~/g' | tr -s '~')
do
token=`echo $rawLine | cut -d '~' -f 2`
if [ "$token" = "memory" -o "$token" = "IBM" ]; then
token="status"
fi
if [ "$token" = "$2" ]; then
line=`echo $rawLine | sed -e 's/~/ /g' -e 's/\%//g'`
case $token in
"status" )
dbstatus_processing $line
;;
"dskreads" )
if [ -f $BASENAME.dskreads ]; then
dskreads_processing $line `cat $BASENAME.dskreads`
else
dskreads_processing $line
fi
;;
"isamtot" )
isamtot_processing $line
;;
"gp_read" )
gp_read_processing $line
;;
"ovlock" )
ovlock_processing $line
;;
"bufwaits" )
bufwaits_processing $line
;;
"ixda-RA" )
ixdaRA_processing $line
;;
* )
echo "Unknown line" > /dev/null
esac
fi
done
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*