Skip to content

Template

add_template_to_group

add_template_to_group <TEMPLATE_NAMES_OR_IDS> <GROUP_NAMES_OR_IDS> [OPTIONS]

Add templates to groups.

NOTE: Group arguments are interpreted as template groups in >= 6.2, otherwise as host groups.

Arguments

TEMPLATE_NAMES_OR_IDS
Template names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

GROUP_NAMES_OR_IDS
Host/template group names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

Options

--strict
Fail if any host groups or templates aren't found. Should not be used in conjunction with wildcards.
Type: boolean
Default: False


create_templategroup

create_templategroup <TEMPLATEGROUP> [OPTIONS]

Create a new template group.

Assigns default user group permissions by default.

  • --rw-groups defaults to config option app.default_admin_usergroups.
  • --ro-groups defaults to config option app.default_create_user_usergroups.
  • Use --no-usergroup-permissions to create a group without any user group permissions.

NOTE: Calls create_hostgroup for Zabbix versions < 6.2.0.

Examples

Create a template group with default user group permissions

create_templategroup 'My Template Group'

Create a template group with specific RO and RW groups

create_templategroup 'My Template Group' --ro-groups users --rw-groups admins

Create a template group with no user group permissions

create_templategroup 'My Template Group' --no-usergroup-permissions

Arguments

TEMPLATEGROUP
Name of the group.
Type: text
Required:

Options

--rw-groups <RW_GROUPS>
User group(s) to give read/write permissions. Comma-separated.
Type: text

--ro-groups <RO_GROUPS>
User group(s) to give read-only permissions. Comma-separated.
Type: text

--no-usergroup-permissions
Do not assign user group permissions.
Type: boolean
Default: False


extend_templategroup

extend_templategroup <SRC_GROUP> <DEST_GROUP> [OPTIONS]

Add all templates from a group to other groups.

Interprets the source group as a template group in >= 6.2, otherwise as a host group.

Does not modify the source group or its templates. To remove the templates from the source group, use the move_templates command instead.

Arguments

SRC_GROUP
Group to get templates from.
Type: text
Required:

DEST_GROUP
Group(s) to add templates to. Comma-separated. Supports wildcards.
Type: text
Required:

Options

--dryrun
Show groups and templates without copying.
Type: boolean
Default: False


link_template_to_host <TEMPLATE_NAMES_OR_IDS> <HOSTNAMES_OR_IDS> [OPTIONS]

Link templates to hosts.

Examples

Link one template to one host

link_template_to_host 'Apache by HTTP' foo.example.com

Link many templates to many hosts

link_template_to_host 'Apache by HTTP,HAProxy by Zabbix agent' foo.example.com,bar.example.com

Link one template to all hosts

link_template_to_host 'Apache by HTTP' '*'

Link many templates to all hosts

link_template_to_host 'Apache by HTTP,HAProxy by Zabbix agent' '*'

Link all templates to all hosts (use with caution!)

link_template_to_host '*' '*'

Arguments

TEMPLATE_NAMES_OR_IDS
Template names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

HOSTNAMES_OR_IDS
Hostnames or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

Options

--strict
Fail if any hosts or templates aren't found. Should not be used in conjunction with wildcards.
Type: boolean
Default: False

--dryrun
Preview changes.
Type: boolean
Default: False


link_template_to_template <SOURCE> <DEST> [OPTIONS]

Link templates to templates.

NOTE: Destination templates are the ones that are ultimately modified. Source templates remain unchanged.

Examples

Link one template to one template

link_template_to_template 'Apache by HTTP' foo_template

Link many templates to many templates

link_template_to_template 'Apache by HTTP,HAProxy by Zabbix agent' foo_template,bar_template

Link all templates starting with 'Apache' to a template

link_template_to_template 'Apache*' foo_template

Link all templates containing 'HTTP' to a subset of templates

link_template_to_template '*HTTP*' 'Webserver-*'

Arguments

SOURCE
Template names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

DEST
Template names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

Options

--strict
Fail if any templates aren't found. Should not be used in conjunction with wildcards.
Type: boolean
Default: False

--dryrun
Do not actually link templates, just show what would be done.
Type: boolean
Default: False


move_templates

move_templates <SRC_GROUP> <DEST_GROUP> [OPTIONS]

Move all templates from one group to another.

Arguments

SRC_GROUP
Group to move templates from.
Type: text
Required:

DEST_GROUP
Group to move templates to.
Type: text
Required:

Options

--rollback/--no-rollback
Rollback changes if templates cannot be removed from source group afterwards.
Type: boolean
Default: True

--dryrun
Show templates and groups without making changes.
Type: boolean
Default: False


remove_template_from_group

remove_template_from_group <TEMPLATE_NAMES_OR_IDS> <GROUP_NAMES_OR_IDS> [OPTIONS]

Remove templates from groups.

Examples

Remove one template from one group

remove_template_from_group 'Apache by HTTP' foo_group

Remove many templates from many groups

remove_template_from_group 'Apache by HTTP,HAProxy by Zabbix agent' foo_group,bar_group

Remove all templates starting with 'Apache' from a group

remove_template_from_group 'Apache*' foo_group

Remove all templates containing 'HTTP' from all groups

remove_template_from_group '*HTTP*' '*'

Arguments

TEMPLATE_NAMES_OR_IDS
Template names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

GROUP_NAMES_OR_IDS
Host/template group names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

Options

--strict
Fail if any host groups or templates aren't found. Should not be used in conjunction with wildcards.
Type: boolean
Default: False

--dryrun
Preview changes.
Type: boolean
Default: False


remove_templategroup

remove_templategroup <TEMPLATEGROUP>

Delete a template group.

NOTE: Calls remove_hostgroup for Zabbix <6.2.

Arguments

TEMPLATEGROUP
Name of the group to delete.
Type: text
Required:


show_items

show_items <TEMPLATE_NAME>

Show a template's items.

Examples

Show items for a template

show_items 'Apache by HTTP'

Arguments

TEMPLATE_NAME
Template name or ID. Supports wildcards.
Type: text
Required:


show_template

show_template <TEMPLATE_NAME>

Show a template.

Arguments

TEMPLATE_NAME
Template name or ID. Names support wildcards.
Type: text
Required:


show_templategroup

show_templategroup <TEMPLATEGROUP> [OPTIONS]

Show details for a template group.

Arguments

TEMPLATEGROUP
Name of the group to show. Supports wildcards.
Type: text
Required:

Options

--templates/--no-templates
Show/hide templates associated with the group.
Type: boolean
Default: True


show_templategroups

show_templategroups <NAME> [OPTIONS]

Show template groups.

Fetches all groups by default, but can be filtered by name.

Examples

Show all template groups

show_templategroups

Show all template groups starting with 'Web-'

show_templategroups 'Web-*'

Show template groups with 'web' in the name

show_templategroups '*web*'

Arguments

NAME
Name of template group(s). Comma-separated. Supports wildcards.
Type: text

Options

--templates/--no-templates
Show/hide templates associated with each group.
Type: boolean
Default: True


show_templates

show_templates <TEMPLATES>

Show all templates.

Shows all templates by default. The template name can be a pattern containing wildcards. Names and IDs cannot be mixed.

Arguments

TEMPLATES
Template name(s) or ID(s). Comma-separated. Supports wildcards.
Type: text


unlink_template_from_host <TEMPLATE_NAMES_OR_IDS> <HOSTNAMES_OR_IDS> [OPTIONS]

Unlink templates from hosts.

Unlinks and clears by default. Use --no-clear to unlink without clearing.

Examples

Unlink a template from a host

unlink_template_from_host 'Apache by HTTP' foo.example.com

Unlink many templates from many hosts

unlink_template_from_host 'Apache by HTTP,HAProxy by Zabbix agent' foo.example.com,bar.example.com

Unlink one template from all hosts

unlink_template_from_host 'Apache by HTTP' '*'

Unlink templates starting with 'Apache' from hosts starting with 'Web'

unlink_template_from_host 'Apache*' 'Web-*'

Unlink template from host without clearing items and triggers

unlink_template_from_host --no-clear 'Apache by HTTP' foo.example.com

Arguments

TEMPLATE_NAMES_OR_IDS
Template names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

HOSTNAMES_OR_IDS
Hostnames or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

Options

--strict
Fail if any hosts or templates aren't found. Should not be used in conjunction with wildcards.
Type: boolean
Default: False

--dryrun
Preview changes.
Type: boolean
Default: False

--clear/--no-clear
Unlink and clear templates.
Type: boolean
Default: True


unlink_template_from_template <SOURCE> <DEST> [OPTIONS]

Unlink templates from templates.

Unlinks and clears by default. Use --no-clear to unlink without clearing. NOTE: Destination templates are the ones that are ultimately modified. Source templates remain unchanged.

Examples

Unlink one template from one template

unlink_template_from_template 'Apache by HTTP' foo_template

Unlink many templates from many templates

unlink_template_from_template 'Apache by HTTP,HAProxy by Zabbix agent' foo_template,bar_template

Unlink all templates starting with 'Apache' from a template

unlink_template_from_template 'Apache*' foo_template

Unlink all templates containing 'HTTP' from a subset of templates

unlink_template_from_template '*HTTP*' 'Web-*'

Unlink a template without clearing items and triggers

unlink_template_from_template --no-clear foo_template bar_template

Arguments

SOURCE
Template names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

DEST
Template names or IDs. Comma-separated. Supports wildcards.
Type: text
Required:

Options

--strict
Fail if any templates aren't found. Should not be used in conjunction with wildcards.
Type: boolean
Default: False

--clear/--no-clear
Unlink and clear templates.
Type: boolean
Default: True

--dryrun
Preview changes.
Type: boolean
Default: False