community.zabbix icon indicating copy to clipboard operation
community.zabbix copied to clipboard

Module: Implementation of zabbix_item

Open ljvdhooft opened this issue 2 months ago • 7 comments

SUMMARY

This implements a new module, zabbix_item. This module controls the items contained by hosts.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

zabbix_item

ADDITIONAL INFORMATION
- name: Create a new item or rewrite an existing item's info
  community.zabbix.zabbix_item:
    host_name: ExampleHost
    item_name: ExampleItem
    key: ExampleItem
    description: My ExampleItem Description
    type: zabbix_internal
    value_type: text
    status: enabled
    state: present
    tags:
      - tag: ExampleItemTag
        value: ExampleTagValue
      - tag: ExampleItemTag2
        value: ExampleTagValue

ljvdhooft avatar Apr 24 '24 10:04 ljvdhooft

Regarding Issue #1203 "Request: Implement item module"

ljvdhooft avatar Apr 24 '24 10:04 ljvdhooft

Hi, not sure why tests failed. Ran them again with a Ansible-docker container closer to the actions runner, all tests passed successfully..

ljvdhooft avatar Apr 25 '24 17:04 ljvdhooft

Looks like they may have just died....restarted

pyrodie18 avatar Apr 26 '24 00:04 pyrodie18

@ljvdhooft you're getting an error during the test.

2024-04-28T03:56:11.7121231Z TASK [test_zabbix_item : test: change type simple_check] *********************** 2024-04-28T03:56:12.7610134Z [0;31mfatal: [testhost]: FAILED! => {"changed": false, "msg": "connection error occurred: REST API returned {'code': -32602, 'message': 'Invalid params.', 'data': 'No interface found.'} when sending {\"jsonrpc\": \"2.0\", \"method\": \"item.update\", \"id\": \"d34c2c4d-7ee0-47dc-8e43-5d75d265b13e\", \"params\": {\"itemid\": \"44635\", \"status\": 0, \"name\": \"ExampleItem1\", \"type\": 3, \"delay\": \"10s\", \"authtype\": 0, \"status_codes\": \"200\", \"tags\": [], \"preprocessing\": []}, \"auth\": \"d6b5801300b78af276a9524821568642\"}"}[0m

pyrodie18 avatar Apr 30 '24 02:04 pyrodie18

This probably has to do with some parameters that are not suitable for all item types. This makes testing a bit difficult. The way it is setup right now is that it makes only one item and changes the type of that item until all items were in use. However, by not setting a specific parameter, this remains set in the Zabbix config making it unable to change to another type of item.

I think it would make more sense to make a new item for each type, since that would be the more practical case too. Would tests like this qualify for a PR?

ljvdhooft avatar May 03 '24 05:05 ljvdhooft

That is totally ok.

pyrodie18 avatar May 03 '24 09:05 pyrodie18