Skip to content

Configuration

Configuration file directory

The application uses the platformdirs package to determine the configuration directory.

The application is configured with a TOML file. The file is created on startup if it doesn't exist.

The configuration file is searched for in the following locations:

  • ./zabbix-cli.toml
  • $XDG_CONFIG_HOME/zabbix-cli/zabbix-cli.toml
  • $XDG_CONFIG_DIRS/zabbix-cli/zabbix-cli.toml
  • ./zabbix-cli.toml
  • ~/Library/Application Support/zabbix-cli/zabbix-cli.toml
  • ~/Library/Preferences/zabbix-cli/zabbix-cli.toml
  • .\zabbix-cli.toml
  • %LOCALAPPDATA%\zabbix-cli\zabbix-cli.toml
  • %APPDATA%\zabbix-cli\zabbix-cli.toml

Create a config

The configuration file is automatically created when the application is started for the first time.

The config file can also manually be created with the init command:

zabbix-cli init

The application will print the location of the created configuration file.

To bootstrap the config with a URL and username, use the options --url and --user:

zabbix-cli init --url https://zabbix.example.com --user Admin

To overwrite an existing configuration file, use the --overwrite option:

zabbix-cli init --overwrite

Config directory

The default configuration directory can be opened in the system's file manager with the open command:

zabbix-cli open config

To print the path instead of opening it, use the --path option:

zabbix-cli open config --path

Show config

The contents of the current configuration file can be displayed with show_config:

zabbix-cli show_config

Sample config

A sample configuration file can be printed to the terminal with the sample_config command. This can be redirected to a file to create a configuration file in an arbitrary location:

zabbix-cli sample_config > /path/to/config.toml

The created config looks like this (with actual paths instead of placeholders)

[api]
url = "https:/zabbix.example.com"
username = "Admin"
password = ""
auth_token = ""
verify_ssl = true

[app]
use_session_file = true
session_file = "/path/to/data_dir/.zabbix-cli_session.json"
auth_token_file = "/path/to/data_dir/.zabbix-cli_auth_token"
use_auth_file = true
auth_file = "/path/to/data_dir/.zabbix-cli_auth"
allow_insecure_auth_file = true
history = true
history_file = "/path/to/data_dir/history"
bulk_mode = "strict"
legacy_json_format = false

[app.commands.create_host]
create_interface = true
hostgroups = []

[app.commands.create_group]
ro_groups = []
rw_groups = []

[app.commands.create_hostgroup]
ro_groups = []
rw_groups = []

[app.commands.create_templategroup]
ro_groups = []
rw_groups = []

[app.commands.create_user]
usergroups = []

[app.commands.create_notification_user]
usergroups = []

[app.commands.export]
directory = "/path/to/data_dir/exports"
format = "json"
timestamps = false

[app.output]
format = "table"
color = true
paging = false

[logging]
enabled = true
log_level = "INFO"
log_file = "/path/to/logs_dir/zabbix-cli.log"

[plugins]

Options

api

Configuration for the Zabbix API.

url

URL of the Zabbix API host. Should not include /api_jsonrpc.php.

Type: str

Default: https:/zabbix.example.com

Example:

[api]
url = "https:/zabbix.example.com"

username

Username for the Zabbix API.

Type: str

Default: Admin

Example:

[api]
username = "Admin"

password

Password for user.

Type: str

Example:

[api]
password = "zabbix"

auth_token

API auth token.

Type: str

Example:

[api]
auth_token = "API_TOKEN_123"

verify_ssl

Verify SSL certificate of the Zabbix API host. Can also be a path to a CA bundle.

Type: Union | str

Default: true

Example:

[api]
verify_ssl = true

timeout

API request timeout in seconds.

Type: Optional

Example:

[api]
timeout = 0

app

Configuration for app defaults and behavior.

use_session_file

Use session file for storing API session IDs for persistent sessions.

Type: bool

Default: true

Example:

[app]
use_session_file = true

session_file

Path to session file.

Type: str

Default: /path/to/data_dir/.zabbix-cli_session.json

Example:

[app]
session_file = "/path/to/data_dir/.zabbix-cli_session.json"

use_auth_file

Look for user credentials stored in plaintext in auth file.

Type: bool

Default: true

Example:

[app]
use_auth_file = true

auth_file

Path to auth file.

Type: str

Default: /path/to/data_dir/.zabbix-cli_auth

Example:

[app]
auth_file = "/path/to/data_dir/.zabbix-cli_auth"

allow_insecure_auth_file

Type: bool

Default: true

Example:

[app]
allow_insecure_auth_file = true

history

Enable command history.

Type: bool

Default: true

Example:

[app]
history = true

history_file

Path to history file.

Type: str

Default: /path/to/data_dir/history

Example:

[app]
history_file = "/path/to/data_dir/history"

bulk_mode

Bulk mode error handling.

Type: str

Default: strict

Choices: strict, continue, skip

Example:

[app]
bulk_mode = "strict"

legacy_json_format

Use legacy JSON format.

Type: bool

Default: false

Example:

[app]
legacy_json_format = false

app.commands

Configuration of commands.

app.commands.create_host

Configuration for the create_host command.

create_interface

Create a DNS/IP interface for the host automatically.

Type: bool

Default: true

Example:

[app.commands.create_host]
create_interface = true

hostgroups

Default host group to add hosts to.

Type: list[str]

Example:

[app.commands.create_host]
hostgroups = []

app.commands.create_group

Shared config for create_hostgroup and create_templategroup commands.

Can be used to configure both commands at once. Has no effect if create_hostgroup or create_templategroup is set.

ro_groups

Default user groups to give read-only permissions to groups when --ro-groups option is not provided.

Type: list[str]

Example:

[app.commands.create_group]
ro_groups = []

rw_groups

Default user groups to give read/write permissions to groups when --rw-groups option is not provided.

Type: list[str]

Example:

[app.commands.create_group]
rw_groups = []

app.commands.create_hostgroup

Configuration for the create_hostgroup command.

ro_groups

Default user groups to give read-only permissions to groups when --ro-groups option is not provided.

Type: list[str]

Example:

[app.commands.create_hostgroup]
ro_groups = []

rw_groups

Default user groups to give read/write permissions to groups when --rw-groups option is not provided.

Type: list[str]

Example:

[app.commands.create_hostgroup]
rw_groups = []

app.commands.create_templategroup

Configuration for the create_templategroup command.

ro_groups

Default user groups to give read-only permissions to groups when --ro-groups option is not provided.

Type: list[str]

Example:

[app.commands.create_templategroup]
ro_groups = []

rw_groups

Default user groups to give read/write permissions to groups when --rw-groups option is not provided.

Type: list[str]

Example:

[app.commands.create_templategroup]
rw_groups = []

app.commands.create_user

Configuration for the create_user command.

usergroups

Default user groups to add users to when --usergroups is not provided.

Type: list[str]

Example:

[app.commands.create_user]
usergroups = []

app.commands.create_notification_user

Configuration for the create_notification_user command.

usergroups

Default user groups to add notification users to when --usergroups is not provided.

Type: list[str]

Example:

[app.commands.create_notification_user]
usergroups = []

app.commands.export

Shared configuration for export_configuration and import_configuration commands.

directory

Default directory to export files to.

Type: str

Default: /path/to/data_dir/exports

Example:

[app.commands.export]
directory = "/path/to/data_dir/exports"

format

Default export format.

Type: str

Default: json

Choices: xml, json, yaml, php

Example:

[app.commands.export]
format = "json"

timestamps

Include timestamps in exported filenames.

Type: bool

Default: false

Example:

[app.commands.export]
timestamps = false

app.output

Configuration for output formatting.

format

Default output format.

Type: str

Default: table

Choices: json, table

Example:

[app.output]
format = "table"

color

Use colors in terminal output.

Type: bool

Default: true

Example:

[app.output]
color = true

paging

Use paging in terminal output.

Type: bool

Default: false

Example:

[app.output]
paging = false

logging

Configuration for application logs.

enabled

Enable logging.

Type: bool

Default: true

Example:

[logging]
enabled = true

log_level

Log level.

Type: str

Default: INFO

Choices: DEBUG, INFO, WARN, WARNING, ERROR, CRITICAL, FATAL

Example:

[logging]
log_level = "INFO"

log_file

File for storing logs. Can be omitted to log to stderr (warning: NOISY).

Type: str

Default: /path/to/logs_dir/zabbix-cli.log

Example:

[logging]
log_file = "/path/to/logs_dir/zabbix-cli.log"