Parcourir la source

added docker zabbix template, removed unused / old templates so they don't confuse other people.

Thomas Wiest il y a 9 ans
Parent
commit
1f52ea8c4e

+ 1 - 0
playbooks/adhoc/zabbix_setup/filter_plugins

@@ -0,0 +1 @@
+../../../filter_plugins/

+ 7 - 0
playbooks/adhoc/zabbix_setup/oo-clean-zaio.yml

@@ -0,0 +1,7 @@
+#!/usr/bin/env ansible-playbook
+---
+- include: clean_zabbix.yml
+  vars:
+    g_server: http://localhost/zabbix/api_jsonrpc.php
+    g_user: Admin
+    g_password: zabbix

+ 13 - 0
playbooks/adhoc/zabbix_setup/oo-config-zaio.yml

@@ -0,0 +1,13 @@
+#!/usr/bin/ansible-playbook
+---
+- hosts: localhost
+  gather_facts: no
+  vars:
+    g_server: http://localhost/zabbix/api_jsonrpc.php
+    g_user: Admin
+    g_password: zabbix
+  roles:
+  - role: os_zabbix
+    ozb_server: "{{ g_server }}"
+    ozb_user: "{{ g_user }}"
+    ozb_password: "{{ g_password }}"

+ 1 - 0
playbooks/adhoc/zabbix_setup/roles

@@ -0,0 +1 @@
+../../../roles

+ 2 - 2
roles/lib_zabbix/library/zbx_trigger.py

@@ -65,7 +65,7 @@ def get_deps(zapi, deps):
     for desc in deps:
         content = zapi.get_content('trigger',
                                    'get',
-                                   {'search': {'description': desc},
+                                   {'filter': {'description': desc},
                                     'expandExpression': True,
                                     'selectDependencies': 'triggerid',
                                    })
@@ -119,7 +119,7 @@ def main():
 
     content = zapi.get_content(zbx_class_name,
                                'get',
-                               {'search': {'description': description},
+                               {'filter': {'description': description},
                                 'expandExpression': True,
                                 'selectDependencies': 'triggerid',
                                })

+ 17 - 19
roles/lib_zabbix/tasks/create_template.yml

@@ -16,18 +16,21 @@
 
 - debug: var=lzbx_applications
 
-- name: Create Application
-  zbx_application:
-    zbx_server: "{{ server }}"
-    zbx_user: "{{ user }}"
-    zbx_password: "{{ password }}"
-    name: "{{ item }}"
-    template_name: "{{ template.name }}"
-  with_items: lzbx_applications
-  register: created_application
-  when: template.zitems is defined
-
-- debug: var=created_application
+#
+# twiest: This is commented out because it doesn't work correctly
+#
+#- name: Create Application
+#  zbx_application:
+#    zbx_server: "{{ server }}"
+#    zbx_user: "{{ user }}"
+#    zbx_password: "{{ password }}"
+#    name: "{{ item }}"
+#    template_name: "{{ template.name }}"
+#  with_items: lzbx_applications
+#  register: created_application
+#  when: template.zitems is defined
+
+#- debug: var=created_application
 
 - name: Create Items
   zbx_item:
@@ -38,24 +41,19 @@
     name: "{{ item.name | default(item.key, true) }}"
     value_type: "{{ item.value_type | default('int') }}"
     template_name: "{{ template.name }}"
-    applications: "{{ item.applications }}"
+#    applications: "{{ item.applications }}"
   with_items: template.zitems
   register: created_items
   when: template.zitems is defined
 
-#- debug: var=ctp_created_items
-
 - name: Create Triggers
   zbx_trigger:
     zbx_server: "{{ server }}"
     zbx_user: "{{ user }}"
     zbx_password: "{{ password }}"
     description: "{{ item.description }}"
+    dependencies: "{{ item.dependencies | default([], true) }}"
     expression: "{{ item.expression }}"
     priority: "{{ item.priority }}"
   with_items: template.ztriggers
   when: template.ztriggers is defined
-
-#- debug: var=ctp_created_triggers
-
-

+ 9 - 0
roles/os_zabbix/tasks/main.yml

@@ -11,6 +11,7 @@
 
 - include_vars: template_heartbeat.yml
 - include_vars: template_os_linux.yml
+- include_vars: template_docker.yml
 
 - name: Include Template Heartbeat
   include: ../../lib_zabbix/tasks/create_template.yml
@@ -28,3 +29,11 @@
     user: "{{ ozb_user }}"
     password: "{{ ozb_password }}"
 
+- name: Include Template docker
+  include: ../../lib_zabbix/tasks/create_template.yml
+  vars:
+    template: "{{ g_template_docker }}"
+    server: "{{ ozb_server }}"
+    user: "{{ ozb_user }}"
+    password: "{{ ozb_password }}"
+

+ 83 - 0
roles/os_zabbix/vars/template_docker.yml

@@ -0,0 +1,83 @@
+---
+g_template_docker:
+  name: Template Docker
+  zitems:
+  - key: docker.ping
+    applications:
+    - Docker Daemon
+    value_type: int
+
+  - key: docker.storage.is_loopback
+    applications:
+    - Docker Storage
+    value_type: int
+
+  - key: docker.storage.data.space.total
+    applications:
+    - Docker Storage
+    value_type: float
+
+  - key: docker.storage.data.space.used
+    applications:
+    - Docker Storage
+    value_type: float
+
+  - key: docker.storage.data.space.available
+    applications:
+    - Docker Storage
+    value_type: float
+
+  - key: docker.storage.data.space.percent_available
+    applications:
+    - Docker Storage
+    value_type: float
+
+  - key: docker.storage.metadata.space.total
+    applications:
+    - Docker Storage
+    value_type: float
+
+  - key: docker.storage.metadata.space.used
+    applications:
+    - Docker Storage
+    value_type: float
+
+  - key: docker.storage.metadata.space.available
+    applications:
+    - Docker Storage
+    value_type: float
+
+  - key: docker.storage.metadata.space.percent_available
+    applications:
+    - Docker Storage
+    value_type: float
+  ztriggers:
+  - description: 'docker.ping failed on {HOST.NAME}'
+    expression: '{Template Docker:docker.ping.max(#3)}<1'
+    priority: high
+
+  - description: 'Docker storage is using LOOPBACK on {HOST.NAME}'
+    expression: '{Template Docker:docker.storage.is_loopback.last()}<>0'
+    priority: high
+
+  - description: 'Critically low docker storage data space on {HOST.NAME}'
+    expression: '{Template Docker:docker.storage.data.space.percent_available.max(#3)}<5 or {Template Docker:docker.storage.data.space.available.max(#3)}<5' # < 5% or < 5GB
+    priority: high
+
+  - description: 'Critically low docker storage metadata space on {HOST.NAME}'
+    expression: '{Template Docker:docker.storage.metadata.space.percent_available.max(#3)}<5 or {Template Docker:docker.storage.metadata.space.available.max(#3)}<0.1' # < 5% or < 100MB
+    priority: high
+
+  # Put triggers that depend on other triggers here (deps must be created first)
+  - description: 'Low docker storage data space on {HOST.NAME}'
+    expression: '{Template Docker:docker.storage.data.space.percent_available.max(#3)}<10 or {Template Docker:docker.storage.data.space.available.max(#3)}<10' # < 10% or < 10GB
+    dependencies:
+    - 'Critically low docker storage data space on {HOST.NAME}'
+    priority: average
+
+  - description: 'Low docker storage metadata space on {HOST.NAME}'
+    expression: '{Template Docker:docker.storage.metadata.space.percent_available.max(#3)}<10 or {Template Docker:docker.storage.metadata.space.available.max(#3)}<0.2' # < 10% or < 200MB
+    dependencies:
+    - 'Critically low docker storage metadata space on {HOST.NAME}'
+    priority: average
+

+ 0 - 27
roles/os_zabbix/vars/template_host.yml

@@ -1,27 +0,0 @@
----
-g_template_host:
-  params:
-    name: Template Host
-    host: Template Host
-    groups:
-    - groupid: 1 # FIXME (not real)
-    output: extend
-    search:
-      name: Template Host
-  zitems:
-  - name: Host Ping
-    hostid: 
-    key_: host.ping
-    type: 2
-    value_type: 0
-    output: extend
-    search:
-      key_: host.ping
-  ztriggers:
-  - description: 'Host ping has failed on {HOST.NAME}'
-    expression: '{Template Host:host.ping.last()}<>0'
-    priority: 3
-    searchWildcardsEnabled: True
-    search:
-      description: 'Host ping has failed on*'
-    expandExpression: True

+ 0 - 27
roles/os_zabbix/vars/template_master.yml

@@ -1,27 +0,0 @@
----
-g_template_master:
-  params:
-    name: Template Master
-    host: Template Master
-    groups:
-    - groupid: 1 # FIXME (not real)
-    output: extend
-    search:
-      name: Template Master
-  zitems:
-  - name: Master Etcd Ping
-    hostid: 
-    key_: master.etcd.ping
-    type: 2
-    value_type: 0
-    output: extend
-    search:
-      key_: master.etcd.ping
-  ztriggers:
-  - description: 'Master Etcd ping has failed on {HOST.NAME}'
-    expression: '{Template Master:master.etcd.ping.last()}<>0'
-    priority: 3
-    searchWildcardsEnabled: True
-    search:
-      description: 'Master Etcd ping has failed on*'
-    expandExpression: True

+ 0 - 27
roles/os_zabbix/vars/template_node.yml

@@ -1,27 +0,0 @@
----
-g_template_node:
-  params:
-    name: Template Node
-    host: Template Node
-    groups:
-    - groupid: 1 # FIXME (not real)
-    output: extend
-    search:
-      name: Template Node
-  zitems:
-  - name: Kubelet Ping
-    hostid: 
-    key_: kubelet.ping
-    type: 2
-    value_type: 0
-    output: extend
-    search:
-      key_: kubelet.ping
-  ztriggers:
-  - description: 'Kubelet ping has failed on {HOST.NAME}'
-    expression: '{Template Node:kubelet.ping.last()}<>0'
-    priority: 3
-    searchWildcardsEnabled: True
-    search:
-      description: 'Kubelet ping has failed on*'
-    expandExpression: True

+ 0 - 27
roles/os_zabbix/vars/template_router.yml

@@ -1,27 +0,0 @@
----
-g_template_router:
-  params:
-    name: Template Router
-    host: Template Router
-    groups:
-    - groupid: 1 # FIXME (not real)
-    output: extend
-    search:
-      name: Template Router
-  zitems:
-  - name: Router Backends down
-    hostid: 
-    key_: router.backends.down
-    type: 2
-    value_type: 0
-    output: extend
-    search:
-      key_: router.backends.down
-  ztriggers:
-  - description: 'Number of router backends down on {HOST.NAME}'
-    expression: '{Template Router:router.backends.down.last()}<>0'
-    priority: 3
-    searchWildcardsEnabled: True
-    search:
-      description: 'Number of router backends down on {HOST.NAME}'
-    expandExpression: True