Ad Widget

Collapse

Zabbix API import not works

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crillus
    Junior Member
    • Jun 2013
    • 20

    #1

    Zabbix API import not works

    hello guys !

    I use Zabbix 3.0.0
    I try to use the Zabbix API to import several templates.

    Code:
    from pyzabbix import ZabbixAPI
    
    zapi = ZabbixAPI("http://127.0.0.1/zabbix")
    zapi.login("Admin", "mypassword")
    
    with open('/appli/exploit/zbx_export_templates.xml', 'r') as myfile:
        data=myfile.read().replace('\n', '').replace('  ', '')
    
    ret = zapi.confimport(format='xml', source=data)
    
    
    print ret

    According to the "ret" value the confimport works successfully (it returns True), however nothing appears in the web GUI. I give you the template in attached files, could you tell me where the problem is ?

    Thank you for your answer.
    Attached Files
  • crillus
    Junior Member
    • Jun 2013
    • 20

    #2
    Hello guys,

    Sorry for the delay, I finally found the solution, but I tjink there is something to be done regarding to the Zabbix API (a bug maybe)

    I've defined some rules exactly the same as what we can see using the UI when you import a template and it works now

    Code:
    rules_s = {'groups':{'createMissing':'true'},'templates':{'createMissing':'true'},'templateScreens':{'createMissing':'true'},'templateLinkage':{'createMissing':'true'},'items':{'createMissing':'true'},'discoveryRules':{'createMissing':'true'},'applications':{'createMissing':'true'},     'triggers':{'createMissing':'true'}, 'graphs':{'createMissing':'true'}, 'valueMaps':{'createMissing':'true'}}
    
    ret = zapi.confimport(format='xml', source=data, rules=rules_s)
    Great !

    However I insist : confimport should not return success if the import fails due to a rules error. Maybe there is a way to improve the Zabbix API

    Comment

    Working...