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

A more convoluted way of creating a default config file in the default location would be:

zabbix-cli sample_config > "$(zabbix-cli open --path config)/zabbix-cli.toml"

The created config looks like this:

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

[app]
default_hostgroups = [
    "All-hosts",
]
default_admin_usergroups = []
default_create_user_usergroups = []
default_notification_users_usergroups = [
    "All-notification-users",
]
export_directory = "/path/to/data_dir/exports"
export_format = "json"
export_timestamps = false
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"
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.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

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.

Type: bool

Default: True

Example:

[api]
verify_ssl = true

timeout

API request timeout in seconds.

Type: int

Example:

[api]
timeout = 0

app

Configuration for app defaults and behavior.

default_hostgroups

Default host groups to assign to hosts created with create_host. Hosts are always added to these groups unless --no-default-hostgroup is provided.

Type: list[str]

Default: ['All-hosts']

Example:

[app]
default_hostgroups = [
    "All-hosts",
]

default_admin_usergroups

Default user groups to give read/write permissions to groups created with create_hostgroup and create_templategroup when --rw-groups option is not provided.

Type: list[str]

Example:

[app]
default_admin_usergroups = []

default_create_user_usergroups

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

Type: list[str]

Example:

[app]
default_create_user_usergroups = []

default_notification_users_usergroups

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

Type: list[str]

Default: ['All-notification-users']

Example:

[app]
default_notification_users_usergroups = [
    "All-notification-users",
]

export_directory

Default directory to export files to.

Type: str

Default: /path/to/data_dir/exports

Example:

[app]
export_directory = "/path/to/data_dir/exports"

export_format

Default export format.

Type: str

Default: json

Choices: xml, json, yaml, php

Example:

[app]
export_format = "json"

export_timestamps

Include timestamps in exported filenames.

Type: bool

Example:

[app]
export_timestamps = false

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"

auth_token_file

Path to legacy auth token file.

Type: str

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

Example:

[app]
auth_token_file = "/path/to/data_dir/.zabbix-cli_auth_token"

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

Example:

[app]
legacy_json_format = false

app.output

Configuration for output formatting.

format

Default output format.

Type: str

Default: table

Choices: csv, 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

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: Path

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

Example:

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