Configuring a read-only user in Tomcat to add JMX authentification

The goal is to configure the Tomcat startup script in order to create a readonly user to read data from the JMX interface. Then we use that user in Zabbix to connect to the JMX console

1. Create or update your to allow for jmx and add authentication

If it does not exist, create a file in your $CATALINA_HOME/bin. It will contain all info on the jmx remote interface.
From the tomcat documentation

# Allow jmx remote

2. Create the access and password file

Here we create the jmxremote.access to add a monitorZabbix user with readonly permission. We adjust the rights so only tomcat can read it.

echo "monitorZabbix readonly" > jmxremote.access && chmod 400 jmxremote.access && chown tomcat:tomcat jmxremote.access

Here we create the jmxremote.password to define the password for the monitorZabbix user declared previously. We adjust the rights so only tomcat can read it.

echo "monitorZabbix PASSWORD" > jmxremote.password && chmod 400 jmxremote.password && chown tomcat:tomcat jmxremote.password

3. Declaring the user in Zabbix

On the host screen, create the two following macros. If needed/wanted you can declare them on the template level.

{$JMX_USER_NAME} = monitorZabbix
Written on April 10, 2015