Merge remote-tracking branch 'upstream/master' into stacklight
diff --git a/_modules/linux_netlink.py b/_modules/linux_netlink.py
new file mode 100644
index 0000000..9e6df55
--- /dev/null
+++ b/_modules/linux_netlink.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+
+import re
+
+_alphanum_re = re.compile(r'^[a-z0-9]+$')
+_lo_re = re.compile(r'^lo$')
+
+
+def _filter(interface):
+    return _alphanum_re.match(interface) and not _lo_re.match(interface)
+
+
+def ls():
+    """
+    Provide a list of network interfaces.
+    """
+    return filter(_filter, __salt__['grains.get']('ip_interfaces', {}).keys())
diff --git a/linux/files/collectd_df.conf b/linux/files/collectd_df.conf
index c0460eb..586e1a0 100644
--- a/linux/files/collectd_df.conf
+++ b/linux/files/collectd_df.conf
@@ -7,4 +7,8 @@
   FSType {{ fs_type }}
   {%- endfor %}
   IgnoreSelected {{ plugin.get('ignore_selected', False)|lower }}
+  ReportByDevice false
+  ReportInodes true
+  ValuesAbsolute true
+  ValuesPercentage true
 </Plugin>
diff --git a/linux/files/collectd_netlink.conf b/linux/files/collectd_netlink.conf
new file mode 100644
index 0000000..9d7d0d3
--- /dev/null
+++ b/linux/files/collectd_netlink.conf
@@ -0,0 +1,10 @@
+<LoadPlugin netlink>
+  Globals false
+</LoadPlugin>
+
+<Plugin netlink>
+  {%- for interface_name in plugin.get('interfaces', []) %}
+  VerboseInterface "{{ interface_name }}"
+  {%- endfor %}
+  IgnoreSelected {{ plugin.get('ignore_selected', False)|lower }}
+</Plugin>
diff --git a/linux/map.jinja b/linux/map.jinja
index 5c57d95..2f370ca 100644
--- a/linux/map.jinja
+++ b/linux/map.jinja
@@ -15,7 +15,7 @@
         'doc_validity_pkgs': ['python-yaml'],
     },
     'Debian': {
-        'pkgs': ['python-apt','vim-nox', 'apt-transport-https'],
+        'pkgs': ['python-apt','vim-nox', 'apt-transport-https', 'libmnl0'],
         'utc': true,
         'user': {},
         'group': {},
diff --git a/linux/meta/collectd.yml b/linux/meta/collectd.yml
index e40f45a..5410d2a 100644
--- a/linux/meta/collectd.yml
+++ b/linux/meta/collectd.yml
@@ -1,31 +1,28 @@
-plugin:
-  linux_network_interface:
-    plugin: interface
-    execution: local
+local_plugin:
+  linux_network_netlink:
+    plugin: netlink
+    template: linux/files/collectd_netlink.conf
+    ignore_selected: false
+    interfaces:
+    {%- for interface_name in salt['linux_netlink.ls']() %}
+    - {{ interface_name }}
+    {%- endfor %}
   linux_system_cpu:
     plugin: cpu
-    execution: local
   linux_system_entropy:
     plugin: entropy
-    execution: local
   linux_system_load:
     plugin: load
-    execution: local
   linux_system_contextswitch:
     plugin: contextswitch
-    execution: local
   linux_system_memory:
     plugin: memory
-    execution: local
   linux_system_uptime:
     plugin: uptime
-    execution: local
   linux_system_users:
     plugin: users
-    execution: local
   linux_storage_df:
     plugin: df
-    execution: local
     template: linux/files/collectd_df.conf
     ignore_selected: True
     fs_types:
@@ -39,9 +36,7 @@
     - cgroup
   linux_storage_disk:
     plugin: disk
-    execution: local
     template: linux/files/collectd_disk.conf
     ignore_selected: True
   linux_storage_swap:
     plugin: swap
-    execution: local
diff --git a/linux/meta/heka.yml b/linux/meta/heka.yml
index 7157ca3..0c4a43c 100644
--- a/linux/meta/heka.yml
+++ b/linux/meta/heka.yml
@@ -1,19 +1,62 @@
-input:
-  linux_rsyslog_syslog:
-    engine: logstreamer
-    log_directory: /var/log
-    file_match: syslog\.?(?P<Index>\d+)?(.gz)?
-    priority: ["^Index"]
-    decoder: RsyslogDecoder
-  linux_rsyslog_auth:
-    engine: logstreamer
-    log_directory: /var/log
-    file_match: auth\.log\.?(?P<Index>\d+)?(.gz)?
-    priority: ["^Index"]
-    decoder: RsyslogDecoder
-  linux_rsyslog_kern:
-    engine: logstreamer
-    log_directory: /var/log
-    file_match: kern\.log\.?(?P<Index>\d+)?(.gz)?
-    priority: ["^Index"]
-    decoder: RsyslogDecoder
+log_collector:
+  decoder:
+    system:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/generic_syslog.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+      config:
+        syslog_pattern: '%TIMESTAMP% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg%\n'
+  input:
+    linux_log_stream:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: '(?P<Service>daemon\.log|cron\.log|haproxy\.log|kern\.log|auth\.log|syslog|messages|debug)'
+      differentiator: [ 'system.', 'Service' ]
+      decoder: "system_decoder"
+      splitter: "TokenSplitter"
+  filter:
+    linux_hdd_errors:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/filters/hdd_errors_counter.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      preserve_data: false
+      message_matcher: "Type == 'log' && Logger == 'system.kern'"
+      ticker_interval: 10
+      config:
+        grace_interval: 10
+        patterns: "/error%s.+([sv]d[a-z][a-z]?)%d?/ /([sv]d[a-z][a-z]?)%d?.+%serror/"
+        hostname: '{{ grains.host }}'
+metric_collector:
+  trigger:
+    linux_system_cpu_critical:
+      description: 'The CPU usage is too high.'
+      severity: critical
+      rules:
+      - metric: cpu_wait
+        relational_operator: '>='
+        threshold: 35
+        window: 120
+        periods: 0
+        function: avg
+      - metric: cpu_idle
+        relational_operator: <=
+        threshold: 5
+        window: 120
+        function: avg
+    linux_system_cpu_warning:
+      description: 'The CPU wait times are high.'
+      severity: critical
+      rules:
+      - metric: cpu_wait
+        relational_operator: '>='
+        threshold: 15
+        window: 120
+        periods: 0
+        function: avg
+  alarm:
+    linux_system_cpu:
+      alerting: enabled
+      triggers:
+      - linux_system_cpu_warning
+      - linux_system_cpu_critical
diff --git a/linux/network/host.sls b/linux/network/host.sls
index d913c6f..6749350 100644
--- a/linux/network/host.sls
+++ b/linux/network/host.sls
@@ -28,6 +28,8 @@
     - repl: {{ after }}
     - watch:
       - host: linux_host_{{ name }}
+    - onlyif:
+      - grep -q "{{ before }}" /etc/hosts
 
 {%- endif %}
 
@@ -35,4 +37,4 @@
 
 {%- endfor %}
 
-{%- endif %}
\ No newline at end of file
+{%- endif %}
diff --git a/linux/network/interface.sls b/linux/network/interface.sls
index 8916ed6..07fb547 100644
--- a/linux/network/interface.sls
+++ b/linux/network/interface.sls
@@ -87,6 +87,7 @@
   - type: {{ interface.type }}
   {%- if interface.address is defined %}
   {%- if grains.os_family == 'Debian' %}
+  - unless: grep -q "iface {{ interface_name }} " /etc/network/interfaces
   - proto: {{ interface.get('proto', 'static') }}
   {% endif %}
   {%- if grains.os_family == 'RedHat' %}
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 55cb43b..cc40765 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -4,7 +4,7 @@
       collectd:
         enabled: true
       heka:
-        enabled: false
+        enabled: true
       sensu:
         enabled: true
       sphinx: