Ad Widget

Collapse

Redis by Agent 2 Template only partially detecting multiple instances of Redis

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alexw-z
    Member
    • Dec 2021
    • 36

    #1

    Redis by Agent 2 Template only partially detecting multiple instances of Redis

    I have the Redis by Agent 2 Template installed on my server. The majority of items work, but my Redis boxes have multiple instances of
    I have a UserParameter for LLD Discovery configured and linked to a shell script:

    Code:
    UserParameter=redis.discovery[*],/etc/zabbix/scripts/discovery_redis.sh
    
    #!/bin/bash
    redisconf=$(ls /etc/redis/redis*.conf)
    first=1
    
    echo '{
    "data":['
    for redis in $redisconf
    do
    if (( $first != 1))
    then
    echo ","
    fi
    name=$(basename $redis|sed 's/.conf//g')
    port=$(grep port $redis|cut -f2 -d\ )
    echo -n "{ \"{#REDISNAME}\":\"$name\", \"{#REDISPORT}\":\"$port\" }"
    first=0
    done
    echo ']
    }'
    This gives the following output:

    Code:
    [root@whsnprdred01 zabbix]# /etc/zabbix/scripts/discovery_redis.sh
    {
    "data":[
    { "{#REDISNAME}":"redis-qa01", "{#REDISPORT}":"6379" },
    { "{#REDISNAME}":"redis-stg", "{#REDISPORT}":"6380" }]
    }
    This has succeeded in correctly detecting the environments and populating some additional items, but most of the item values are missing:

    ​I can't find any trace of an error or related log activity on either client or server.
    I've looked through the docs and played around with some LLD and non-LLD MACROs for the hosts, but nothing seems to make a difference.

    The majority of the server data that is being returned looks to be being provided via the first (qa01) instances of Redis, via the following MACRO, but I can't find an obvious way to add an additional one:

    Code:
    {$REDIS.CONN.URI}    tcp://localhost:6379
    Is anybody able to advise where I'm going wrong?

    Thanks.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    replace hardcoded port with {#REDISPORT}.
    I do not know the template (is it this one? https://www.zabbix.com/integrations/redis#redis) , It is probably not meant to be used for multiple instances on same host... it may end up with a lot places to change and maybe even redoing it all for multiple instances. Looking at it, even the items "Get info" and "Get config" need to be redone to get info from your discovery, not from hardcoded "localhost:6379"...

    Comment

    Working...