def main(): state = StatusState.check() if state.changed: # a systems property would be really nice state.age = 0 send_report(state, True) elif state.age % 16 == 0: send_report(state, False) state.save() nodes = model.NodeList.alive() counts, bw = map(sum, zip(*[(a.usercount, a.throughput) for a in nodes])) s_bw = "{0:.2f}".format(bw / 1000000.) total_gb = sum([a.total_throughput for a in model.NodeList.enabled()]) logger.log("Usercount: " + str(counts)) logger.log("Bandwidth usage: {0} mb/s".format(s_bw)) logger.log("Monthly total: " + str(total_gb) + " GB") rrd = rrdupdate(time(), counts, s_bw) if rrd.startswith("ERROR"): logger.log("rrdtool update: " + rrd) graphs = creategraphs() if "ERROR" in graphs: logger.log("rrdtool graph: " + rrd)
def status(): state = StatusState.check() return {'status': state.status, 'systems': state.systems}