summaryrefslogtreecommitdiffstats
path: root/roles/lib_zabbix/library
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-09-08 15:55:45 -0400
committerKenny Woodson <kwoodson@redhat.com>2015-09-08 15:55:45 -0400
commit4824691f00c04936da74ddfbbeb6e521ddb86d98 (patch)
treef8feafe7c85cf2054d9959d0b62e429413037174 /roles/lib_zabbix/library
parent63ad6b61144cf610a813f2022bcbab5ddacf729a (diff)
downloadopenshift-4824691f00c04936da74ddfbbeb6e521ddb86d98.tar.gz
openshift-4824691f00c04936da74ddfbbeb6e521ddb86d98.tar.bz2
openshift-4824691f00c04936da74ddfbbeb6e521ddb86d98.tar.xz
openshift-4824691f00c04936da74ddfbbeb6e521ddb86d98.zip
Adding desc, multiplier, and units to zabbix item
Diffstat (limited to 'roles/lib_zabbix/library')
-rw-r--r--roles/lib_zabbix/library/zbx_item.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/roles/lib_zabbix/library/zbx_item.py b/roles/lib_zabbix/library/zbx_item.py
index 388db31b9..11e3c7b2b 100644
--- a/roles/lib_zabbix/library/zbx_item.py
+++ b/roles/lib_zabbix/library/zbx_item.py
@@ -88,6 +88,23 @@ def get_template_id(zapi, template_name):
return template_ids, app_ids
+def get_multiplier(inval):
+ ''' Determine the multiplier
+ '''
+ if inval == None or inval == '':
+ return None, None
+
+ rval = None
+ try:
+ rval = int(inval)
+ except ValueError:
+ pass
+
+ if rval:
+ return rval, True
+
+ return rval, False
+
# The branches are needed for CRUD and error handling
# pylint: disable=too-many-branches
def main():
@@ -106,6 +123,9 @@ def main():
template_name=dict(default=None, type='str'),
zabbix_type=dict(default=2, type='int'),
value_type=dict(default='int', type='str'),
+ multiplier=dict(default=None, type='str'),
+ description=dict(default=None, type='str'),
+ units=dict(default=None, type='str'),
applications=dict(default=None, type='list'),
state=dict(default='present', type='str'),
),
@@ -137,11 +157,15 @@ def main():
'templateids': templateid,
})
- # Get
+ #******#
+ # GET
+ #******#
if state == 'list':
module.exit_json(changed=False, results=content['result'], state="list")
- # Delete
+ #******#
+ # DELETE
+ #******#
if state == 'absent':
if not exists(content):
module.exit_json(changed=False, state="absent")
@@ -152,12 +176,17 @@ def main():
# Create and Update
if state == 'present':
+ formula, use_multiplier = get_multiplier(module.params['multiplier'])
params = {'name': module.params.get('name', module.params['key']),
'key_': module.params['key'],
'hostid': templateid[0],
'type': module.params['zabbix_type'],
'value_type': get_value_type(module.params['value_type']),
'applications': get_app_ids(module.params['applications'], app_name_ids),
+ 'formula': formula,
+ 'multiplier': use_multiplier,
+ 'description': module.params['description'],
+ 'units': module.params['units'],
}
# Remove any None valued params