Skip to content

Template Group

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


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_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