Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zabbix discovery doesn't work. #13

Open
sharewax opened this issue Nov 5, 2015 · 3 comments
Open

zabbix discovery doesn't work. #13

sharewax opened this issue Nov 5, 2015 · 3 comments

Comments

@sharewax
Copy link

sharewax commented Nov 5, 2015

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>
@rubal033
Copy link

Any updates or workaround for this? How to discover the Redis db?

@timwelch
Copy link

timwelch commented Sep 23, 2016

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"}]}

@darksmoke
Copy link

darksmoke commented Sep 10, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants