本文整理汇总了Python中redis.client.StrictRedis.info方法的典型用法代码示例。如果您正苦于以下问题:Python StrictRedis.info方法的具体用法?Python StrictRedis.info怎么用?Python StrictRedis.info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.client.StrictRedis
的用法示例。
在下文中一共展示了StrictRedis.info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rfunc
# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import info [as 别名]
def rfunc(info):
#
info.setdefault('host', '127.0.0.1')
info.setdefault('port', 6379)
#
conn_kwargs = dict(
host=info['host'],
port=int(info['port']),
)
#
print('# Connect')
print(pformat(conn_kwargs, indent=4, width=1))
#
conn = None
try:
#
conn = StrictRedis(**conn_kwargs)
#
res = '\n'.join('{:<30}: {}'.format(k, v) for k, v in conn.info().items())
#
print('# Result')
print(res)
finally:
#
conn = None
示例2: run_once
# 需要导入模块: from redis.client import StrictRedis [as 别名]
# 或者: from redis.client.StrictRedis import info [as 别名]
def run_once():
for port in REDIS_PORT.split(','):
if ',' in REDIS_PORT:
statsd_prefix = STATSD_PREFIX + '-{}'.format(port)
else:
statsd_prefix = STATSD_PREFIX
redis = StrictRedis(REDIS_HOST, port)
stats = redis.info()
stats['keyspaces'] = {}
for key in stats.keys():
if key.startswith('db'):
stats['keyspaces'][key] = stats[key]
del stats[key]
out_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
for g in GAUGES:
if g in stats:
send_metric(out_sock, '{}.{}'.format(statsd_prefix, g), 'g', float(stats[g]))
for c in COUNTERS:
if c in stats:
send_metric(out_sock, '{}.{}'.format(statsd_prefix, c), 'c', float(stats[c]))
for ks in stats['keyspaces']:
for kc in KEYSPACE_COUNTERS:
if kc in stats['keyspaces'][ks]:
send_metric(out_sock, '{}.keyspace.{}'.format(
statsd_prefix, kc), 'c',
float(stats['keyspaces'][ks][kc]))
for kg in KEYSPACE_GAUGES:
if kg in stats['keyspaces'][ks]:
send_metric(out_sock, '{}.keyspace.{}'.format(
statsd_prefix, kg), 'g',
float(stats['keyspaces'][ks][kg]))
out_sock.close()
time.sleep(PERIOD)