0

We want to monitor jvm metrics of our tomcat instances. We think jolokia is a good solution since there is a nice Nagios (checkMK) plugin for it. I was wondering, if we use the spring agent option, specifying the dependency in our pom.

From what I understand this will launch the agent when the application starts. Is it possible to specify in any tomcat properties file if we want the agent to start or not ? Because otherwise if for some reason we want to stop the agent there is no other way but to redeploy the app right ?

dragosb
  • 607
  • 8
  • 25

1 Answers1

0

If you integrate Jolokia into a Spring application context as described here then you can set the option autoStart to false either directly or via a Spring property. If you the systemPropertiesMode then you can set it even from an external property.

Tbh, I don't know exactly how Spring Boot does create the agent internally when the dependency is provided, but hopefully it exposes the same ways of configuration as if you declare the agent yourself in your application context.

As an alternative, if you would use an external agent you can easily add the Jolokia agent to the startup options of a Tomcat in bin/setenv.sh. Since this is a regular shell script you can add any logic here, too and add the Jolokia configuration to your variable CATALINA_OPTS conditionally:

if [ -n "$ENABLE_JOLOKIA" ]; then
   CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/jolokia-agent.jar"
fi

and then you can set the env var ENABLE_JOLOKIA before starting tomcat.

Roland Huß
  • 2,507
  • 15
  • 30