Skip to content

Commit d2d4158

Browse files
committed
refactor to support all configuration exports
1 parent 04e93ae commit d2d4158

File tree

5 files changed

+238
-155
lines changed

5 files changed

+238
-155
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22
*.xml
3-
*.json
3+
*.json
4+
*.yaml

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018-2020 Frank Klaassen
3+
Copyright (c) 2018-2021 Frank Klaassen
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+28-17
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,58 @@
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+
216

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.
517

618
## Install
719
Install the requirements:
20+
821
```bash
922
$ pip3 install -r requirements.txt
1023
```
1124

1225
## Usage
1326
You can provide your credentials on the commandline:
27+
1428
```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]
1830

1931
optional arguments:
2032
-h, --help show this help message and exit
2133
--server ZABBIX_HOST, -s ZABBIX_HOST
2234
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}
2838
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}
3040
Export this type of entities
3141
--debug, -d Enable debugging output
42+
43+
3244
```
3345

3446
You can also configure your credentials globally and export these (e.g. in `.bashrc` or `.zshrc`) like this:
3547

3648
```bash
3749
export ZABBIX_HOST=https://zabbix.example.com
38-
export ZABBIX_USER=youruser
39-
export ZABBIX_PASS=yourpass
50+
export ZABBIX_API_TOKEN=your-token
4051
```
4152

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
4454

55+
* Exporting auto-discovered hosts results in an empty file, because the Zabbix API does not provide this information.
4556

4657
## 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

Comments
 (0)