Hi all,
I'm trying to import the standard yaml templates from Zabbix after upgrade to 6.0.5. Since the web gui requires very many clicks to import all the templates, I wanted to use the API.
I've used the pyzabbix api (now in version 1.0, https://github.com/lukecyca/pyzabbix) for exporting templates in yaml or xml format. Using the pyzabbix api for import gives no error messages, a "True" result code fromt he API - but no changes visible in the web. Also, I cannot see anything in the zabbix server logs (at level 3), or zabbix audit-logs. I also tried to export an existing template to xml, change it, then re-import the xml, same result: no errors but also no changes.
I'm calling the pyzabbix like the below code after zapi login, taken from zabbix-gnomes ztmplimport.py and changed to py3 and yaml (it seems that code blocks is not allowing python indents, sorry about that).
Please advice how I can test this further. Anyone else seen the same thing?
Thanks,
Eirik
I'm trying to import the standard yaml templates from Zabbix after upgrade to 6.0.5. Since the web gui requires very many clicks to import all the templates, I wanted to use the API.
I've used the pyzabbix api (now in version 1.0, https://github.com/lukecyca/pyzabbix) for exporting templates in yaml or xml format. Using the pyzabbix api for import gives no error messages, a "True" result code fromt he API - but no changes visible in the web. Also, I cannot see anything in the zabbix server logs (at level 3), or zabbix audit-logs. I also tried to export an existing template to xml, change it, then re-import the xml, same result: no errors but also no changes.
I'm calling the pyzabbix like the below code after zapi login, taken from zabbix-gnomes ztmplimport.py and changed to py3 and yaml (it seems that code blocks is not allowing python indents, sorry about that).
Please advice how I can test this further. Anyone else seen the same thing?
Thanks,
Eirik
Code:
for template in args.templates:
Continue = True
if Continue:
try:
# open file for reading
with open(template,'r') as f:
yamlfile = f.read()
f.close()
except:
# If the file can't be opened, exit with error
error = "Error: Something went wrong when trying to read the file" + template
PrintError(error)
Continue = False
if Continue:
try:
# verify if the file is a valid YAML
yparse = yaml.safe_load(yamlfile)
except:
# If the file isn't a valid YAML, exit with error
error = "Error: YAML is not valid in " + template
PrintError(error)
Continue = False
if Continue:
try:
# Everything looks good, let's try to import
#result = zapi.configuration.Import(
result = zapi.confimport( confformat="yaml", rules=rules, source=yamlfile)
print(result)
except ZabbixAPIException as e:
print(e)
# Something went wrong with the API call or import
error = "Error: Something went wrong while importing " + \
template + "\n" + str(e) + str(sys.exc_info()[1][0])
PrintError(error)
Continue = False
if args.verbose:
print(("Succesfully imported " + template))
# And we're done...
Comment