summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 08d06d7)
raw | patch | inline | side by side (parent: 08d06d7)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 20 Aug 2009 15:21:33 +0000 (17:21 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 20 Aug 2009 15:21:33 +0000 (17:21 +0200) |
bindings/java/org/collectd/java/GenericJMXConfConnection.java | patch | blob | history | |
contrib/GenericJMX.conf | patch | blob | history |
diff --git a/bindings/java/org/collectd/java/GenericJMXConfConnection.java b/bindings/java/org/collectd/java/GenericJMXConfConnection.java
index 0108b53fdb1d5f3b56e7d477c54c5c2ef35a73ad..7214fd761c54f1f5ddd184bd5da311e0d82e5226 100644 (file)
package org.collectd.java;
import java.util.List;
+import java.util.Map;
import java.util.Iterator;
import java.util.ArrayList;
+import java.util.HashMap;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
class GenericJMXConfConnection
{
+ private String _username = null;
+ private String _password = null;
private String _host = null;
private String _service_url = null;
private MBeanServerConnection _jmx_connection = null;
{
JMXServiceURL service_url;
JMXConnector connector;
+ Map environment;
if (_jmx_connection != null)
return;
+ environment = null;
+ if (this._password != null)
+ {
+ String[] credentials;
+
+ if (this._username == null)
+ this._username = new String ("monitorRole");
+
+ credentials = new String[] { this._username, this._password };
+
+ environment = new HashMap ();
+ environment.put (JMXConnector.CREDENTIALS, credentials);
+ }
+
try
{
service_url = new JMXServiceURL (this._service_url);
- connector = JMXConnectorFactory.connect (service_url);
+ connector = JMXConnectorFactory.connect (service_url, environment);
_jmx_connection = connector.getMBeanServerConnection ();
}
catch (Exception e)
if (tmp != null)
this._host = tmp;
}
+ else if (child.getKey ().equalsIgnoreCase ("User"))
+ {
+ String tmp = getConfigString (child);
+ if (tmp != null)
+ this._username = tmp;
+ }
+ else if (child.getKey ().equalsIgnoreCase ("Password"))
+ {
+ String tmp = getConfigString (child);
+ if (tmp != null)
+ this._password = tmp;
+ }
else if (child.getKey ().equalsIgnoreCase ("ServiceURL"))
{
String tmp = getConfigString (child);
index 394dd3065a25c487ac9504ab406f473442a70798..f4dd8f0ead954d5281be573d641f6ca20a1cb322 100644 (file)
--- a/contrib/GenericJMX.conf
+++ b/contrib/GenericJMX.conf
# Connection blocks #
#####################
<Connection>
- Host "localhost"
ServiceURL "service:jmx:rmi:///jndi/rmi://localhost:17264/jmxrmi"
+ User "monitorRole"
+ Password "queeZie1"
+ Host "localhost"
Collect "classes"
Collect "compilation"
Collect "garbage_collector"