Sunday, January 15, 2012

WebSphere Business Monitor 7 - Archive Monitor Module Instance Data

After a long time running, the instance data in a monitor module may reach thousands of records. It will take a lot of Database server disk space and will also downgrade the query performance. The following UNIX shell script shows how to archive the instance data with retention period of 3 month:

IBM provide a jython script in the directory  /IBM/WebSphere/MonServer/scripts.wbm/instances to use for archive the data, refering to the following URL for the script usage:

http://publib.boulder.ibm.com/infocenter/dmndhelp/v7r0mx/topic/com.ibm.btools.help.monitor.ref.doc/ref/instdata_archive_script.html

#!/usr/bin/ksh

classDir=/IBM/WebSphere/MonServer/plugins                    
wsadminDir=/IBM/wbmProfiles/WBMProd01/bin
scriptDir=/IBM/WebSphere/MonServer/scripts.wbm/instances
archiveDir=/IBM/delta
currentMonth=`date +%m`
currentYear=`date +%Y`
currentDate=`date +%d`

pre3Month=`expr $currentMonth - 3`

if [ "$pre3Month" -le "0" ]; then
   pre3Month=`expr $pre3Month + 12`
   currentYear=`expr $currentYear - 1`
fi


#acquire the date 3 month ago
previousDate=$currentYear-$pre3Month-$currentDate

#define a startTime, The date is better before the monitor module version date.
startTime="2011-8-1T00:00:00"
endTime="$previousDate"T00:00:00
classPath=$classDir/com.ibm.wbimonitor.lifecycle.spi.jar:$classDir/com.ibm.wbimonitor.archive.jar

echo "Achive the instance for monitor model MO_Monitoring"

$wsadminDir/wsadmin.sh -wsadmin_classpath $classPath -lang jython -f $scriptDir/instanceArchive.jy MO_Monitoring 2011-08-10T13:00:33 $archiveDir $startTime $endTime

echo "Done"

No comments:

Post a Comment