diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2015-10-26 16:51:53 -0400 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2015-10-26 16:51:53 -0400 |
commit | 593d2b0c296a9f264f0f0ae927f468c978e30176 (patch) | |
tree | aeb028f8a75ff3f56e4b8277f80eda30b8dc1e8f /roles/lib_zabbix | |
parent | 4836ed6801b3f841ac3b3bab589c550c35179591 (diff) | |
parent | 5800ca35fd005957cb325165ac7d109d3892ea28 (diff) | |
download | openshift-593d2b0c296a9f264f0f0ae927f468c978e30176.tar.gz openshift-593d2b0c296a9f264f0f0ae927f468c978e30176.tar.bz2 openshift-593d2b0c296a9f264f0f0ae927f468c978e30176.tar.xz openshift-593d2b0c296a9f264f0f0ae927f468c978e30176.zip |
Merge pull request #744 from kwoodson/zbxztype
Adding zabbix_type to zbx_items and fixing zabbix agent items
Diffstat (limited to 'roles/lib_zabbix')
-rw-r--r-- | roles/lib_zabbix/library/zbx_item.py | 37 | ||||
-rw-r--r-- | roles/lib_zabbix/tasks/create_template.yml | 2 |
2 files changed, 36 insertions, 3 deletions
diff --git a/roles/lib_zabbix/library/zbx_item.py b/roles/lib_zabbix/library/zbx_item.py index 2cd00dd27..5dc3cff9b 100644 --- a/roles/lib_zabbix/library/zbx_item.py +++ b/roles/lib_zabbix/library/zbx_item.py @@ -107,6 +107,39 @@ def get_multiplier(inval): return rval, 0 +def get_zabbix_type(ztype): + ''' + Determine which type of discoverrule this is + ''' + _types = {'agent': 0, + 'SNMPv1': 1, + 'trapper': 2, + 'simple': 3, + 'SNMPv2': 4, + 'internal': 5, + 'SNMPv3': 6, + 'active': 7, + 'aggregate': 8, + 'web': 9, + 'external': 10, + 'database monitor': 11, + 'ipmi': 12, + 'ssh': 13, + 'telnet': 14, + 'calculated': 15, + 'JMX': 16, + 'SNMP trap': 17, + } + + for typ in _types.keys(): + if ztype in typ or ztype == typ: + _vtype = _types[typ] + break + else: + _vtype = 2 + + return _vtype + # The branches are needed for CRUD and error handling # pylint: disable=too-many-branches def main(): @@ -123,7 +156,7 @@ def main(): name=dict(default=None, type='str'), key=dict(default=None, type='str'), template_name=dict(default=None, type='str'), - zabbix_type=dict(default=2, type='int'), + zabbix_type=dict(default='trapper', type='str'), value_type=dict(default='int', type='str'), interval=dict(default=60, type='int'), delta=dict(default=0, type='int'), @@ -184,7 +217,7 @@ def main(): params = {'name': module.params.get('name', module.params['key']), 'key_': module.params['key'], 'hostid': templateid[0], - 'type': module.params['zabbix_type'], + 'type': get_zabbix_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, diff --git a/roles/lib_zabbix/tasks/create_template.yml b/roles/lib_zabbix/tasks/create_template.yml index d5168a9f4..ac9cf756b 100644 --- a/roles/lib_zabbix/tasks/create_template.yml +++ b/roles/lib_zabbix/tasks/create_template.yml @@ -38,7 +38,7 @@ units: "{{ item.units | default('', True) }}" template_name: "{{ template.name }}" applications: "{{ item.applications }}" - zabbix_type: "{{ item.zabbix_type | default(2, True) }}" + zabbix_type: "{{ item.zabbix_type | default('trapper') }}" interval: "{{ item.interval | default(60, True) }}" delta: "{{ item.delta | default(0, True) }}" with_items: template.zitems |