本文整理匯總了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)