Selection by namespace does not work
Closed this issue · 4 comments
Hello, thx for providing this script.
I got it working with the "all" namespace. But for our usecase, I only want to watch specific namespaces, as we share one redis between several Rails apps.
This one works:
/usr/lib/zabbix/externalscripts/redis-queue-discovery.sh discovery -d 0 -h redis -p 6379 -n all
...
{"{#SK_QUEUE}":"default", "{#SK_NS}":"redaktion_production"},
{"{#SK_QUEUE}":"important", "{#SK_NS}":"sq_eb_production"},
So, if I only want to access the sq_eb_production queue like this:
/usr/lib/zabbix/externalscripts/redis-queue-discovery.sh discovery ... -n sq_eb_production
{"{#SK_QUEUE}":"Invalid", "{#SK_NS}":""sq_eb_production""}
The reason seems to be the escaping of $i in https://github.com/hungntit/sidekiq_queue_zabbix/blob/master/redis-queue-discovery.sh#L65
which leads to this SMEMBERS command (L.79):
SMEMBERS "sq_eb_production":queues | /usr/bin/redis-cli ...
instead of this, that works:
SMEMBERS sq_eb_production:queues | /usr/bin/redis-cl
Solution:
If I remove the \"$i\"
backslashes from the quotes in line 65 it works. Do you have any objections for removing this backslashes? Otherwise I could submit the PR.
I can confirm exactly the same problem and proposed solution.
Original code leads to [name spaces redacted]:
./redis-queue-discovery.sh discovery -n my:name:space
{
"data":[
{"{#SK_QUEUE}":"Invalid", "{#SK_NS}":""my:name:space""}
]
}
Fixing line 65 to avoid the two times double-quotes, works as expected:
./redis-queue-discovery.sh discovery -n my:name:space
{
"data":[
{"{#SK_QUEUE}":"default", "{#SK_NS}":"my:name:space"},
{"{#SK_QUEUE}":"other", "{#SK_NS}":"my:name:space"}
]
}
Thanks :-)
So, I got this working on Zabbix, with namespaces. There where 2 aspects that needed fixing. This one and a small type in the queuesize
function when using $namespace.
I suggested both fixes in Merge Request #3
Thanks you guys, I haven't received the email for this issue and PR, I've also merged the PR of petervandenabeele .
Thanks and Best Regards
Hung Nguyen
Thanks for merging :-) I had also missed the communication on this one ...