|
1 |
| -# Zabbix Template Exporter |
| 1 | +# Zabbix Configuration Exporter |
| 2 | + |
| 3 | +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). |
| 4 | + |
| 5 | +It is capable of exporting the following: |
| 6 | + |
| 7 | +* Templates |
| 8 | +* Mediatypes |
| 9 | +* Hosts |
| 10 | +* Host Groups |
| 11 | +* Maps |
| 12 | +* Images |
| 13 | + |
| 14 | +Tested with Zabbix 5.4.x |
| 15 | + |
2 | 16 |
|
3 |
| -This tool connects to the Zabbix API. |
4 |
| -It retrieves all templates and stores them in individual XML files allowing you to re-use these templates and make backups of them. |
5 | 17 |
|
6 | 18 | ## Install
|
7 | 19 | Install the requirements:
|
| 20 | + |
8 | 21 | ```bash
|
9 | 22 | $ pip3 install -r requirements.txt
|
10 | 23 | ```
|
11 | 24 |
|
12 | 25 | ## Usage
|
13 | 26 | You can provide your credentials on the commandline:
|
| 27 | + |
14 | 28 | ```bash
|
15 |
| -usage: export.py [-h] [--server ZABBIX_HOST] [--username ZABBIX_USER] |
16 |
| - [--password ZABBIX_PASSWORD] [--format EXPORT_FORMAT] |
17 |
| - [--type EXPORT_TYPE] [--debug] |
| 29 | +usage: export.py [-h] [--server ZABBIX_HOST] [--token ZABBIX_API_TOKEN] [--format {xml,json,yaml}] [--type {templates,mediatypes,hosts,hostgroups,maps,images}] [--debug] |
18 | 30 |
|
19 | 31 | optional arguments:
|
20 | 32 | -h, --help show this help message and exit
|
21 | 33 | --server ZABBIX_HOST, -s ZABBIX_HOST
|
22 | 34 | Zabbix URL
|
23 |
| - --username ZABBIX_USER, -u ZABBIX_USER |
24 |
| - Zabbix user to connect with the API |
25 |
| - --password ZABBIX_PASSWORD, -p ZABBIX_PASSWORD |
26 |
| - Zabbix password for connecting to the API |
27 |
| - --format EXPORT_FORMAT, -f EXPORT_FORMAT |
| 35 | + --token ZABBIX_API_TOKEN |
| 36 | + Zabbix API token |
| 37 | + --format {xml,json,yaml}, -f {xml,json,yaml} |
28 | 38 | Export the templates as XML or JSON
|
29 |
| - --type EXPORT_TYPE, -t EXPORT_TYPE |
| 39 | + --type {templates,mediatypes,hosts,hostgroups,maps,images}, -t {templates,mediatypes,hosts,hostgroups,maps,images} |
30 | 40 | Export this type of entities
|
31 | 41 | --debug, -d Enable debugging output
|
| 42 | + |
| 43 | + |
32 | 44 | ```
|
33 | 45 |
|
34 | 46 | You can also configure your credentials globally and export these (e.g. in `.bashrc` or `.zshrc`) like this:
|
35 | 47 |
|
36 | 48 | ```bash
|
37 | 49 | export ZABBIX_HOST=https://zabbix.example.com
|
38 |
| -export ZABBIX_USER=youruser |
39 |
| -export ZABBIX_PASS=yourpass |
| 50 | +export ZABBIX_API_TOKEN=your-token |
40 | 51 | ```
|
41 | 52 |
|
42 |
| -Both `ZABBIX_USER` and `ZABBIX_PASS` can be provided as a string or a base64 string to prevent the passwords from being visible easily. |
43 |
| -The exporter automatically detects the content and will act accordingly. |
| 53 | +## Limitations |
44 | 54 |
|
| 55 | +* Exporting auto-discovered hosts results in an empty file, because the Zabbix API does not provide this information. |
45 | 56 |
|
46 | 57 | ## License
|
47 |
| -The MIT License (MIT). Please see the [license file](https://github.com/syphernl/zabbix-template-exporter/blob/master/LICENSE) for more information. |
| 58 | +The MIT License (MIT). Please see the [license file](./blob/master/LICENSE) for more information. |
0 commit comments