-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from syphernl/feat/refactor
refactor to support all configuration exports
- Loading branch information
Showing
5 changed files
with
238 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
*.xml | ||
*.json | ||
*.json | ||
*.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,58 @@ | ||
# Zabbix Template Exporter | ||
# Zabbix Configuration Exporter | ||
|
||
This tool connects to the Zabbix API and retrieves configuration and stores this in individual files, allowing you to re-use these templates and make backups of them (e.g. by adding them to version control). | ||
|
||
It is capable of exporting the following: | ||
|
||
* Templates | ||
* Mediatypes | ||
* Hosts | ||
* Host Groups | ||
* Maps | ||
* Images | ||
|
||
Tested with Zabbix 5.4.x | ||
|
||
|
||
This tool connects to the Zabbix API. | ||
It retrieves all templates and stores them in individual XML files allowing you to re-use these templates and make backups of them. | ||
|
||
## Install | ||
Install the requirements: | ||
|
||
```bash | ||
$ pip3 install -r requirements.txt | ||
``` | ||
|
||
## Usage | ||
You can provide your credentials on the commandline: | ||
|
||
```bash | ||
usage: export.py [-h] [--server ZABBIX_HOST] [--username ZABBIX_USER] | ||
[--password ZABBIX_PASSWORD] [--format EXPORT_FORMAT] | ||
[--type EXPORT_TYPE] [--debug] | ||
usage: export.py [-h] [--server ZABBIX_HOST] [--token ZABBIX_API_TOKEN] [--format {xml,json,yaml}] [--type {templates,mediatypes,hosts,hostgroups,maps,images}] [--debug] | ||
|
||
optional arguments: | ||
-h, --help show this help message and exit | ||
--server ZABBIX_HOST, -s ZABBIX_HOST | ||
Zabbix URL | ||
--username ZABBIX_USER, -u ZABBIX_USER | ||
Zabbix user to connect with the API | ||
--password ZABBIX_PASSWORD, -p ZABBIX_PASSWORD | ||
Zabbix password for connecting to the API | ||
--format EXPORT_FORMAT, -f EXPORT_FORMAT | ||
--token ZABBIX_API_TOKEN | ||
Zabbix API token | ||
--format {xml,json,yaml}, -f {xml,json,yaml} | ||
Export the templates as XML or JSON | ||
--type EXPORT_TYPE, -t EXPORT_TYPE | ||
--type {templates,mediatypes,hosts,hostgroups,maps,images}, -t {templates,mediatypes,hosts,hostgroups,maps,images} | ||
Export this type of entities | ||
--debug, -d Enable debugging output | ||
|
||
|
||
``` | ||
|
||
You can also configure your credentials globally and export these (e.g. in `.bashrc` or `.zshrc`) like this: | ||
|
||
```bash | ||
export ZABBIX_HOST=https://zabbix.example.com | ||
export ZABBIX_USER=youruser | ||
export ZABBIX_PASS=yourpass | ||
export ZABBIX_API_TOKEN=your-token | ||
``` | ||
|
||
Both `ZABBIX_USER` and `ZABBIX_PASS` can be provided as a string or a base64 string to prevent the passwords from being visible easily. | ||
The exporter automatically detects the content and will act accordingly. | ||
## Limitations | ||
|
||
* Exporting auto-discovered hosts results in an empty file, because the Zabbix API does not provide this information. | ||
|
||
## License | ||
The MIT License (MIT). Please see the [license file](https://github.com/syphernl/zabbix-template-exporter/blob/master/LICENSE) for more information. | ||
The MIT License (MIT). Please see the [license file](./blob/master/LICENSE) for more information. |
Oops, something went wrong.