import datetime

def main(j, args, params, tags, tasklet):
    doc = args.doc
    id = args.getTag('id')
    width = args.getTag('width')
    height = args.getTag('height')
    result = "{{jgauge width:%(width)s id:%(id)s height:%(height)s val:%(running)s start:0 end:%(total)s}}"
    cl = j.clients.osis.getByInstance('main')
    vmcl = j.clients.osis.getCategory(cl, 'system', 'machine')
    running = vmcl.search({'state': 'RUNNING'})[0]
    total = len(vmcl.list())
    result = result % {'height': height,
                       'width': width,
                       'running': running,
                       'id': id,
                       'total': total}
    params.result = (result, doc)
    return params

def match(j, args, params, tags, tasklet):
    return True
