本文整理汇总了Python中pyzabbix.ZabbixAPI.confimport方法的典型用法代码示例。如果您正苦于以下问题:Python ZabbixAPI.confimport方法的具体用法?Python ZabbixAPI.confimport怎么用?Python ZabbixAPI.confimport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyzabbix.ZabbixAPI
的用法示例。
在下文中一共展示了ZabbixAPI.confimport方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from pyzabbix import ZabbixAPI [as 别名]
# 或者: from pyzabbix.ZabbixAPI import confimport [as 别名]
except OSError as e:
print e
sys.exit(1)
for i in templateFiles:
try:
f = open("/tmp/zabbix_templates/"+i,'r')
except IOError as e:
print e
sys.exit(1)
templatexml = f.read()
f.close()
try:
zapi.confimport(format='xml',source=templatexml,rules={'applications':{'createMissing':'true'}, 'discoveryRules':{'createMissing':'true'}, 'graphs':{'createMissing':'true'},'groups':{'createMissing':'true'}, 'hosts':{'createMissing':'true'}, 'images':{'createMissing':'true'}, 'items':{'createMissing':'true'},'maps':{'createMissing':'true'}, 'screens':{'createMissing':'true'}, 'templates':{'createMissing':'true'}, 'templateLinkage':{'createMissing':'true'}, 'templateScreens':{'createMissing':'true'}, 'triggers':{'createMissing':'true'} })
except ZabbixAPIException as e:
print(e)
sys.exit(1)
# Get host group IDs
hostgroups = zapi.hostgroup.get(output='extend')
# build hostgroups dictionary
for t in hostgroups:
gd[t['name']] = t['groupid']
# get template IDs
templates = zapi.template.get(output='extend')
示例2: print
# 需要导入模块: from pyzabbix import ZabbixAPI [as 别名]
# 或者: from pyzabbix.ZabbixAPI import confimport [as 别名]
},
'valueMaps': {
'createMissing': True,
'updateExisting': True
},
}
if os.path.isdir(path):
#path = path/*.xml
files = glob.glob(path+'/*.xml')
for file in files:
print(file)
with open(file, 'r') as f:
template = f.read()
try:
zapi.confimport('xml', template, rules)
except ZabbixAPIException as e:
print(e)
print('')
elif os.path.isfile(path):
files = glob.glob(path)
for file in files:
with open(file, 'r') as f:
template = f.read()
try:
zapi.confimport('xml', template, rules)
except ZabbixAPIException as e:
print(e)
else:
print('I need a xml file')
示例3: open
# 需要导入模块: from pyzabbix import ZabbixAPI [as 别名]
# 或者: from pyzabbix.ZabbixAPI import confimport [as 别名]
# Login to the Zabbix API
zapi.login("admin", "zabbix")
rules = {
"applications": {"createMissing": "true", "updateExisting": "true"},
"discoveryRules": {"createMissing": "true", "updateExisting": "true"},
"graphs": {"createMissing": "true", "updateExisting": "true"},
"groups": {"createMissing": "true"},
"hosts": {"createMissing": "true", "updateExisting": "true"},
"images": {"createMissing": "true", "updateExisting": "true"},
"items": {"createMissing": "true", "updateExisting": "true"},
"maps": {"createMissing": "true", "updateExisting": "true"},
"screens": {"createMissing": "true", "updateExisting": "true"},
"templateLinkage": {"createMissing": "true", "updateExisting": "true"},
"templates": {"createMissing": "true", "updateExisting": "true"},
"templateScreens": {"createMissing": "true", "updateExisting": "true"},
"triggers": {"createMissing": "true", "updateExisting": "true"},
}
path = "./templates/*.xml"
files = glob.glob(path)
for file in files:
with open(file, "r") as f:
template = f.read()
try:
zapi.confimport("xml", template, rules)
except ZabbixAPIException as e:
print(e)