zbx_redis_template
zbx_redis_template copied to clipboard
zabbix discovery doesn't work.
Is it normal, that you have discovery function for db, but it has been never used?
grep DBNAME -R .
./zbx_redis_templates.xml: <filter>{#DBNAME}:</filter>
./zbx_redis_templates.xml: <key>redis[{HOSTNAME}, key_space_db_expires, {#DBNAME}]</key>
./zbx_redis_templates.xml: <key>redis[{HOSTNAME}, key_space_db_keys, {#DBNAME}]</key>
./zbx_redis_templates.xml: <key>redis[{HOSTNAME}, key_space_db_avg_ttl, {#DBNAME}]</key>
./zbx_redis_trapper_templates.xml: <filter>{#DBNAME}:</filter>
./zbx_redis_trapper_templates.xml: <key>redis[{HOSTNAME}, key_space_db_avg_ttl, {#DBNAME}]</key>
./zbx_redis_trapper_templates.xml: <key>redis[{HOSTNAME}, key_space_db_keys, {#DBNAME}]</key>
./zbx_redis_trapper_templates.xml: <key>redis[{HOSTNAME}, key_space_db_expires, {#DBNAME}]</key>
Any updates or workaround for this? How to discover the Redis db?
I have a fix on my working copy of the script for my own use by adding a new function for discovery. So in the python script, add this new function above list_key_space_db:
def list_all_dbs_with_keys():
d = {'data': []}
for key in server_info.keys():
if key.startswith( 'db' ):
d['data'].append({'{#DBNAME}': key})
print json.dumps(d)
def list_key_space_db():
if args.db in server_info:
print(args.db)
else:
print('database_detect')
Making sure to add list_all_dbs_with_keys as a command line argument option:
{
'llen': llen,
'llenall': llensum,
'list_all_dbs_with_keys': list_all_dbs_with_keys,
'list_key_space_db': list_key_space_db,
}.get(args.metric, default)()
And then in the zabbix_agent.d/zbx_redis.conf file change the line to read:
UserParameter=redis.discovery,/etc/zabbix/externalscripts/zbx_redis_stats.py localhost list_all_dbs_with_keys
I also created a graph prototype with the 3 auto discover values in my template. You can if you want.
Below is the output when I run the command, and zabbix happily discovers all of my DBs now.
[root@testredis externalscripts]# /etc/zabbix/externalscripts/zbx_redis_stats.py localhost list_all_dbs_with_keys
{"data": [{"{#DBNAME}": "db2"}, {"{#DBNAME}": "db1"}, {"{#DBNAME}": "db0"}]}
good afternoon Zabbix does not automatically detect the database, writes: Redis dscovery db Value should be a JSON object.
I do: /opt/zabbix/externalscripts/zbx_redis_stats.py localhost list_all_dbs_with_case But nothing comes in reply. It's empty. How to fix it?
redis_version:2.6.17