2

I´m trying to install perfino jar on production that can monitor Java Spring MVC web transactions and I need to put a javaagent into my Tomcat 9 server on windows somehow but am not clear on exactly how to do this, I am using Windows server and have been instructed by the software company that makes this product to do something like below:

-javaagent:C:\Program Files\perfino\agent\perfino.jar

Do i need to insert the above line into startup.bat or catlina.bat and any format i need to follow?

rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem ---------------------------------------------------------------------------

setlocal
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME=%cd%"
cd "%CURRENT_DIR%"
:gotHome
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end

Kindly advise me on this?

JSBeginner
  • 41
  • 2
  • 12

2 Answers2

0

-javagent is a VM parameter, it has to be inserted in the command line after the java executable and before the main class name.

The start scripts for Tomcat support an environment variable CATALINA_OPTS. In startup.bat, you can insert the line

set CATALINA_OPTS="-javaagent:C:\Program Files\perfino\agent\perfino.jar" %CATALINA_OPTS%

before the call to

call "%EXECUTABLE%" run %CMD_LINE_ARGS%
Ingo Kegel
  • 46,523
  • 10
  • 71
  • 102
  • I have added like below and startup.bat immediately close after i click it.tomcat is not starting. I have updated my question with the startup.bat file. :okHome set CATALINA_OPTS=-javaagent:C:\Program Files\perfino\agent\perfino.jar %CATALINA_OPTS% set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" – JSBeginner Oct 30 '20 at 16:10
  • How to do setup for linux? – JSBeginner Oct 30 '20 at 16:28
  • what is the difference between perfino and jprofiler. You have given option to attach a jvm from jprofiler itself and so why i need to use perfino? kindly advise. – JSBeginner Oct 30 '20 at 16:53
  • 1
    For Linux it's the same, just replace set with "export". perfino is a low overhead monitoring tool and JProfiler is a development profiler. – Ingo Kegel Oct 30 '20 at 19:22
0

After i have added " " to the above answer,it started working.

set CATALINA_OPTS=-javaagent:"C:\Program Files\perfino\agent\perfino.jar" %CATALINA_OPTS%

JSBeginner
  • 41
  • 2
  • 12