Thursday, April 5, 2012

Custom scripts to monitor Siebel using OMS user defined metrics

In this post, I describe how to create user defined metrics in hosts.
The following scripts will raise alerts, whenever something's wrong.

IBM HTTP Server:
#!/bin/sh
PS=`ps -ef|grep "HTTPServer -k start"|grep -v grep|wc -l`

echo em_result=$PS
if test $PS -lt 4
then
echo em_message='Apache is down. Processes='$PS
else
echo em_message='Apache is up. Processes='$PS
fi

Oracle BI Publisher:
#!/bin/sh
PS=`ps -ef|grep oc4j_bi|grep java|grep -v grep|wc -l`

echo em_result=$PS
if test $PS -ne 1
then
echo em_message='BI Publisher is down. Processes='$PS
else
echo em_message='BI Publisher is up. Processes='$PS
fi

Gateway Server:
#!/bin/sh
PS=`ps -ef|grep gtwyns|grep -v grep|wc -l`

echo em_result=$PS
if test $PS -ne 1
then
echo em_message='Gateway is down. Processes='$PS
else
echo em_message='Gateway is up. Processes='$PS
fi

Siebel Server:
server.cfg:
spool server.lst
list server show SBLSRVR_NAME,HOST_NAME,SBLSRVR_STATE,START_TIME,END_TIME
exit

Main script [Insert your env. variables' values]:
export SIEBEL_HOME=
export SIEBGATE=
export SIEBENT=
export SADMINPWD=
export WORKDIR=
export HOST_NAME=

. $SIEBEL_HOME/siebenv.sh

cd $WORKDIR

cat /dev/null>server.lst

srvrmgr /g $SIEBGATE /e $SIEBENT /u sadmin /p $SADMINPWD /s $HOST_NAME /i server.cfg 1>/dev/null

GREP=`grep Running server.lst |wc -l`
echo em_result=$GREP

if test $GREP -lt 1
    then
                echo em_message='Siebel Server is down.'
        else
                echo em_message='Siebel Server is up.'
fi

Siebel Components:
comp.cfg:
spool comp.lst
list comp show SV_NAME,CC_ALIAS,CC_NAME,CP_DISP_RUN_STATE,CP_START_TIME,CP_END_TIME
exit

Main script [Insert your env. variables' values]:

export SIEBEL_HOME=
export SIEBGATE=
export SIEBENT=
export SADMINPWD=
export WORKDIR=
export HOST_NAME=

. $SIEBEL_HOME/siebenv.sh

cd $WORKDIR

cat /dev/null>comp.lst

srvrmgr /g $SIEBGATE /e $SIEBENT /u sadmin /p $SADMINPWD /s $HOST_NAME /i comp.cfg 1>/dev/null

GREP=`egrep '(Unavailable|Shutdown)' comp.lst |wc -l`
echo em_result=$GREP

if test $GREP -gt 0
    then
                echo em_message=$GREP' Components down.'
        else
                echo em_message='Components are OK.'
fi

You may use OMS 11g preinstalled Siebel plugin, instead, although I haven't seen anything about components' status. You only get informed, if gateway or Siebel servers are up or down.
If you choose to use this plugin, make sure agent's OS user has the same primary group as Siebel's OS user. Oracle had to open Bug 13849748 for me, until I discovered that this was needed, since it is not mentioned in any documentation.
Also agent messes with /tmp/regss* files, taking their ownership and crashing, sometimes, the gateway server. Remove "${MWHOME}/bin/regautobackup -off" from your siebenv.sh files to correct this.