Warning
This module will be removed from Salt in version 3009 in favor of the zabbix Salt Extension.
New in version 2017.7.0.
Management of Zabbix Template object over Zabbix API.
Jakub Sliva <jakub.sliva@ultimum.io>
Makes the Zabbix Template to be absent (either does not exist or delete it).
name -- Zabbix Template name
_connection_user -- Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
_connection_password -- Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
_connection_url -- Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)
zabbix-template-absent:
zabbix_template.absent:
- name: Ceph OSD
Check if Zabbix Template already exists.
name -- Zabbix Template name
_connection_user -- Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
_connection_password -- Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
_connection_url -- Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)
does_zabbix-template-exist:
zabbix_template.is_present:
- name: Template OS Linux
Creates Zabbix Template object or if differs update it according defined parameters. See Zabbix API documentation.
Zabbix API version: >3.0
name -- Zabbix Template name
params -- Additional parameters according to Zabbix API documentation
static_host_list -- If hosts assigned to the template are controlled only by this state or can be also assigned externally
_connection_user -- Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
_connection_password -- Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
_connection_url -- Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)
Note
If there is a need to get a value from current zabbix online (e.g. ids of host groups you want the template to be associated with), put a dictionary with two keys "query_object" and "query_name" instead of the value. In this example we want to create template named "Testing Template", assign it to hostgroup Templates, link it to two ceph nodes and create a macro.
Note
IMPORTANT NOTE: Objects (except for template name) are identified by name (or by other key in some exceptional cases) so changing name of object means deleting old one and creating new one with new ID !!!
Note
linked templates
trigger dependencies
groups and group prototypes for host prototypes
SLS Example:
zabbix-template-present:
zabbix_template.present:
- name: Testing Template
# Do not touch existing assigned hosts
# True will detach all other hosts than defined here
- static_host_list: False
- params:
description: Template for Ceph nodes
groups:
# groups must already exist
# template must be at least in one hostgroup
- groupid:
query_object: hostgroup
query_name: Templates
macros:
- macro: "{$CEPH_CLUSTER_NAME}"
value: ceph
hosts:
# hosts must already exist
- hostid:
query_object: host
query_name: ceph-osd-01
- hostid:
query_object: host
query_name: ceph-osd-02
# templates:
# Linked templates - not supported by state module but can be linked manually (will not be touched)
applications:
- name: Ceph OSD
items:
- name: Ceph OSD avg fill item
key_: ceph.osd_avg_fill
type: 2
value_type: 0
delay: 60
units: '%'
description: 'Average fill of OSD'
applications:
- applicationid:
query_object: application
query_name: Ceph OSD
triggers:
- description: "Ceph OSD filled more that 90%"
expression: "{{'{'}}Testing Template:ceph.osd_avg_fill.last(){{'}'}}>90"
priority: 4
discoveries:
- name: Mounted filesystem discovery
key_: vfs.fs.discovery
type: 0
delay: 60
itemprototypes:
- name: Free disk space on {{'{#'}}FSNAME}
key_: vfs.fs.size[{{'{#'}}FSNAME},free]
type: 0
value_type: 3
delay: 60
applications:
- applicationid:
query_object: application
query_name: Ceph OSD
triggerprototypes:
- description: "Free disk space is less than 20% on volume {{'{#'}}FSNAME{{'}'}}"
expression: "{{'{'}}Testing Template:vfs.fs.size[{{'{#'}}FSNAME},free].last(){{'}'}}<20"
graphs:
- name: Ceph OSD avg fill graph
width: 900
height: 200
graphtype: 0
gitems:
- color: F63100
itemid:
query_object: item
query_name: Ceph OSD avg fill item
screens:
- name: Ceph
hsize: 1
vsize: 1
screenitems:
- x: 0
y: 0
resourcetype: 0
resourceid:
query_object: graph
query_name: Ceph OSD avg fill graph