forked from zabbix-tools/zabbix-template-converter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38c66dd
commit 8c0d679
Showing
7 changed files
with
191 additions
and
149 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 +1,4 @@ | ||
*.xml | ||
*.egg-info/ | ||
build/ | ||
dist/ |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
all: dist | ||
|
||
dist: | ||
python setup.py sdist | ||
|
||
install: | ||
pip install --upgrade . | ||
|
||
clean: | ||
rm -vrf \ | ||
zabbix_template_converter.egg-info \ | ||
build \ | ||
dist | ||
|
||
upload: | ||
python setup.py sdist upload | ||
|
||
.PHONY: all dist install clean upload |
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
zabbix-template-converter | ||
========================= | ||
|
||
This Python script aims to resolve compatability issues when migrating Zabbix | ||
template XML files between versions of Zabbix. For example, you may wish to | ||
import a Zabbix v3.2 template into Zabbix v2.0. | ||
|
||
The script works by applying conversion rules to a template, which manipulate | ||
the template XML to match the desired Zabbix version template format. | ||
|
||
__WARNING__: This project is still under active development and not ready for | ||
release. | ||
|
||
.. code-block:: shell | ||
$ zabbix-template-convertor -h | ||
usage: zabbix-template-convertor [-h] [-v] -o X.Y.Z [-s] file | ||
Migrate Zabbix templates between versions | ||
positional arguments: | ||
file Zabbix template XML file | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
-v, --version show program's version number and exit | ||
-o X.Y.Z, --output-version X.Y.Z | ||
target Zabbix version | ||
-s, --squash-value-maps | ||
remove references to value maps for versions older | ||
than 3.0.0 | ||
Examples | ||
-------- | ||
To convert a Zabbix 3.2 template for import into v2.0: | ||
.. code-block:: shell | ||
$ zabbix-template-convertor -o 2.0 my_template.xml > my_template-2.0.xml | ||
A number of transformations will take place. For example, Discovery Rule | ||
filters will be downgraded from the multiple-filter format introduced in Zabbix 2.4, to a single filter expression as follows: | ||
.. code-block:: xml | ||
<filter> | ||
<evaltype>0</evaltype> | ||
<formula/> | ||
<conditions> | ||
<condition> | ||
<macro>{#IFNAME}</macro> | ||
<value>@Network interfaces for discovery</value> | ||
<operator>8</operator> | ||
<formulaid>A</formulaid> | ||
</condition> | ||
</conditions> | ||
</filter> | ||
Becomes: | ||
.. code-block:: xml | ||
<filter>{#IFNAME}:@Network interfaces for discovery</filter> | ||
Coverage | ||
-------- | ||
This project relies heavily on the community to report incompatability problems | ||
when importing templates. | ||
__Please raise an issue__ if you find a template that won't import after being | ||
converted. Be sure to include the error messages and template file. | ||
|
||
Over time, as conversion rules are added, the script should become more comprehensive, and more reliable. | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
Copy the script file to your bin directory and add the executable flag: | ||
|
||
.. code-block:: shell | ||
$ curl -Lo /bin/zabbix-template-convertor \ | ||
https://raw.githubusercontent.com/cavaliercoder/zabbix-template-convertor/master/zabbix-template-convertor | ||
$ chmod +x /bin/zabbix-template-convertor |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
distutils/setuptools install script. | ||
""" | ||
|
||
import os | ||
import re | ||
|
||
from setuptools import setup | ||
|
||
ROOT = os.path.dirname(__file__) | ||
VERSION_RE = re.compile(r'''__version__ = ['"]([0-9.]+)['"]''') | ||
|
||
def get_version(): | ||
""" | ||
get_version reads the version info from bin/vpc-free:__version__ | ||
""" | ||
|
||
init = open(os.path.join(ROOT, 'bin', 'zabbix-template-converter')).read() | ||
return VERSION_RE.search(init).group(1) | ||
|
||
setup(name='zabbix-template-converter', | ||
version=get_version(), | ||
description='Convert Zabbix templates to older versions.', | ||
long_description=open('README.rst').read(), | ||
url='http://github.com/cavaliercoder/zabbix-template-converter', | ||
author='Ryan Armstrong', | ||
author_email='[email protected]', | ||
license='GNU Public License v3.0', | ||
scripts=['bin/zabbix-template-converter']) |