Friday 11 March 2011

Continually gathering stats in WebSphere

I sometimes work with IBM's WebSphere Application server, and there is times I need to see what it is doing. In most of the places I have worked in, there is usually a set of monitoring tools. In some cases, there are no tools, and I will need to gather the statistics yourself.

For those circumstances on UNIX, I can point you to Michael Milani's page on "Gathering PMI Data from WAS using wsadmin Scripting".

For the same solution on Windows, you may want to use this wrapper script (can be named anything.bat):


echo Off

FOR /f "tokens=1-8 delims=:/-,. " %%i in ('echo exit^|cmd /q /k"prompt $D $T"') do (
  For /f "tokens=2-4 delims=/-,() skip=1" %%a in ('echo.^|date') do (
    set dow=%%i
    set %%a=%%j
    set %%b=%%k
    set %%c=%%l
    set hh=%%m
    set min=%%n
    set ss=%%o
    set cs=%%p
  )
)

SET DATESTAMP=%yy%%mm%%dd%
SET TIMESTAMP=%hh%%min%%ss%

SET OUTFILE=collectstats_%DATESTAMP%%TIMESTAMP%.log
echo "Script started at:"
date /t
time /t

:TOP
FOR /f "tokens=1-8 delims=:/-,. " %%i in ('echo exit^|cmd /q /k"prompt $D $T"') do (
  For /f "tokens=2-4 delims=/-,() skip=1" %%a in ('echo.^|date') do (
    set dow=%%i
    set %%a=%%j
    set %%b=%%k
    set %%c=%%l
    set hh=%%m
    set min=%%n
    set ss=%%o
    set cs=%%p
  )
)

SET DATESTAMP=%yy%%mm%%dd%
SET TIMESTAMP=%hh%%min%%ss%

echo %DATESTAMP%-%TIMESTAMP% >> %OUTFILE%
echo ------------------------------------------------- >> %OUTFILE%
call C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin\wsadmin.bat -lang jacl -f PmiInfo.jacl machine01 jvm >> %OUTFILE%
call C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin\wsadmin.bat -lang jacl -f PmiInfo.jacl machine01 threadpool >> %OUTFILE%
echo ------------------------------------------------->> %OUTFILE%

echo "Pausing for 30 seconds..."
CHOICE /N /C Y /T 30 /D Y >NUL
Shift
Goto TOP


As long as you use the PmiInfo.jacl script Michael set up, it should gather the stats you need and log them to a file. Change "machine01" the name of the machine you are connecting to. Ensure you have access to wsadmin.bat - you may need to change the path. You should now be able to execute this script, and it will run indefinitely until you cancel it.

1 comment:

  1. UGH! is there anything uglier than scripting in Windows. As Dijkstra said "Elegance is not a dispensable luxury but a quality that decides between success and failure"

    ReplyDelete