summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7b81455)
raw | patch | inline | side by side (parent: 7b81455)
author | Florian Forster <octo@noris.net> | |
Wed, 16 Jun 2010 13:36:04 +0000 (15:36 +0200) | ||
committer | Florian Forster <octo@noris.net> | |
Wed, 16 Jun 2010 13:36:04 +0000 (15:36 +0200) |
diff --git a/bindings/java/org/collectd/java/GenericJMXConfConnection.java b/bindings/java/org/collectd/java/GenericJMXConfConnection.java
index ffa9ded4fbdc874b32dc3c5e6472df5352c6c59d..0c81bc9ad941760f07021530d6663f32ee34b75f 100644 (file)
/*
* collectd/java - org/collectd/java/GenericJMXConfConnection.java
- * Copyright (C) 2009 Florian octo Forster
+ * Copyright (C) 2009,2010 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
private String _username = null;
private String _password = null;
private String _host = null;
+ private String _instance_prefix = null;
private String _service_url = null;
private MBeanServerConnection _jmx_connection = null;
private List<GenericJMXConfMBean> _mbeans = null;
if (tmp != null)
this._service_url = tmp;
}
+ else if (child.getKey ().equalsIgnoreCase ("InstancePrefix"))
+ {
+ String tmp = getConfigString (child);
+ if (tmp != null)
+ this._instance_prefix = tmp;
+ }
else if (child.getKey ().equalsIgnoreCase ("Collect"))
{
String tmp = getConfigString (child);
{
int status;
- status = this._mbeans.get (i).query (this._jmx_connection, pd);
+ status = this._mbeans.get (i).query (this._jmx_connection, pd,
+ this._instance_prefix);
if (status != 0)
{
this._jmx_connection = null;
diff --git a/bindings/java/org/collectd/java/GenericJMXConfMBean.java b/bindings/java/org/collectd/java/GenericJMXConfMBean.java
index 1587bd5f9729009d13d72f8a31766439f33a6341..b1fbfb3ec18c14fadf0ae56c845d8ff76a0f5417 100644 (file)
/*
* collectd/java - org/collectd/java/GenericJMXConfMBean.java
- * Copyright (C) 2009 Florian octo Forster
+ * Copyright (C) 2009,2010 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
return (v.getString ());
} /* }}} String getConfigString */
- private String join (String separator, List<String> list) /* {{{ */
- {
- StringBuffer sb;
-
- sb = new StringBuffer ();
-
- for (int i = 0; i < list.size (); i++)
- {
- if (i > 0)
- sb.append ("-");
- sb.append (list.get (i));
- }
-
- return (sb.toString ());
- } /* }}} String join */
-
/*
* <MBean "alias name">
* ObjectName "object name"
return (this._name);
} /* }}} */
- public int query (MBeanServerConnection conn, PluginData pd) /* {{{ */
+ public int query (MBeanServerConnection conn, PluginData pd, /* {{{ */
+ String instance_prefix)
{
Set<ObjectName> names;
Iterator<ObjectName> iter;
ObjectName objName;
PluginData pd_tmp;
List<String> instanceList;
- String instance;
+ StringBuffer instance;
objName = iter.next ();
pd_tmp = new PluginData (pd);
instanceList = new ArrayList<String> ();
+ instance = new StringBuffer ();
Collectd.logDebug ("GenericJMXConfMBean: objName = "
+ objName.toString ());
}
}
+ if (instance_prefix != null)
+ instance.append (instance_prefix);
+
if (this._instance_prefix != null)
- instance = new String (this._instance_prefix
- + join ("-", instanceList));
- else
- instance = join ("-", instanceList);
- pd_tmp.setPluginInstance (instance);
+ instance.append (this._instance_prefix);
+
+ for (int i = 0; i < instanceList.size (); i++)
+ {
+ if (i > 0)
+ instance.append ("-");
+ instance.append (instanceList.get (i));
+ }
+
+ pd_tmp.setPluginInstance (instance.toString ());
- Collectd.logDebug ("GenericJMXConfMBean: instance = " + instance);
+ Collectd.logDebug ("GenericJMXConfMBean: instance = " + instance.toString ());
for (int i = 0; i < this._values.size (); i++)
this._values.get (i).query (conn, objName, pd_tmp);
diff --git a/src/collectd-java.pod b/src/collectd-java.pod
index 9c0c6eba1646cf771bea4bdf80b327b203723980..9e2f81aa9b9f0056d3aefa215605688b47f8ae81 100644 (file)
--- a/src/collectd-java.pod
+++ b/src/collectd-java.pod
Use I<password> to authenticate to the server. If not given, unauthenticated
access is used.
+=item B<InstancePrefix> I<prefix>
+
+Prefixes the generated I<plugin instance> with I<prefix>. If a second
+I<InstancePrefix> is specified in a referenced I<MBean> block, the prefix
+specified in the I<Connection> block will appear at the beginning of the
+I<plugin instance>, the prefix specified in the I<MBean> block will be appended
+to it.
+
=item B<Collect> I<mbean_block_name>
Configures which of the I<MBean> blocks to use with this connection. May be