#############################################################################
##
## iMS monitoring and alarm script
##
## This script is part an example framework of what can be done.
## There are MANY ways that you can take this from here.
##
## File: $RCSfile: alarms.cfg,v $
##       This is the main configuration file for setting global variables
## 	 which other support scripts will use.
##
## 	 This config file defines the alarm thresholds and
## 	 notification addresses for monitoring alerts.
##
## While this package is provided AS-IS and unsupported, we would appreciate
## your comments, feedback and bug-reports at:
##
##      mailtools-feedback @Sign sun.com
##
#############################################################################

## version of this package
DATA_VERSION=6.0

## set the serverroot if it hasn't already been set on the command line
## of the calling script. 
##
if [ -z "$serverroot" ]; then
    ## NOTE: Sites can hard code the location of the serverroot instead 
    ## of doing the other tests shown below
    if [ ! -f "$_CURR_WDIR_/../etc/firstrun.cfg" ]; then
           serverroot=`pkginfo -r SUNWmsgco 2>/dev/null`
           if [ $? -ne 0 ] ; then 
                echo "please supply the serverroot"
                exit 13
           else
                echo serverroot=$serverroot > $_CURR_WDIR/../etc/firstrun.cfg
                echo export serverroot >> $_CURR_WDIR/../etc/firstrun.cfg
           fi
    fi

    . $_CURR_WDIR/../etc/firstrun.cfg

fi

##
## Common commands: imsimta, immonitor-access, mboxutil etc
##
MSG_CONF_FILE=$serverroot/config/msg.conf
LOCAL_CONF_FILE=$serverroot/config/local.conf
##
##             These command paths should be adjusted
##
MBOXLIST_PATH=$serverroot/data/store/mboxlist
LDAPSEARCH=$serverroot/lib/ldapsearch
IMSIMTA=$serverroot/sbin/imsimta
TAILOR_FILE=`grep local.imta.imta_tailor $MSG_CONF_FILE|cut -d" " -f3-'`
MBOXUTIL=$serverroot/sbin/mboxutil
IMMONITOR_ACCESS=$serverroot/sbin/immonitor-access
##
##

export IMSIMTA MBOXUTIL MBOXLIST_PATH IMMONITOR_ACCESS

## Domain name of site
domain=`grep local.defdomain $MSG_CONF_FILE|cut -d" " -f3-'`

## alarmmessage sender
alarmsender=postmaster@$domain

## comma seperated list of e-mail addresses that
## receive alert messages when active mail
## queue size exceeds the 'queuelimit' number
queuenotifyaddress=postmaster@$domain

## comma seperated list of e-mail addresses that
## receive alert messages when the systest script
## detects a problem on the the mail system
systestnotifyaddress=postmaster@$domain

## comma separated list of nightly report recipients
reportrcpts=isp-stats@Eng.Sun.COM,postmaster@$domain

## comma separated list of independent smarthost machines. These machines
## are to serve as relay nodes for reporting on problems with mail. Since
## we are monitoring the mail system, if there is any trouble with it, the 
## last thing we want to do is to send messages through that system.
## By default not set. Please set this value to something reasonable
## ROUTER=<local.servername>
 
## Instance name of installation
if [ -z "$instancename" ]; then
    instancename=msg-config
fi

## Set the reporting style
. $_CURR_WDIR/../plugins/report_formats.cfg
if [ "$report_style" = "" ]; then
    report_style=bigbrother
    BBHOME=/opt/brother/client    # define the location of bb
    if [ -f "$BBHOME/etc/bbaliasname" ]; then
       MACHINEDOTS=`cat $BBHOME/etc/bbaliasname`
    fi
    export BBHOME report_style
fi

## Default sender of test messages
sender=Health.Monitor.Probe@$domain

## Instance root of installation
instanceroot=$serverroot/$instancename

## set of messaging server disks to monitor
messaging_disks="$serverroot/log $serverroot/" # set of disks to monitor

## TMP directory from where most scripts dump temp files 
HEALTHMON_TMPDIR=$serverroot/log

## Directory where the reports are logged
if [ -z "$reportlogdir" ] ; then
   reportlogdir=$serverroot/log/healthmon.reports
   mkdir -p $reportlogdir
fi

## Directory where the web reports are logged
if [ -z "$webreportlogdir" ] ; then
   webreportlogdir=$serverroot/log/healthmon.webreports
   mkdir -p $webreportlogdir
fi

## Script used to rotate the logs
rotatelog=$_CURR_WDIR/../lib/rotatelogs

## nickname for this machine - this is the primary name for 
## the machine, or the clustwer alias. 
## Use the fully qualified domain name in DOTTED format
if [ -z "$MACHINEDOTS" ]; then
   MACHINEDOTS=`grep local.servername $MSG_CONF_FILE|cut -d" " -f3-`
fi

## fully qualified domain name of this machine in CSV format
MACHINE="`echo $MACHINEDOTS |sed -e 's/\./,/g'`"

## number of messages in the queue before an alarm message is sent out
queuewarnlimit=1000
queuepaniclimit=2000
queueheldwarnlimit=0

## Table of queue specific thresholds. Used to override
## the default values of queuewarnlimit/queuepaniclimit on a per channel basis
qmtab=$_CURR_WDIR/../etc/qmtab.cfg

## list of processes for which a warning should be issued if they aren't around.
## separate individual processes with a space.
imtaprocs="popd imsched"

## Processes which are REQURED to exist for iMS to function properly.
imtapageproc="job_controller stored imapd mshttpd"

## Common password for all test users
secret=test1234

## Default test user
TEST_USER=usr10500

##
## Platform specific command definitions. 
## Hmmmm...** Should be a separate file :-) **
## 
platform=`uname -s`
case $platform in
  SunOS )
    AWK=nawk
    CAT="/bin/cat"
    CKSUM="/bin/cksum"
    GREP="/bin/grep"
    EGREP="/usr/xpg4/bin/egrep"
    SED="/usr/bin/sed"
    ;;
  * )
    AWK=gawk
    CAT="/bin/cat"
    CKSUM="/usr/bin/cksum"
    GREP="/bin/grep"
    EGREP="/bin/egrep"
    ;;
esac

##
## Now export those variables
##

export domain alarmsender queuenotifyaddress systestnotifyaddress 
export reportrcpts secret sender instanceroot messaging_disks
export webreportlogdir reportlogdir rotatelog
export MACHINE MACHINEDOTS HEALTHMON_TMPDIR
export queuewarnlimit queueheldwarnlimit queuepaniclimit qmtab 
export imtaprocs imtapageproc ROUTER serverroot instancename 
export HEALTHMON_TMPDIR AWK GREP CAT EGREP CKSUM

addpath=${serverroot}/sbin:${serverroot}/bin/msg/imta/lib:${serverroot}/bin/msg/lib

addlib=${serverroot}/shared/lib:${serverroot}/lib:${serverroot}/bin/msg/lib

LD_LIBRARY_PATH=${addlib}:${LD_LIBRARY_PATH}

PATH=$PATH:${addpath}
export LD_LIBRARY_PATH PATH
