OSGI应用中集成Jolokia

OSGI应用中集成Jolokia

导入并安装jolokia的bundle

<dependency>
    <groupId>org.jolokia</groupId>
    <artifactId>jolokia-osgi</artifactId>
    <version>1.3.1</version>
</dependency>

安装

 <bundle>mvn:org.jolokia/jolokia-osgi/1.3.1</bundle>

阅读官方文档

jolokia-osgi

验证功能

启动系统,输入http://localhost:8181/jolokia/version
默认端口为8181可以通过修改配置文件指定端口,参考webcontainer

By default, Karaf creates an internal Jetty connector that you can configure via etc/org.ops4j.pax.web.cfg:

org.osgi.service.http.port=8181

输出:

{"request":{"type":"version"},"value":{"agent":"1.3.1","protocol":"7.2","config":{"listenForHttpService":"true","authIgnoreCerts":"false","agentId":"10.42.197.158-6872-208d744f-osgi","debug":"false","agentType":"servlet","policyLocation":"classpath:\/jolokia-access.xml","agentContext":"\/jolokia","serializeException":"false","mimeType":"text\/plain","authMode":"basic","canonicalNaming":"true","historyMaxEntries":"10","realm":"jolokia","includeStackTrace":"true","useRestrictorService":"false","debugMaxEntries":"100"},"info":{"product":"equinox","vendor":"Eclipse","version":"3.8.2.v20130124-134944"}},"timestamp":1571132282,"status":200}

查询内存占用http://localhost:8181/jolokia/read/java.lang:type=Memory
输出:

{"request":{"mbean":"java.lang:type=Memory","type":"read"},"value":{"ObjectPendingFinalizationCount":0,"Verbose":false,"HeapMemoryUsage":{"init":134217728,"committed":836763648,"max":1908932608,"used":527912992},"NonHeapMemoryUsage":{"init":2555904,"committed":156172288,"max":-1,"used":139495160},"ObjectName":{"objectName":"java.lang:type=Memory"}},"timestamp":1571132556,"status":200}

Karaf中的webconsole组件也是使用的上述端口
http://localhost:8181/system/console/bundles

OSGI应用中集成JolokiaOSGI应用中集成Jolokia 约定291天后 发布了99 篇原创文章 · 获赞 34 · 访问量 13万+ 私信 关注
上一篇:实验4:开源控制器实践——OpenDaylight


下一篇:Mybatis的一些语句