Java
Java JMX Mbeans.
Expose Java app metrics
You have to add java parameters to the app run f.x.
CATALINA_OPTS="-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9493 -Dcom.sun.management.jmxremote.rmi.port=9493 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=185.79.217.30
Connection could be SSL and authentication enabled. But since it's just a number the easiest way is just to configure available port, without SSL and auth.
List of possible JVM JMX parameters for remote connect:
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=9491
-Dcom.sun.management.jmxremote.rmi.port=9491
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=${HOST_IP}
${HOST_IP}
- It looks like JMX also requires access to a remote management interface (jstat) that uses a different port to transfer some data when arbitrating the connection. jstatd port is equivalent to the -Dcom.sun.management.jmxremote.rmi.port parameter
GUI to check MBeans
"C:\Program Files\Eclipse Adoptium\jdk-8.0.345.1-hotspot\bin\jconsole.exe"
Java installation has JConsole utility.
You could enter IP:port
and Username and Password for connection to JMX port there.
MBeans path and Zabbix representation
Example Bitbucket
- Connect with JConsole to Java JMX application endpoint
- Get ObjectName from MBeans Info
com.atlassian.bitbucket:type=metrics,category00=git,name=Merge
- Get Attribute name from MBeanAttribute info (it's a folder inside MBeans)
Count
- Install Zabbix Java Gateway component on Zabbix server
grep -i 'JavaGatewayPort' /etc/zabbix/zabbix_server.conf JavaGatewayPort=10052
- Create Zabbix item
Type: JMX agent Key: jmx["com.atlassian.bitbucket:type=metrics,category00=git,name=Merge",Count] JMX endpoint: service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{$BITBUCKET_JMX_PORT}/jmxrmi Username: {$BITBUCKET_JMX_USERNAME} Password: {$BITBUCKET_JMX_PASSWORD}
Key
- Notejmx["mbeansName",attributeName]
JMX endpoint
- Make sure host macro{$BITBUCKET_JMX_PORT}
is set on the host
Keytool (Java)
Java app LDAPS trust certificate (see below)
Use keytool to import AD DC certificate to cacerts keystore
Java import trusted certificate to keystore
keytool -importcert -keystore "C:\Program Files\Atlassian\JIRA\jre\lib\security\cacerts" -storepass changeit -file server-certificate.crt
Java list keystore certificates
keytool -v -list -keystore "C:\Program Files\Atlassian\JIRA\jre\lib\security\cacerts" -storepass changeit
Convert JKS to PEM certificate
keytool -importkeystore -srckeystore sourcecertificate.jks -destkeystore destinationcertificate.p12 -srcstoretype jks -deststoretype pkcs12