Skip to content

Instantly share code, notes, and snippets.

@gdhgdhgdh
Created April 21, 2017 12:29
Show Gist options
  • Save gdhgdhgdh/20ce03cf02540f9a9fdb1e2f46441f47 to your computer and use it in GitHub Desktop.
Save gdhgdhgdh/20ce03cf02540f9a9fdb1e2f46441f47 to your computer and use it in GitHub Desktop.
# HELP bounded_fifo_buffer_gauges
# TYPE bounded_fifo_buffer_gauges gauge
bounded_fifo_buffer_gauges{deviceid="0000000000000003",gauge="bridge_outgoing_pub_buffer"} 79.0
bounded_fifo_buffer_gauges{deviceid="0000000000000003",gauge="bridge_outgoing_unsub_queue"} 55.0
bounded_fifo_buffer_gauges{deviceid="0000000000000003",gauge="number_of_connections"} 3.0
bounded_fifo_buffer_gauges{deviceid="0000000000000003",gauge="polt_queue"} 47.0
bounded_fifo_buffer_gauges{deviceid="0000000000000003",gauge="bridge_outgoing_sub_queue"} 79.0
bounded_fifo_buffer_gauges{deviceid="0000000000000003",gauge="broker_to_poltergeist_queue"} 47.0
# HELP attribute_store
# TYPE attribute_store histogram
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="0.005"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="0.01"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="0.025"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="0.05"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="0.075"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="0.1"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="0.25"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="0.5"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="0.75"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="1.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="2.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="5.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="7.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="10.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_devices",le="+Inf"} 1.0
attribute_store_count{deviceid="0000000000000003",event="load_devices"} 1.0
attribute_store_sum{deviceid="0000000000000003",event="load_devices"} 0.575542436995444
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="0.005"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="0.01"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="0.025"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="0.05"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="0.075"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="0.1"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="0.25"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="0.5"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="0.75"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="1.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="2.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="5.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="7.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="10.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_shadow",le="+Inf"} 1.0
attribute_store_count{deviceid="0000000000000003",event="save_shadow"} 1.0
attribute_store_sum{deviceid="0000000000000003",event="save_shadow"} 0.8645112123779156
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="0.005"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="0.01"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="0.025"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="0.05"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="0.075"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="0.1"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="0.25"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="0.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="0.75"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="1.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="2.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="5.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="7.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="10.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="open_store",le="+Inf"} 1.0
attribute_store_count{deviceid="0000000000000003",event="open_store"} 1.0
attribute_store_sum{deviceid="0000000000000003",event="open_store"} 0.25828119462135035
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="0.005"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="0.01"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="0.025"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="0.05"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="0.075"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="0.1"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="0.25"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="0.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="0.75"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="1.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="2.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="5.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="7.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="10.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="load_shadow",le="+Inf"} 1.0
attribute_store_count{deviceid="0000000000000003",event="load_shadow"} 1.0
attribute_store_sum{deviceid="0000000000000003",event="load_shadow"} 0.07790526171053602
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="0.005"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="0.01"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="0.025"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="0.05"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="0.075"} 0.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="0.1"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="0.25"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="0.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="0.75"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="1.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="2.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="5.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="7.5"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="10.0"} 1.0
attribute_store_bucket{deviceid="0000000000000003",event="save_device",le="+Inf"} 1.0
attribute_store_count{deviceid="0000000000000003",event="save_device"} 1.0
attribute_store_sum{deviceid="0000000000000003",event="save_device"} 0.07635146772915202
# HELP poltergeist_zigbee_events
# TYPE poltergeist_zigbee_events counter
poltergeist_zigbee_events{count="network_up_se",deviceid="0000000000000003"} 51.0
poltergeist_zigbee_events{count="zigbee_uptime",deviceid="0000000000000003"} 8.0
poltergeist_zigbee_events{count="smart_energy_registration_failure",deviceid="0000000000000003"} 67.0
poltergeist_zigbee_events{count="network_up_ha",deviceid="0000000000000003"} 39.0
poltergeist_zigbee_events{count="ember_cli_custom",deviceid="0000000000000003"} 93.0
poltergeist_zigbee_events{count="network_down_se",deviceid="0000000000000003"} 64.0
import time
import random
import threading
from prometheus_client import CollectorRegistry, Histogram, Gauge, Counter, write_to_textfile
def on_timer():
start=time.time()
for a in xrange(1, 20000):
write_device(a)
print (time.time() - start)
threading.Timer(600, on_timer).start()
def write_device(a):
registry = CollectorRegistry()
h = Histogram('attribute_store', '', ['event','deviceid'], registry=registry)
g = Gauge('bounded_fifo_buffer_gauges', '', ['gauge', 'deviceid'], registry=registry)
c = Counter('poltergeist_zigbee_events', '', ['count', 'deviceid'], registry=registry)
deviceid= "%0.16X" % a
h.labels('load_devices',deviceid).observe(random.random())
h.labels('load_shadow',deviceid).observe(random.random())
h.labels('open_store',deviceid).observe(random.random())
h.labels('save_device',deviceid).observe(random.random())
h.labels('save_shadow',deviceid).observe(random.random())
g.labels('bridge_outgoing_pub_buffer', deviceid).set(random.randint(0,100))
g.labels('bridge_outgoing_sub_queue', deviceid).set(random.randint(0,100))
g.labels('bridge_outgoing_unsub_queue', deviceid).set(random.randint(0,100))
g.labels('broker_to_poltergeist_queue', deviceid).set(random.randint(0,100))
g.labels('polt_queue', deviceid).set(random.randint(0,100))
g.labels('number_of_connections', deviceid).set(random.randint(0,100))
c.labels('ember_cli_custom',deviceid).inc(random.randint(0,100))
c.labels('network_down_se',deviceid).inc(random.randint(0,100))
c.labels('network_up_ha',deviceid).inc(random.randint(0,100))
c.labels('network_up_se',deviceid).inc(random.randint(0,100))
c.labels('smart_energy_registration_failure',deviceid).inc(random.randint(0,100))
c.labels('zigbee_uptime',deviceid).inc(random.randint(0,100))
write_to_textfile('out/' + deviceid + '.prom', registry)
threading.Timer(1, on_timer).start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment