title: Jmeter PerfMon Metrics collection on different jmx port
body: <p>Wanted to post this because I searched around a lot and could not find a solution.</p>
  
  <p>Using jmeter and ServerAgent (2.2.1), I was having trouble getting it work on a custom JMX port (not 4711). Per the documentation you need to specify the parameters like so:</p>
  
  <pre><code>By default the Server Agent will try to connect to JMX server at localhost with port 4711. If you started JMX server at different host/port or using authentication with username/password, please, use following additional parameters:
  
  url=&lt;hostname&gt;\:&lt;port&gt;
  user=&lt;username&gt;
  password=&lt;password&gt;
  Available JMX metric types:
  
  gc-time - time spent in garbage collection, milliseconds (used method)
  memory-usage - heap memory used by VM, bytes (method used)
  memory-committed - heap memory committed by VM, bytes (method used)
  memorypool-usage - heap memory pool usage, bytes (method used)
  memorypool-committed - heap memory pool committed size, bytes (method used)
  class-count - loaded class count in VM (used method)
  compile-time - time spent in compilation, milliseconds (used method)
  Examples:
  
  gc-time - monitor GC time at localhost:4711
  memory-usage:url=somehost.com\:4715 - use alternative hostname/password
  class-count:url=somehost.com\:4715:user=apc:password=SecurityPlease123 - some secure setup access
  </code></pre>
  
  <p><a href="https://jmeter-plugins.org/wiki/PerfMonMetrics/" rel="nofollow noreferrer">Source</a></p>
  
  <p>So I tried that using </p>
  
  <p>localhost 4444 JMX gc-time:url=localhost:9080</p>
  
  <p>This however resulted in the server agent having the following stack trace</p>
  
  <pre><code>INFO    2017-02-23 20:53:51.352 [kg.apc.p] (): Starting measures: jmx:gc-time:url=localhost\:9080
  ERROR   2017-02-23 20:53:51.445 [kg.apc.p] (): Failed to get MX Bean data provider
  java.lang.IllegalArgumentException: Can't define JMX type
          at kg.apc.perfmon.metrics.jmx.AbstractJMXDataProvider.getProvider(AbstractJMXDataProvider.java:48)
          at kg.apc.perfmon.metrics.JMXMetric.&lt;init&gt;(JMXMetric.java:42)
          at kg.apc.perfmon.metrics.AbstractPerfMonMetric.createMetric(AbstractPerfMonMetric.java:65)
          at kg.apc.perfmon.PerfMonMetricGetter.setUpMetrics(PerfMonMetricGetter.java:138)
          at kg.apc.perfmon.PerfMonMetricGetter.processCommand(PerfMonMetricGetter.java:63)
          at kg.apc.perfmon.PerfMonMetricGetter.processNextCommand(PerfMonMetricGetter.java:101)
          at kg.apc.perfmon.PerfMonWorker.read(PerfMonWorker.java:210)
          at kg.apc.perfmon.PerfMonWorker.processCommands(PerfMonWorker.java:97)
          at kg.apc.perfmon.AgentTool.processParams(AgentTool.java:72)
          at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:63)
          at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:23)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:483)
          at kg.apc.cmd.UniversalRunner.main(UniversalRunner.java:175)
  ERROR   2017-02-23 20:53:51.446 [kg.apc.p] (): Invalid metric specified: jmx
  java.lang.RuntimeException: Failed to get MX Bean data provider
          at kg.apc.perfmon.metrics.JMXMetric.&lt;init&gt;(JMXMetric.java:45)
          at kg.apc.perfmon.metrics.AbstractPerfMonMetric.createMetric(AbstractPerfMonMetric.java:65)
          at kg.apc.perfmon.PerfMonMetricGetter.setUpMetrics(PerfMonMetricGetter.java:138)
          at kg.apc.perfmon.PerfMonMetricGetter.processCommand(PerfMonMetricGetter.java:63)
          at kg.apc.perfmon.PerfMonMetricGetter.processNextCommand(PerfMonMetricGetter.java:101)
          at kg.apc.perfmon.PerfMonWorker.read(PerfMonWorker.java:210)
          at kg.apc.perfmon.PerfMonWorker.processCommands(PerfMonWorker.java:97)
          at kg.apc.perfmon.AgentTool.processParams(AgentTool.java:72)
          at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:63)
          at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:23)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:483)
          at kg.apc.cmd.UniversalRunner.main(UniversalRunner.java:175)
  Caused by: java.lang.IllegalArgumentException: Can't define JMX type
          at kg.apc.perfmon.metrics.jmx.AbstractJMXDataProvider.getProvider(AbstractJMXDataProvider.java:48)
          at kg.apc.perfmon.metrics.JMXMetric.&lt;init&gt;(JMXMetric.java:42)
          ... 14 more
  </code></pre>
  
  <p>The solution, unbelievably, was to put the url portion first. Hopefully someone finds this page and time can be saved.</p>
  
  <p>e.g.</p>
  
  <p>url=localhost:9080:gc-time</p>