def store(now, data): node_id = data.get('node_id') if node_id: loc = path.join(DATADIR, '{}.json'.format(node_id)) node = readjson(loc) if not node: node = {'log': {}} clients = data.get('clients', {}) traffic = data.get('traffic', {}) node['hostname'] = data.get('hostname') node['log'][now] = {} node['log'][now]['load_avg'] = data.get('loadavg') node['log'][now]['clients_total'] = clients.get('total') node['log'][now]['clients_wifi'] = clients.get('wifi') node['log'][now]['traffic_rx'] = traffic.get('rx', {}).get('bytes') node['log'][now]['traffic_tx'] = traffic.get('tx', {}).get('bytes') node['log'][now]['traffic_forward'] = traffic.get('forward', {}).get('bytes') node['log'][now]['traffic_mgmt_rx'] = traffic.get('mgmt_tx', {}).get('bytes') node['log'][now]['traffic_mgmt_tx'] = traffic.get('mgmt_tx', {}).get('bytes') return writejson(loc, node)
def store(now, data): node_id = data.get('node_id') if node_id: loc = path.join(DATADIR, '{}.json'.format(node_id)) node = readjson(loc) if not node: node = {'log': {}} clients = data.get('clients', {}) traffic = data.get('traffic', {}) node['hostname'] = data.get('hostname') node['log'][now] = {} node['log'][now]['load_avg'] = data.get('loadavg') node['log'][now]['clients_total'] = clients.get('total') node['log'][now]['clients_wifi'] = clients.get('wifi') node['log'][now]['traffic_rx'] = traffic.get('rx', {}).get('bytes') node['log'][now]['traffic_tx'] = traffic.get('tx', {}).get('bytes') node['log'][now][ 'traffic_forward' ] = traffic.get('forward', {}).get('bytes') node['log'][now][ 'traffic_mgmt_rx' ] = traffic.get('mgmt_tx', {}).get('bytes') node['log'][now][ 'traffic_mgmt_tx' ] = traffic.get('mgmt_tx', {}).get('bytes') return writejson(loc, node)
def load(): conf = readjson(CONFIG) if not conf: conf = {} if not conf.get('connection'): conf['connection'] = gen_connection() if not conf.get('targets'): conf['targets'] = gen_targets() if not conf.get('upload'): conf['upload'] = gen_upload() writejson(CONFIG, conf) return conf
def load(): conf = readjson(CONFIG) if not conf: conf = {} if not conf.get("connection"): conf["connection"] = gen_connection() if not conf.get("targets"): conf["targets"] = gen_targets() if not conf.get("upload"): conf["upload"] = gen_upload() writejson(CONFIG, conf) return conf
def _load(): sdata = {'log': {}, 'hostname': 'Summary'} for jf in listdir(DATADIR): if fnmatch(jf, '*.json'): data = readjson(path.join(DATADIR, jf)) yield PlotNode(data) for ts in data['log']: sdata['log'][ts] = sdata['log'].get(ts, {}) for field in data['log'][ts]: dt = data['log'][ts][field] sdata['log'][ts][field] = sdata['log'][ts].get(field, 0) if dt is not None: sdata['log'][ts][field] += dt sum_node = PlotNode(sdata) save('_sum', sum_node.clients(), 'clients') save('_sum', sum_node.traffic(), 'traffic') save('_sum', sum_node.traffic_full(), 'traffic_full')
def _load(): sdata = { 'log': {}, 'hostname': 'Summary' } for jf in listdir(DATADIR): if fnmatch(jf, '*.json'): data = readjson(path.join(DATADIR, jf)) yield PlotNode(data) for ts in data['log']: sdata['log'][ts] = sdata['log'].get(ts, {}) for field in data['log'][ts]: dt = data['log'][ts][field] sdata['log'][ts][field] = sdata['log'][ts].get(field, 0) if dt is not None: sdata['log'][ts][field] += dt sum_node = PlotNode(sdata) save('_sum', sum_node.clients(), 'clients') save('_sum', sum_node.traffic(), 'traffic') save('_sum', sum_node.traffic_full(), 'traffic_full')