/*
* 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;
/*
* 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);
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