Ad Widget

Collapse

How to make work items prototypes with this example?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • franco.diaz
    Junior Member
    • Jun 2022
    • 2

    #1

    How to make work items prototypes with this example?

    Hi community

    I am working on a personal nash script for my OpenNebula. The script give me info about the cluster and a created in a way that LLD MACROS values be evaluated in other items prototype to gather the info I want.

    * In the OpenNebula orchestrator
    In the file '/etc/zabbix/zabbix_agent2.d/mychecks-one.conf'
    ```bash
    #
    ### Additional CHECKS
    ## These checks will be used by "HyperNode-ON" template
    # Get LLD MACROS from ON
    UserParameter=lld.one.key[*],sudo /etc/zabbix/scripts/agentd/mysh-one-lld.sh $1
    # Get info from ON
    UserParameter=onehost.key[*],sudo /etc/zabbix/scripts/agentd/mysh-one-bashone.sh HOST-KVM $1 $2
    ```

    Testing 'lld.one.key' for LLD MACROS:
    ```bash
    zabbix_get -s 127.0.0.1 -k lld.one.key[HOST-KVM]
    ```

    The output should look like this:
    ```bash
    [
    {"{#HOST-KVM_ID}":"5"},
    {"{#HOST-KVM_ID}":"4"},
    {"{#HOST-KVM_ID}":"3"}
    ]
    ```bash

    Suppose that HOST-KVM_ID=3, then:
    ```bash
    zabbix_get -s 127.0.0.1 -k onehost.key[3,ALLOCATED_MEM_B]
    ```

    The output should look like this:
    ```bash
    10737418240
    ```bash

    In other words...result is 10GB.

    My intention is to reuse those LLD MACROS in other checks using then as arguments, as one cluster have more than one host and of course, differentes IDs. But this is not working for me when I create the item prototype.

    * On Zabbix Server

    Creating the template *HyperNode-ON*:

    *Configuration > Templates > Create template*

    - Template
    - Template name: `HyperNode-ON`
    - Groups: `Templates`
    - Description: `This template is for OpenNebula in the orchestrators.
    [Made by Franco]`

    - Tags
    - Name: `Application`
    - Value: `OpenNebula`

    Creating the LLD rule for *HOST-KVM*

    *Configuration > Templates > HyperNode-ON > Discovery rules > Create discovery rule*

    - Discovery rule
    - Name: `opennebula: LLD for OpenNebula HOST-KVM
    - Type: `Zabbix agent`
    - Key: `lld.one.key[HOST-KVM]`
    - Update interval: `1h`
    - Keep lost resource period: `7d`
    - Description: `This LLD rule will gather the LLD Macros for OpenNebula HOST-KVM IDs defined in json format, from the orchestrator
    [Made by Franco]`


    Creating the item prototype for *HOST-KVM*

    *Configuration > Templates > HyperNode-ON > Discovery rules > opennebula: LLD for OpenNebula HOST-KVM "{#HOST-KVM_ID}" > Item prototypes > Create item prototype*

    - Item prototype
    - Name: `opennebula: ALLOCATED_MEM_B on HOST-KVM "{#HOST-KVM_ID}"`
    - Type: `Zabbix agent`
    - Key: `onehost.key[{#HOST-KVM_ID},ALLOCATED_MEM_B]`
    - Type of information: `Numeric (unsigned)`
    - Unit: `Bytes`
    - Update interval: `1d`
    - Tags
    - Name: `Application`
    - Value: `ALLOCATED_MEM_B on HOST-KVM [MyChecks]`
    - Description: `This will check for Allocated Memory on HOST-KVM.
    [Made by Franco]`


    Anyway...this is not working...after I linked the template to the host I want to use it...no data is received, no trace about this check. So...my question is if this proceedure I am doing is correct or not...because I have used LLD in other checks...but not as complex as this one. I would glad any help from community
  • franco.diaz
    Junior Member
    • Jun 2022
    • 2

    #2
    Fixed, I removing the key name for the LLD MACRO "HOST-KVM_ID" to "HOSTKVMID" will fix the problem.

    Comment

    Working...