Skip to content

Instantly share code, notes, and snippets.

Created April 23, 2017 06:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import json
import os
import time
import sys
from random import randint
from collections import defaultdict
def multi_dimension_dict(dimension, callable_obj=int):
nodes = defaultdict(callable_obj)
for i in range(dimension-1):
p = nodes.copy()
nodes = defaultdict(lambda : defaultdict(p.default_factory))
return nodes
if(os.environ.get('MACKEREL_AGENT_PLUGIN_META') == '1'):
meta = multi_dimension_dict(2)
metrics = [{'name':'d6','label':'Die(d6)'},{'name':'d20','label':'Die(20)'}]
meta['graphs']['super.dice'] = {'label': 'My Dice', 'unit': 'integer', 'metrics': metrics}
print('\t'.join(['super.dice.d6', str(randint(1,6)), str(time.time())]))
print('\t'.join(['super.dice.d20', str(randint(1,20)), str(time.time())]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment