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:
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
:
To overwrite an existing configuration file, use the --overwrite
option:
Config directory
The default configuration directory can be opened in the system's file manager with the open
command:
To print the path instead of opening it, use the --path
option:
Show config
The contents of the current configuration file can be displayed with 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:
A more convoluted way of creating a default config file in the default location would be:
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:
username
Username for the Zabbix API.
Type: str
Default: Admin
Example:
password
Password for user.
Type: str
Example:
auth_token
API auth token.
Type: str
Example:
verify_ssl
Verify SSL certificate of the Zabbix API host.
Type: bool
Default: True
Example:
timeout
API request timeout in seconds.
Type: int
Example:
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:
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:
default_create_user_usergroups
Default user groups to add users created with create_user
to when --usergroups
is not provided.
Type: list[str]
Example:
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:
export_directory
Default directory to export files to.
Type: str
Default: /path/to/data_dir/exports
Example:
export_format
Default export format.
Type: str
Default: json
Choices: xml, json, yaml, php
Example:
export_timestamps
Include timestamps in exported filenames.
Type: bool
Example:
use_session_file
Use session file for storing API session IDs for persistent sessions.
Type: bool
Default: True
Example:
session_file
Path to session file.
Type: str
Default: /path/to/data_dir/.zabbix-cli_session.json
Example:
auth_token_file
Path to legacy auth token file.
Type: str
Default: /path/to/data_dir/.zabbix-cli_auth_token
Example:
auth_file
Path to auth file.
Type: str
Default: /path/to/data_dir/.zabbix-cli_auth
Example:
allow_insecure_auth_file
Type: bool
Default: True
Example:
history
Enable command history.
Type: bool
Default: True
Example:
history_file
Path to history file.
Type: str
Default: /path/to/data_dir/history
Example:
bulk_mode
Bulk mode error handling.
Type: str
Default: strict
Choices: strict, continue, skip
Example:
legacy_json_format
Use legacy JSON format.
Type: bool
Example:
app.output
Configuration for output formatting.
format
Default output format.
Type: str
Default: table
Choices: csv, json, table
Example:
color
Use colors in terminal output.
Type: bool
Default: True
Example:
paging
Use paging in terminal output.
Type: bool
Example:
logging
Configuration for application logs.
enabled
Enable logging.
Type: bool
Default: True
Example:
log_level
Log level.
Type: str
Default: INFO
Choices: DEBUG, INFO, WARN, WARNING, ERROR, CRITICAL, FATAL
Example:
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: