jmx

只用五分钟为系统实现基于JMX的监控

心已入冬 提交于 2019-12-10 22:49:34
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> JMX 早期是作为J2EE的一部分 , 因此总给人一种开发起来会很"重"的感觉, 这让不少Java程序员宁愿选择自行实现"轻量级"方案. 时至今日, 借助一些优秀的开源项目, JMX 也可以用起来很"轻". 使用 pojo-mbean 声明MBean pojo-mbean 使用Annotation对MBean进行声明, 省去不少 JMX 规范中要求的罗嗦代码, 不知道有多罗嗦的请见 这里 . 例如, ManagableServer 希望被声明为一个MBean, 只有两个步骤: 注解 @MBean(objectName="jsmx:type=Demo") class ManagableServer { @ManagedAttribute public long getCount() {...} @ManagedAttribute public int getGauge() {...} @ManagedOperation public void shutdown() {...} } 注册 ManagableServer mBean = new ManagableServer(); new MBeanRegistration(mBean).register(); 运行之后, 你可以通过 jconsole

JMX04-客户端访问

一曲冷凌霜 提交于 2019-12-10 22:42:34
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 通过客户端连接进行远程访问 连接: 1.声明一个JMX服务地址; 2.创建一个JMX连接器; 3.通过JMX连接器连接JMX服务地址,获得一个与MBeanServer的连接。 27行,mbsc.getDomains():用于获取当前MBeanServer中所有可以访问的作用域。 35到41行是对属性进行赋值和取值,不能直接调用属性方法,而是通过setAttribute、getAttrubute方法进行操作,则属性的首字母要大写。 对MBean资源中的方法进行操作有两种方式:一是通过代理直接调用方法(44到48行);二是通过JAVA反射的方法调用(51到54行)。 如果服务端异常退出: 1. 客户端与服务端之间是Socket连接,因此Socket连接超时后,会收到连接中断的异常信息。 2. 服务端中断后,客户端调用服务端方法会抛出ConnectException。 来源: oschina 链接: https://my.oschina.net/blacklands/blog/3141471

Deleting all messages in JMS queue in Widlfy 9

北城以北 提交于 2019-12-10 19:20:46
问题 I am trying to remove messages from JMS queue on Wildfly 9.0.2 (JBoss) using JMX, see following code: MBeanServer server = ManagementFactory.getPlatformMBeanServer(); try { String name = "jboss.as.expr:subsystem=messaging,hornetq-server=default,jms-queue=MyQueue"; ObjectName objectName = new ObjectName(objectNameString); String result = (String) server.invoke(objectName, "removeMessages", new Object[]{null}, new String[]{"java.lang.String"}); return result; } catch

How to expose Hystrix's circuit breaker status through JMX

坚强是说给别人听的谎言 提交于 2019-12-10 14:15:02
问题 I've been looking for a tutorial on how to expose Hystrix's circuit breaker status on JMX. I just found out an API for exposing metrics (e.g counters, gauges, etc) using hystrix-servo-metrics-publisher . Is it possible to expose circuit breaker status on JMX? 回答1: I found the solution, just start this code: HystrixPlugins.getInstance().registerMetricsPublisher( HystrixServoMetricsPublisher.getInstance()); After this you'll see the metrics on JMX in com.netlix.servo . Obs: The information will

Is it necessary to unregister an MBean from the Platform MBean Server?

落爺英雄遲暮 提交于 2019-12-10 13:09:12
问题 I've begun playing with MBeans for exposing some information about an app. Pretty much the totality of HOWTOs / Tutorials / Blog posts / Samples online teach you how to implement an MBean and register it with an MBean Server, but never mention (or only cursorily) unregistering the MBean from the server. I'm concerned about an MBean that needs to have a reference to a fairly heavyweight object in order to provide status information about that object. Does the Platform MBean Server maintain a

How to get the name of JMX Jmeter filename in a variable

半腔热情 提交于 2019-12-10 10:57:56
问题 I want to use the name of the jmeter test script (.jmx) in a listener so as to generate the result file in a dynamic way. Can you please tell me what is the Jmeter variable for that purpose? Used ${fileName} which didn't work 回答1: The variable that holds the test plan name is ${__TestPlanName} Ref: http://jmeter.apache.org/usermanual/functions.html#__TestPlanName 回答2: You can do it via Beanshell scripting like: GUI mode import org.apache.jmeter.gui.GuiPackage; String scriptName = GuiPackage

Kafka consumer lag through JMX

…衆ロ難τιáo~ 提交于 2019-12-10 10:39:58
问题 I'm trying to monitor the lag of a consumer group in Kafka 0.10. Our consumers are keeping track of their offsets in Kafka rather than ZooKeper. This means I can get the figures using the following: bin/kafka-consumer-groups.sh --bootstrap-server <broker> --describe --group <group-name> This works fine. However, my broker already makes use of the Prometheus JMX exporter for collecting a number of stats. I've connected JConsole to the brokers but can't see the same data being reported in JMX

JBoss JMX twiddle Runtime not registered

走远了吗. 提交于 2019-12-10 10:31:30
问题 I have a problem with the twiddle script on a Solaris 10 server. I have to read some properties e.g jboss.system and others. All properties depending on the jboss server are fine, but when I try to read properties from java.lang , the following error occurs: javax.management.InstanceNotFoundException: java.lang:type=Runtime is not registered. 回答1: The problem is that java.lang:type=Runtime is a Platform MBeanServer registered MBean and by default, twiddle connects you to the JBoss MBeanServer

Getting JMX working under Tomcat 7 with SSL and a self-signed cert

夙愿已清 提交于 2019-12-09 23:37:12
问题 I'm trying to get JMX working under Tomcat 7.0.23 with SSL. The servers are located in AWS, which means all the hosts are NATed, and I need to use JmxRemoteLifecycleListener to explicitly set the two ports used by JMX. I've been doing a lot of reading on the subject but I just can't get all the pieces working together properly. I can get JMX working fine without SSL. I have downloaded the version of catalina-jmx-remote.jar for my version of Tomcat and installed it in my tomcat/lib directory.

exporting spark worker/executor metrics to prometheus using jmxagent

谁说胖子不能爱 提交于 2019-12-09 18:25:53
问题 I have followed the instructions here to enable the metrics export to Prometheus for spark. In order to enable metrics export not just from the job, but also from master and workers, I have enabled the jmx agent for all of spark driver, master, worker, and executor. This causes a problem since spark worker and executor are collocated on the same machine and, thus, I need to pass in different jmx ports to them. This is not a problem if I have a 1-1 relationship between spark workers and