Ad Widget

Collapse

Create graph prototypes in discovery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jstrayer
    Junior Member
    • Oct 2013
    • 1

    #1

    Create graph prototypes in discovery

    I get the error message: "Cannot create item: item with the same key "icmppingloss[{#IPADDR},10,100,64,64]" already exists.

    The items show up, but if I try to make graph prototypes, they do not work and I think it is related to the error.

    The thing is I am not using it twice so I don't understand the error. Here is some information on my discovery rule:

    In the Discovery rule, i use the key site.ip.dscovery

    for item prototypes, I use icmppingloss[{#IPADDR},10,100,64,64]
    and will use #IPADDR1 and #IPADDR2

    site-ip.sh (converts to JSON format.. the awk statements get me ip addresses)

    Code:
    #!/bin/bash
    
    SITEIPADDR=`ifconfig -a | grep 172.16 | awk '{gsub("addr:", "");print $2}'`
    TUNNEL1ADDR=`ifconfig -a | grep 10.10 | awk '{gsub("addr:", "");print $2}' | awk 'FNR == 1 {print}'`
    TUNNEL2ADDR=`ifconfig -a | grep 10.10 | awk '{gsub("addr:", "");print $2}' | awk 'FNR == 2 {print}'`
    
    echo -en "{\n"
    echo -en "\t\"data\":[\n\n"
    
    echo -en "\t{"
    echo -en "\"{#IPADDR}\":\"$SITEIPADDR\""
    echo -en "},\n";
    
    echo -en "\t{"
    echo -en "\"{#IPADDR1}\":\"$TUNNEL1ADDR\""
    echo -en "},\n";
    
    echo -en "\t{"
    echo -en "\"{#IPADDR2}\":\"$TUNNEL2ADDR\""
    echo -en "},\n";
    
    echo -en "\n\t]\n"
    echo -en "}\n"
    site-ip.conf
    Code:
    UserParameter=site.ip.discovery,/etc/zabbix/site-ip.sh
  • steveboyson
    Senior Member
    • Jul 2013
    • 582

    #2
    I think, each and every JSON record needs to have the same parameters in the output stream.

    So, instead (in Pseudocode)
    {#IPADDR1} : {VAL1}
    {#IPADDR2} :{VAL2}
    {#IPADDR3} : {VAL3}

    have it:
    { {#IPADDR}: {1}, {#TYPE} = {REGULAR_IP}, {#VALUE} = {"x.x.x.x"} },
    { {#IPADDR}: {2}, {#TYPE} = {TUNNEL_IP1}, {#VALUE} = {"y.y.y.y"} },
    { {#IPADDR}: {3}, {#TYPE} = {TUNNEL_IP2}, {#VALUE} = {"z.z.z.z"} }

    Note that #IPADDR, #TYPE ad #VALUE params appear identical for each "record".

    (I did not check the correct settings of the {})

    Comment

    Working...