本文整理汇总了Python中statsd.StatsClient.pipeline方法的典型用法代码示例。如果您正苦于以下问题:Python StatsClient.pipeline方法的具体用法?Python StatsClient.pipeline怎么用?Python StatsClient.pipeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类statsd.StatsClient
的用法示例。
在下文中一共展示了StatsClient.pipeline方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_stats
# 需要导入模块: from statsd import StatsClient [as 别名]
# 或者: from statsd.StatsClient import pipeline [as 别名]
def send_stats(last_timestamp, last_message_count, json_filename):
with open(json_filename) as data_file:
data = json.load(data_file)
current_timestamp = data["now"]
current_message_count = data["messages"]
secs = False
msgs = False
if last_timestamp is False:
print "Starting up, first pass...."
elif current_message_count < last_message_count:
print "Looks like dump1090 restarted, message count reset (%d)" % current_message_count
else:
secs = current_timestamp - last_timestamp
msgs = current_message_count - last_message_count
print "{0} sec\t{1} messages\t{2} messages per sec avg".format(secs, msgs, (msgs / secs))
last_timestamp = current_timestamp
last_message_count = current_message_count
threading.Timer(INTERVAL, send_stats, [last_timestamp, last_message_count, json_filename]).start()
aircrafts_5s = []
aircrafts_10s = []
aircrafts_30s = []
aircrafts_60s = []
for aircraft in data["aircraft"]:
if aircraft["seen"] < 5:
aircrafts_5s.append(aircraft["hex"])
if aircraft["seen"] < 10:
aircrafts_10s.append(aircraft["hex"])
if aircraft["seen"] < 30:
aircrafts_30s.append(aircraft["hex"])
if aircraft["seen"] < 60:
aircrafts_60s.append(aircraft["hex"])
print "\t5s:{0}\t10s:{1}\t30s:{2}\t60s:{3}".format(len(aircrafts_5s), len(aircrafts_10s), len(aircrafts_30s), len(aircrafts_60s))
radio_name = sys.argv[1]
if secs:
client = StatsClient(STATSD_HOST)
client.incr("radios.%s.message_rate" % radio_name, msgs)
pipe = client.pipeline()
c = 0
max_msg_size = 20
for hex in aircrafts_10s:
pipe.set("radios.%s.aircraft" % radio_name, hex)
c = c + 1
if c == max_msg_size:
pipe.send()
c = 0
if c != max_msg_size:
pipe.send()
示例2: setUp
# 需要导入模块: from statsd import StatsClient [as 别名]
# 或者: from statsd.StatsClient import pipeline [as 别名]
def setUp(self):
sqsregioninfo = SQSRegionInfo(name='localhost_region', endpoint='localhost')
self.connection = sqsregioninfo.connect(
port=8001,
aws_access_key_id='id',
aws_secret_access_key='secret',
is_secure=False
)
self.queue = self.connection.create_queue('test_queue')
client = StatsClient(host='localhost', port=8125, prefix=None, maxudpsize=512)
self.statsd = client.pipeline()
示例3: send_radio_stats
# 需要导入模块: from statsd import StatsClient [as 别名]
# 或者: from statsd.StatsClient import pipeline [as 别名]
def send_radio_stats(n, s):
client = StatsClient(STATSD_HOST)
pipe = client.pipeline()
pipe.gauge("radios.%s.accepted" % n, s["local"]["accepted"][0])
pipe.gauge("radios.%s.accepted_corrected" % n, s["local"]["accepted"][1])
# If you use the "aggressive" setting in dump1090-mutability, there may
# be a third entry in the accepted set. Maybe you want to do something with that data?
#pipe.gauge("radios.%s.accepted_corrected_2bit" % n, s["local"]["accepted"][2])
pipe.gauge("radios.%s.bad" % n, s["local"]["bad"])
pipe.gauge("radios.%s.blocks_dropped" % n, s["local"]["blocks_dropped"])
pipe.gauge("radios.%s.blocks_processed" % n, s["local"]["blocks_processed"])
pipe.gauge("radios.%s.modeac" % n, s["local"]["modeac"])
pipe.gauge("radios.%s.modes" % n, s["local"]["modes"])
pipe.gauge("radios.%s.strong_signals" % n, s["local"]["strong_signals"])
pipe.gauge("radios.%s.unknown_icao" % n, s["local"]["unknown_icao"])
pipe.gauge("radios.%s.cpr.airborne" % n, s["cpr"]["airborne"])
pipe.gauge("radios.%s.cpr.filtered" % n, s["cpr"]["filtered"])
pipe.send()
pipe.gauge("radios.%s.cpr.global_bad" % n, s["cpr"]["global_bad"])
pipe.gauge("radios.%s.cpr.global_ok" % n, s["cpr"]["global_ok"])
pipe.gauge("radios.%s.cpr.global_range" % n, s["cpr"]["global_range"])
pipe.gauge("radios.%s.cpr.global_skipped" % n, s["cpr"]["global_skipped"])
pipe.gauge("radios.%s.cpr.global_speed" % n, s["cpr"]["global_speed"])
pipe.gauge("radios.%s.cpr.local_aircraft_relative" % n, s["cpr"]["local_aircraft_relative"])
pipe.gauge("radios.%s.cpr.local_ok" % n, s["cpr"]["local_ok"])
pipe.gauge("radios.%s.cpr.local_range" % n, s["cpr"]["local_range"])
pipe.gauge("radios.%s.cpr.local_receiver_relative" % n, s["cpr"]["local_receiver_relative"])
pipe.gauge("radios.%s.cpr.local_skipped" % n, s["cpr"]["local_skipped"])
pipe.send()
pipe.gauge("radios.%s.cpr.local_speed" % n, s["cpr"]["local_speed"])
pipe.gauge("radios.%s.cpr.surface" % n, s["cpr"]["surface"])
pipe.gauge("radios.%s.messages" % n, s["messages"])
pipe.gauge("radios.%s.tracks_all" % n, s["tracks"]["all"])
pipe.gauge("radios.%s.tracks_single_message" % n, s["tracks"]["single_message"])
pipe.timing("radios.%s.cpu.background" % n, s["cpu"]["background"])
pipe.timing("radios.%s.cpu.demodulation" % n, s["cpu"]["demod"])
pipe.timing("radios.%s.cpu.usb" % n, s["cpu"]["reader"])
pipe.send()