Fix for collectd java plugin proper loading
diff --git a/collectd/_service.sls b/collectd/_service.sls
index cef78e2..f1689f8 100644
--- a/collectd/_service.sls
+++ b/collectd/_service.sls
@@ -129,6 +129,13 @@
 
 {%- endif %}
 
+{{ client.defaults_file }}:
+  file.managed:
+  - source: salt://collectd/files/default_collectd
+  - template: jinja
+  - user: root
+  - group: root
+  - mode: 644
 
 {{ client.service }}_service:
 {%- if client.automatic_starting %}
@@ -137,6 +144,7 @@
   - watch:
     - file: {{ client.config_file }}
     - file: {{ client.config_dir }}/*
+    - file: {{ client.defaults_file }}
 {%- else %}
   service.disabled:
 {%- endif %}
diff --git a/collectd/files/default_collectd b/collectd/files/default_collectd
new file mode 100644
index 0000000..c06e4bb
--- /dev/null
+++ b/collectd/files/default_collectd
@@ -0,0 +1,24 @@
+# 0: start collectd on boot, 1: do not start collectd on boot
+# default: 0
+DISABLE=0
+
+# 0: start collectd in stand-alone mode, 1: monitor collectd using collectdmon
+# default: 1
+USE_COLLECTDMON=1
+
+# number of seconds to wait for collectd to shut down
+# default: 30
+MAXWAIT=30
+
+# 0: do not enable core-files, 1: enable core-files ... if collectd crashes
+# default: 0
+ENABLE_COREFILES=0
+{%- set java_ld_library_path = '' %}
+{%- set java_lib = salt['cmd.run']('type java >/dev/null 2>&1 && find /usr/lib/jvm -name libjvm.so -type f') %}
+{%- if java_lib|length > 0 %}
+  {%- set java_path = '/'.join(java_lib.split('/')[:-1]) %}
+  {%- set java_ld_library_path = 'export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:' ~ java_path %}
+
+# For Java plugin
+{{ java_ld_library_path }}
+{%- endif %}
diff --git a/collectd/map.jinja b/collectd/map.jinja
index ace3a0b..4464c9c 100644
--- a/collectd/map.jinja
+++ b/collectd/map.jinja
@@ -3,6 +3,7 @@
     'Arch': {
         'pkgs': ['collectd'],
         'service': 'collectd',
+        'defaults_file': '/etc/default/collectd',
         'config_file': '/etc/collectd.conf',
         'config_dir': '/etc/collectd.d',
         'read_interval': 60,
@@ -14,6 +15,7 @@
     'Debian': {
         'pkgs': ['collectd-core', 'snmp', 'python-yaml', 'libpython2.7', 'python-simplejson'],
         'service': 'collectd',
+        'defaults_file': '/etc/default/collectd',
         'config_file': '/etc/collectd/collectd.conf',
         'config_dir': '/etc/collectd/conf.d',
         'read_interval': 60,
@@ -25,6 +27,7 @@
     'RedHat': {
         'pkgs': ['collectd', 'collectd-ping', 'net-snmp', 'PyYAML'],
         'service': 'collectd',
+        'defaults_file': '/etc/sysconfig/collectd',
         'config_file': '/etc/collectd.conf',
         'config_dir': '/etc/collectd.d',
         'read_interval': 60,
@@ -38,6 +41,7 @@
 {% set remote_client = salt['grains.filter_by']({
     'default': {
         'service': 'remote_collectd',
+        'defaults_file': '/etc/default/remote_collectd',
         'config_file': '/etc/remote_collectd/collectd.conf',
         'config_dir': '/etc/remote_collectd/conf.d',
         'read_interval': 60,