Ejemplo n.º 1
0
def stats_redis(port=6379):
    redis = RedisClient(port=port)
    info = redis.info()
    ret = {}
    #ret['port'] = port
    for k,v in info.iteritems():
        if k in ['instantaneous_ops_per_sec','total_commands_processed','keyspace_misses','keyspace_hits','connected_clients','total_connections_received','used_memory','maxmemory','mem_fragmentation_ratio','keyspace']:
            ret[k] = v
    ret['maxmemory'] = redis.config_mem()['maxmemory']
    return ret
Ejemplo n.º 2
0
def get_discovery(redis, hostname):
    """ Discover 'dynamic' items like
        http://redis.io/commands/info
        replication: depends on slave number
        cluster: empty if not applicable
        keyspace: depends on database number
    """
    data = {}
    data[hostname] = {}
    section_list = { 'keyspace': 'REDISDB' }
    data[hostname] = { "redis.cluster.discovery":[] }
    for section, lldvalue in section_list.iteritems():
        data[hostname]["redis.%s.discovery" % section] = []
        result = redis.info(section)
        for key, value in result.iteritems():
            dsc_data = {"{#%s}" % lldvalue: "%s" % key }
            data[hostname][("redis.%s.discovery" % (section))].append(dsc_data)
    return data
Ejemplo n.º 3
0
def get_metrics(redis, hostname):
    """ http://redis.io/commands/info
        server: General information about the Redis server
        clients: Client connections section
        memory: Memory consumption related information
        persistence: RDB and AOF related information
        stats: General statistics
        replication: Master/slave replication information
        cpu: CPU consumption statistics
        commandstats: Redis command statistics
        cluster: Redis Cluster section
        keyspace: Database related statistics
    """
    data = {}
    data[hostname] = {}
    section_list = [ 'server', 'clients', 'memory', 'persistence',
                     'stats', 'replication', 'cpu', 'cluster', 'keyspace' ]
    for section in section_list:
        result = redis.info(section)
        data[hostname].update(get_data_from_dict(result, ("redis.%s[" % section)))
    return data