Merge "Support dict values for the notification parameter"
diff --git a/neutron/files/mitaka/openvswitch_agent.ini b/neutron/files/mitaka/openvswitch_agent.ini
index d22dda7..4656e35 100644
--- a/neutron/files/mitaka/openvswitch_agent.ini
+++ b/neutron/files/mitaka/openvswitch_agent.ini
@@ -101,6 +101,7 @@
 
 # Network types supported by the agent (gre and/or vxlan). (list value)
 #tunnel_types =
+{%- if "vxlan" in neutron.backend.tenant_network_types %}
 tunnel_types =vxlan
 
 # The UDP port to use for VXLAN tunnels. (port value)
@@ -112,7 +113,6 @@
 # MTU size of veth interfaces (integer value)
 #veth_mtu = 9000
 
-{%- if "vxlan" in neutron.backend.tenant_network_types %}
 # Use ML2 l2population mechanism driver to learn remote MAC and IPs and improve tunnel scalability. (boolean value)
 #l2_population = false
 l2_population = True
@@ -180,7 +180,9 @@
 
 # Local IP address of tunnel endpoint. Can be either an IPv4 or IPv6 address. (IP address value)
 #local_ip = <None>
+{%- if "vxlan" in neutron.backend.tenant_network_types %}
 local_ip = {{ neutron.local_ip }}
+{%- endif %}
 
 # Comma-separated list of <physical_network>:<bridge> tuples mapping physical network names to the agent's node-specific Open vSwitch bridge
 # names to be used for flat and VLAN networks. The length of bridge names should be no more than 11. Each bridge must exist, and should have
diff --git a/neutron/meta/heka.yml b/neutron/meta/heka.yml
index 33e0ec6..17fdc06 100644
--- a/neutron/meta/heka.yml
+++ b/neutron/meta/heka.yml
@@ -1,3 +1,10 @@
+{%- from "neutron/map.jinja" import server with context %}
+{%- if server.backend.engine == "ml2" %}
+{% set neutron_agents = ('l3', 'dhcp', 'metadata', 'openvswitch') %}
+{%- else %}
+{% set neutron_agents = () %}
+{%- endif %}
+
 log_collector:
   decoder:
     neutron:
@@ -79,6 +86,67 @@
         periods: 0
         function: last
     {%- endif %}
+    {%- for agent in neutron_agents %}
+    neutron_{{ agent }}_two_up:
+      description: 'Some Neutron {{ agent }} agents are down'
+      severity: warning
+      logical_operator: and
+      rules:
+      - metric: openstack_neutron_agents
+        field:
+          service: {{ agent }}
+          state: up
+        relational_operator: '>='
+        threshold: 2
+        window: 60
+        periods: 0
+        function: last
+      - metric: openstack_neutron_agents
+        field:
+          service: {{ agent }}
+          state: down
+        relational_operator: '>'
+        threshold: 0
+        window: 60
+        periods: 0
+        function: last
+    neutron_{{ agent }}_one_up:
+      description: 'Only one Neutron {{ agent }} agent is up'
+      severity: critical
+      logical_operator: and
+      rules:
+      - metric: openstack_neutron_agents
+        field:
+          service: {{ agent }}
+          state: up
+        relational_operator: '=='
+        threshold: 1
+        window: 60
+        periods: 0
+        function: last
+      - metric: openstack_neutron_agents_percent
+        field:
+          service: {{ agent }}
+          state: up
+        relational_operator: '<'
+        threshold: 100
+        window: 60
+        periods: 0
+        function: last
+    neutron_{{ agent }}_zero_up:
+      description: 'All Neutron {{ agent }} agents are down or disabled'
+      severity: down
+      rules:
+      - metric: openstack_neutron_agents
+        field:
+          service: {{ agent }}
+          state: up
+        relational_operator: '=='
+        threshold: 0
+        window: 60
+        periods: 0
+        function: last
+    {%- endfor %}
   alarm:
     {%- if pillar.neutron.server is defined %}
     neutron_api_check:
@@ -87,6 +155,16 @@
       dimension:
         service: neutron-api-check
     {%- endif %}
+    {%- for agent in neutron_agents %}
+    neutron_{{ agent }}:
+      alerting: enabled
+      triggers:
+      - neutron_{{ agent }}_zero_up
+      - neutron_{{ agent }}_one_up
+      - neutron_{{ agent }}_two_up
+      dimension:
+        service: neutron-{{ agent }}
+    {%- endfor %}
 aggregator:
   alarm_cluster:
     neutron_logs:
@@ -133,3 +211,29 @@
       dimension:
         cluster_name: neutron-control
         nagios_host: 00-top-clusters
+    {%- for agent in neutron_agents %}
+    neutron_{{ agent }}:
+      policy: highest_severity
+      alerting: enabled
+      match:
+        service: neutron-{{ agent }}
+      members:
+      - neutron_{{ agent }}
+      dimension:
+        service: neutron-data
+        nagios_host: 01-service-clusters
+    {%- endfor %}
+{%- if neutron_agents|length > 0 %}
+    neutron_data:
+      policy: highest_severity
+      alerting: enabled_with_notification
+      match:
+        service: neutron-data
+      members:
+    {%- for agent in neutron_agents %}
+      - neutron_{{ agent }}
+    {%- endfor %}
+      dimension:
+        cluster_name: neutron-data
+        nagios_host: 00-top-clusters
+{%- endif %}