1、首先下载jolokia agent
wget 'https://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/1.6.2/jolokia-jvm-1.6.2-agent.jar' -O jolokia-jvm-1.6.2-agent.jar
2、查看一下jolokia agent的使用帮助
root@graylog:/opt/app/apache-tomcat-8.5.55/bin# java -jar jolokia-jvm-1.6.2-agent.jar --help
Jolokia Agent Launcher
======================
Usage: java -jar jolokia-jvm-1.6.2-agent.jar [options]
where is one of
start -- Start a Jolokia agent for the process specified
stop -- Stop a Jolokia agent for the process specified
status -- Show status of an (potentially) attached agent
toggle -- Toggle between start/stop (default when no command is given)
list -- List all attachable Java processes (default when no argument is given at all)
encrypt -- Encrypt a password which is given as argument or read from standard input
[options] are used for providing runtime information for attaching the agent:
--host Hostname or IP address to which to bind on
(default: InetAddress.getLocalHost())
--port Port to listen on (default: 8778)
--agentContext HTTP Context under which the agent is reachable (default: /jolokia)
--agentId VM unique identifier used by this agent (default: autogenerated)
--agentDescription Agent description
--authMode Authentication mode: 'basic' (default), 'jaas' or 'delegate'
--authMatch If MultiAuthenticator is used, this config item explains how to combine multiple authenticators
"any" -- at least one authenticator must match (default)
"all" -- all authenticators must match
--authClass Classname of an custom Authenticator which must be loadable from the classpath
--authUrl URL used for a dispatcher authentication (authMode == delegate)
--authPrincipalSpec Extractor specification for getting the principal (authMode == delegate)
--authIgnoreCerts Whether to ignore CERTS when doing a dispatching authentication (authMode == delegate)
--user User used for Basic-Authentication
--password Password used for Basic-Authentication
--quiet No output. "status" will exit with code 0 if the agent is running, 1 otherwise
--verbose Verbose output
--executor Executor policy for HTTP Threads to use (default: single)
"fixed" -- Thread pool with a fixed number of threads (default: 5)
"cached" -- Cached Thread Pool, creates threads on demand
"single" -- Single Thread
--threadNamePrefix Thread name prefix that executor will use while creating new thread(s)
(default: jolokia-)
--threadNr Number of fixed threads if "fixed" is used as executor
--backlog How many request to keep in the backlog (default: 10)
--protocol Protocol which must be either "http" or "https" (default: http)
--keystore Path to keystore (https only)
--keystorePassword Password to the keystore (https only)
--useSslClientAuthentication Use client certificate authentication (https only)
--secureSocketProtocol Secure protocol (https only, default: TLS)
--keyStoreType Keystore type (https only, default: JKS)
--keyManagerAlgorithm Key manager algorithm (https only, default: SunX509)
--trustManagerAlgorithm Trust manager algorithm (https only, default: SunX509)
--caCert Path to a PEM encoded CA cert file (https & sslClientAuth only)
--serverCert Path to a PEM encoded server cert file (https only)
--serverKey Path to a PEM encoded server key file (https only)
--serverKeyAlgorithm Algorithm to use for decrypting the server key (https only, default: RSA)
--clientPrincipal Allow only this principal in the client cert (https & sslClientAuth only)
If supplied multiple times, any one of the clientPrincipals must match
--extendedClientCheck Additional validation of client certs for the proper key usage (https & sslClientAuth only)
--discoveryEnabled Enable/Disable discovery multicast responses (default: true)
--discoveryAgentUrl The URL to use for answering discovery requests. Will be autodetected if not given.
--sslProtocol SSL / TLS protocol to enable, can be provided multiple times
--sslCipherSuite SSL / TLS cipher suite to enable, can be provided multiple times
--debug Switch on agent debugging
--logHandlerClass Implementation of org.jolokia.util.LogHandler for logging
Available classes: org.jolokia.util.LogHandler.Quiet org.jolokia.util.LogHandler.Jul --debugMaxEntries Number of debug entries to keep in memory which can be fetched from the Jolokia MBean
--maxDepth Maximum number of levels for serialization of beans
--maxCollectionSize Maximum number of element in collections to keep when serializing the response
--maxObjects Maximum number of objects to consider for serialization
--restrictorClass Classname of an custom restrictor which must be loadable from the classpath
--policyLocation Location of a Jolokia policy file
--mbeanQualifier Qualifier to use when registering Jolokia internal MBeans
--canonicalNaming whether to use canonicalName for ObjectNames in 'list' or 'search' (default: true)
--includeStackTrace whether to include StackTraces for error messages (default: true)
--serializeException whether to add a serialized version of the exception in the Jolokia response (default: false)
--config Path to a property file from where to read the configuration
--help This help documentation
--version Version of this agent (it's 1.6.2 btw :)
can be either a numeric process id or a regular expression. A regular expression is matched
against the processes' names (ignoring case) and must be specific enough to select exactly one process.
If no is given but only a the state of the Agent will be toggled
between "start" and "stop"
If neither nor is given, a list of Java processes along with their IDs
is printed
There are several possible reasons, why attaching to a process can fail:
* The UID of this launcher must be the very *same* as the process to attach too. It not sufficient to be root.
* The JVM must have HotSpot enabled and be a JVM 1.6 or larger.
* It must be a Java process ;-)
For more documentation please visit www.jolokia.org
3、启动jolokia agent
java -jar jolokia-jvm-1.6.2-agent.jar start catalina
显示如下:
Started Jolokia for process matching "catalina" (PID: 23402)
http://127.0.0.1:8778/jolokia/
4、查看jolokia的监听端口:
netstat -nlptu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 :::8443 :::* LISTEN 1862/java
tcp6 0 0 :::6556 :::* LISTEN 1443/xinetd
tcp6 0 0 :::6557 :::* LISTEN 2203/xinetd
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 23402/java
tcp6 0 0 :::9000 :::* LISTEN 1204/java
tcp6 0 0 127.0.0.1:8778 :::* LISTEN 23402/java
5、拷贝mk_jolokia.py 脚本到tomcat主机的check mk的plugin文件夹中
cp /opt/omd/versions/1.6.0p12.cre/share/check_mk/agents/plugins/mk_jolokia.py /usr/lib/check_mk_agent/plugins/
6、编辑 /etc/check_mk/jolokia.cfg 配置文件
vi /etc/check_mk/jolokia.cfg
填入如下内容:
suburi = "jolokia"
instance = None
#Configuration for multiple instances. Not-specified
#values will be taken from the upper settings
instances = [
{
"port" : 8778,
"instance" : "tomcat8",
}
]
7、登陆check mk 编辑tomcat主机配置
8、点击服务发现
9、如果提示 mk_jolokia requires the requests library. Please install it on the monitored system.
请安装 python的requests模块
pip2 install requests
10、刷新出来的监控项目如下:
11、提交此次发现
12、返回主界面,点击主机。基于jolokia agent的jvm监控就添加完毕了。