#!/bin/ksh
# Script to record and monitor all appserver brokers on
# a system
#
# Usage
# -----
# $0
#
# Possible Extentions & Limitations:
# 1. Monitor other "progress" related metrics
# 2.
#
#
#
# Modification History
# --------------------
# [1] June 08 2009 pao:
# Created script
#
# [2] Jun 09 2009 pao:
# This is tailored to read in from a file the Adminserver port and a list of appservers to monitor
#
# [3] Apr 04 2012 mcp:
# Changed to accept DLC as value
#
# LIMITATIONS/DEPENDENCIES
# ------------------------
# [1] June 09 2009 pao:
# Monitoring for avery is quick-coded, depends on having a properly formatted file called
# "appservers-to-monitor" in pwd
##################################################
#useage message
if [ $# -eq 0 ]; then
echo -e "
Usage:
monitor-brokers
e.g.
nohup ./monitor-brokers test1 20 100 &
will monitor all appserver brokers on the system 100 samples at 20 second intervals.
NOTE
----
Use \"nohup\" before command
Execute in background with \" &\"
This is to allow shell to continue execution if connection is broken
"
exit
fi
hostname=`hostname` #Get hostname to place in output files
#variable assignments and calculations
prefix=$1"."$hostname
no_samples=$3
sleeptime=$2
totaltime=`echo "$no_samples*$sleeptime" | bc`
DLC=$4 #MCP
ENV=$5 #MCP
ASFILE=./appservers-to-monitor-$ENV
#create output filenames & remove if they already exits
brokerfile=$prefix".appservers"
if [ -f $brokerfile ]; then rm $brokerfile; fi
#Get Adminserver port and list of appservers to monitor from
#hardcoded file
port=$(head -1 $ASFILE)
noaps=$(wc -l $ASFILE | awk '{lines=$1-1}END{print lines}')
aps=$(tail -$noaps $ASFILE)
#set variables
time=0
asbman=$(echo "$DLC/bin/asbman")
#Loop for monitoring period
while (( $time<=$totaltime )); do
t1=$(date +%s)
for i in $aps; do
date >> $brokerfile;
$asbman -i $i -q -port $port >> $brokerfile; done
t2=$(date +%s)
sleep $sleeptime
time=$(echo "$sleeptime + $time + $t2 -$t1" | bc -l);
done