diff options
author | Matt Woodson <mwoodson@gmail.com> | 2015-09-10 10:41:43 -0400 |
---|---|---|
committer | Matt Woodson <mwoodson@gmail.com> | 2015-09-10 10:41:43 -0400 |
commit | 6dfeaccd2a6966e5b4e43cc315f88018e268e084 (patch) | |
tree | 2d27dd0de8d497dbc4941e5229d241c06ae7b375 /roles/lib_zabbix/library/zbx_item.py | |
parent | 5ea59791dd5fd30664f076a3a768c34a99ff6af8 (diff) | |
parent | 4824691f00c04936da74ddfbbeb6e521ddb86d98 (diff) | |
download | openshift-6dfeaccd2a6966e5b4e43cc315f88018e268e084.tar.gz openshift-6dfeaccd2a6966e5b4e43cc315f88018e268e084.tar.bz2 openshift-6dfeaccd2a6966e5b4e43cc315f88018e268e084.tar.xz openshift-6dfeaccd2a6966e5b4e43cc315f88018e268e084.zip |
Merge pull request #566 from kwoodson/item_fix
Adding desc, units, and multiplier functionality to zabbix items.
Diffstat (limited to 'roles/lib_zabbix/library/zbx_item.py')
-rw-r--r-- | roles/lib_zabbix/library/zbx_item.py | 33 |
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 |