Add possibility to override inputs from reclass

Change-Id: I786bd68335aa80ffacc22980981383f8fed054fa
diff --git a/telegraf/agent.sls b/telegraf/agent.sls
index 78a06f4..686bd98 100644
--- a/telegraf/agent.sls
+++ b/telegraf/agent.sls
@@ -28,6 +28,8 @@
   {%- endif %}
 {%- endfor %}
 
+{%- set service_grains = salt['grains.filter_by']({'default': service_grains}, merge={'telegraf': {'agent': {'input': agent.get('input', {})}}}) %}
+
 telegraf_grains_dir:
   file.directory:
   - name: /etc/salt/grains.d
@@ -47,8 +49,10 @@
     - file: telegraf_grains_dir
 
 {%- set telegraf_input = service_grains.telegraf.agent.input %}
+
 {%- for name,values in telegraf_input.iteritems() %}
 
+{%- if values is not mapping or values.get('enabled', True) %}
 input_{{ name }}:
   file.managed:
     - name: {{ agent.dir.config }}/input-{{ name }}.conf
@@ -75,6 +79,16 @@
       - pkg: telegraf_packages
 {%- endif %}
 
+{%- else %}
+input_{{name }}:
+  file.absent:
+    - name: {{ agent.dir.config }}/input-{{ name }}.conf
+    - require:
+      - pkg: telegraf_packages
+    - watch_in:
+      - service: telegraf_service
+{%- endif %}
+
 {%- endfor %}
 
 {%- for name,values in agent.output.iteritems() %}
diff --git a/telegraf/files/input/cpu.conf b/telegraf/files/input/cpu.conf
index ffc92ec..4c1dd90 100644
--- a/telegraf/files/input/cpu.conf
+++ b/telegraf/files/input/cpu.conf
@@ -1,9 +1,9 @@
 [[inputs.{{ name }}]]
 {%- if values is defined %}
 {%- if values.totalcpu is defined %}
-totalcpu = {{ values.totalcpu | lower }}
+  totalcpu = {{ values.totalcpu | lower }}
 {%- endif %}
 {%- if values.percpu is defined %}
-percpu = {{ values.percpu | lower }}
+  percpu = {{ values.percpu | lower }}
 {%- endif %}
 {%- endif %}
diff --git a/telegraf/files/input/disk.conf b/telegraf/files/input/disk.conf
index 9dd9e67..8ee733e 100644
--- a/telegraf/files/input/disk.conf
+++ b/telegraf/files/input/disk.conf
@@ -1,6 +1,6 @@
 [[inputs.{{ name }}]]
 {%- if values is defined %}
 {%- if values.mount_points is defined%}
-mount_points = {{ values.mount_points }}
+  mount_points = {{ values.mount_points }}
 {%- endif %}
 {%- endif %}
diff --git a/telegraf/files/input/diskio.conf b/telegraf/files/input/diskio.conf
index 01bf009..fa488c5 100644
--- a/telegraf/files/input/diskio.conf
+++ b/telegraf/files/input/diskio.conf
@@ -1,9 +1,9 @@
 [[inputs.{{ name }}]]
 {%- if values is defined %}
 {%- if values.devices is defined %}
-devices = {{ values.devices }}
+  devices = {{ values.devices }}
 {%- endif %}
 {%- if values.skip_serial_number is defined %}
-skip_serial_number = {{ values.skip_serial_number | lower }}
+  skip_serial_number = {{ values.skip_serial_number | lower }}
 {%- endif %}
 {%- endif %}
diff --git a/telegraf/files/input/procstat.conf b/telegraf/files/input/procstat.conf
index af5aedf..091a560 100644
--- a/telegraf/files/input/procstat.conf
+++ b/telegraf/files/input/procstat.conf
@@ -1,4 +1,5 @@
-{%- for item in values %}
+{%- for item_name, item in values.get('process', {}).iteritems() %}
+{%- if item.get('enabled', True) %}
 [[inputs.{{ name }}]]
 {%- if item.pid_file is defined %}
   pid_file = "{{ item.pid_file }}"
@@ -12,7 +13,6 @@
 {%- if item.user is defined %}
   user = "{{ item.user }}"
 {%- endif %}
-{%- if item.process_name is defined %}
-  process_name = "{{ item.process_name }}"
+  process_name = "{{ item_name }}"
 {%- endif %}
 {%- endfor %}