Multiple Collectd conf files using GenericJmxPlugin

293 Views Asked by At

I had couple of collectd conf files each loading the GenericJmx plugin and found the following in the logs. Although, the metrics were pulled from both jmx connections.

Dec 21 10:49:17 poc-vm collectd[27737]: java plugin: All `JVMArg' options MUST appear before all `LoadPlugin' options! The JVM is already started and I have to ignore this argument: -Djava.class.path=/opt/stackdriver/collectd/share/collectd/java/collectd-api.jar:/opt/stackdriver/collectd/share/collectd/java/generic-jmx.jar
Dec 21 10:49:17 poc-vm collectd[27737]: The read function "GenericJMX" is already registered. Check for duplicates in your configuration!

I could guess this is because of the following being present in both .conf files.

LoadPlugin java
LoadPlugin match_regex
LoadPlugin target_set
LoadPlugin target_replace
 
<Plugin "java">
    JVMARG "-Djava.class.path=/opt/stackdriver/collectd/share/collectd/java/collectd-api.jar:/opt/stackdriver/collectd/share/collectd/java/generic-jmx.jar"
    LoadPlugin "org.collectd.java.GenericJMX"
 
    <Plugin "GenericJMX">
        <MBean "SomeMbean">
            .....
 

But is this a guaranteed behavior? Can we have multiple conf files using GenericJMX plugin?

1

There are 1 best solutions below

0
Vinodhini Chockalingam On

Yes, those logs are just harmless warnings. Collectd loads each plugin when it first encounters the LoadPlugin directive. Since that directive may have options, it also warns when it encounters multiple ones - so you know it will only use the options from the first one it sees.

The GenericJmx plugin is loaded via the java binding. so in this case you're also being warned that the options for the second attempt to load the java binding will be ignored.

To avoid these warnings :

  1. Move the LoadPlugin into a separate file in the path.
vm:~$ cat /opt/stackdriver/collectd/etc/collectd.d/00_load_generic_jmx.conf 
LoadPlugin java
 
<Plugin "java">
    JVMARG "-Djava.class.path=/opt/stackdriver/collectd/share/collectd/java/collectd-api.jar:/opt/stackdriver/collectd/share/collectd/java/generic-jmx.jar"
    LoadPlugin "org.collectd.java.GenericJMX"
</Plugin>

Note :

Here the "path" is /opt/stackdriver/collectd/etc/collect.d/

Refer the bottom of the file : /etc/stackdriver/collectd.conf

# if you have other config, especially for plugins, you can drop them
# into this directory
Include "/opt/stackdriver/collectd/etc/collectd.d"
Include "/etc/stackdriver/collectd.d"
  1. Note the file name is prefixed with "00" to ensure it comes first in lexicographical order and therefore picked ahead of other .conf files in that path.

From https://collectd.org/documentation/manpages/collectd.conf.5.shtml#global_options : If more than one file is included by a single Include option, the files will be included in lexicographical order (as defined by the strcmp function). Thus, you can e. g. use numbered prefixes to specify the order in which the files are loaded.