diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2015-10-07 16:56:46 -0400 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2015-10-07 17:00:33 -0400 |
commit | aacf1839073ebd40ea0e379abeac5754b0656987 (patch) | |
tree | 8a33522334f6374662d521303821e002b310145f /roles/lib_zabbix/library | |
parent | 3bd2ebe0ecae022a027b1d4af7e4820786415cf2 (diff) | |
download | openshift-aacf1839073ebd40ea0e379abeac5754b0656987.tar.gz openshift-aacf1839073ebd40ea0e379abeac5754b0656987.tar.bz2 openshift-aacf1839073ebd40ea0e379abeac5754b0656987.tar.xz openshift-aacf1839073ebd40ea0e379abeac5754b0656987.zip |
Zabbix server template added
Diffstat (limited to 'roles/lib_zabbix/library')
-rw-r--r-- | roles/lib_zabbix/library/zbx_trigger.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/roles/lib_zabbix/library/zbx_trigger.py b/roles/lib_zabbix/library/zbx_trigger.py index 21d0fcfd2..ab7731faa 100644 --- a/roles/lib_zabbix/library/zbx_trigger.py +++ b/roles/lib_zabbix/library/zbx_trigger.py @@ -86,6 +86,24 @@ def get_trigger_status(inc_status): return r_status +def get_template_id(zapi, template_name): + ''' + get related templates + ''' + template_ids = [] + app_ids = {} + # Fetch templates by name + content = zapi.get_content('template', + 'get', + {'search': {'host': template_name}, + 'selectApplications': ['applicationid', 'name']}) + if content.has_key('result'): + template_ids.append(content['result'][0]['templateid']) + for app in content['result'][0]['applications']: + app_ids[app['name']] = app['applicationid'] + + return template_ids, app_ids + def main(): ''' Create a trigger in zabbix @@ -117,6 +135,7 @@ def main(): url=dict(default=None, type='str'), status=dict(default=None, type='str'), state=dict(default='present', type='str'), + template_name=dict(default=None, type='str'), ), #supports_check_mode=True ) @@ -132,11 +151,16 @@ def main(): state = module.params['state'] tname = module.params['name'] + templateid = None + if module.params['template_name']: + templateid, _ = get_template_id(zapi, module.params['template_name']) + content = zapi.get_content(zbx_class_name, 'get', {'filter': {'description': tname}, 'expandExpression': True, 'selectDependencies': 'triggerid', + 'templateids': templateid, }) # Get |