def get_cpu_usage(): """get the current cpu usage""" session_id = fh.get_session_id() xhr_data = fh.get_xhr_content(session_id, PAGE) data = json.loads(xhr_data) print('cpu.value %d' % (int(data['data']['cpuutil']['series'][0][-1])))
def get_cpu_temperature(): """get the current cpu temperature""" session_id = fh.get_session_id() xhr_data = fh.get_xhr_content(session_id, PAGE) data = json.loads(xhr_data) print('temp.value %d' % (int(data['data']['cputemp']['series'][0][-1])))
def get_power_consumption(): """get the current power consumption usage""" session_id = fh.get_session_id() xhr_data = fh.get_xhr_content(session_id, PAGE) data = json.loads(xhr_data) devices = data['data']['drain'] for i, device in enumerate(DEVICES): print('%s.value %s' % (device, devices[i]['actPerc']))
def get_memory_usage(): """get the current memory usage""" session_id = fh.get_session_id() xhr_data = fh.get_xhr_content(session_id, PAGE) data = json.loads(xhr_data) for i, usage in enumerate(USAGE): print('%s.value %s' % (usage, data['data']['ramusage']['series'][i][-1]))
def get_cpu_temperature(): """get the current cpu temperature""" server = hostname password = os.environ['fritzbox_password'] session_id = fh.get_session_id(server, password) xhr_data = fh.get_xhr_content(server, session_id, PAGE) data = json.loads(xhr_data) print('temp.value %d' % (int(data['data']['cputemp']['series'][0][-1])))
def get_cpu_usage(): """get the current cpu usage""" server = os.environ['fritzbox_ip'] password = os.environ['fritzbox_password'] session_id = fh.get_session_id(server, password) xhr_data = fh.get_xhr_content(server, session_id, PAGE) data = json.loads(xhr_data) print('cpu.value %d' % (int(data['data']['cpuutil']['series'][0][-1])))
def get_connected_wifi_devices(): """gets the numbrer of currently connected wifi devices""" session_id = fh.get_session_id() xhr_data = fh.get_xhr_content(session_id, PAGE) data = json.loads(xhr_data) m = re.search(pattern, data['data']['drain'][2]['statuses'][-1]) if m: connected_devices = int(m.group(1)) print('wifi.value %d' % connected_devices)
def get_memory_usage(): """get the current memory usage""" server = os.environ['fritzbox_ip'] password = os.environ['fritzbox_password'] session_id = fh.get_session_id(server, password) xhr_data = fh.get_xhr_content(server, session_id, PAGE) data = json.loads(xhr_data) for i, usage in enumerate(USAGE): print('%s.value %s' % (usage, data['data']['ramusage']['series'][i][-1]))
def get_power_consumption(): """get the current power consumption usage""" server = os.environ['fritzbox_ip'] password = os.environ['fritzbox_password'] session_id = fh.get_session_id(server, password) xhr_data = fh.get_xhr_content(server, session_id, PAGE) data = json.loads(xhr_data) devices = data['data']['drain'] for i, device in enumerate(DEVICES): print('%s.value %s' % (device, devices[i]['actPerc']))
def get_connected_wifi_devices(): """gets the numbrer of currently connected wifi devices""" server = os.environ['fritzbox_ip'] password = os.environ['fritzbox_password'] session_id = fh.get_session_id(server, password) xhr_data = fh.get_xhr_content(server, session_id, PAGE) data = json.loads(xhr_data) m = re.search(pattern, data['data']['drain'][2]['statuses'][-1]) if m: connected_devices = int(m.group(1)) print('wifi.value %d' % connected_devices)
def get_connected_wifi_devices(): """gets the numbrer of currently connected wifi devices""" server = os.environ['fritzbox_ip'] password = os.environ['fritzbox_password'] session_id = fh.get_session_id(server, password) xhr_data = fh.get_xhr_content(server, session_id, PAGE) data = json.loads(xhr_data) m = re.search(pattern, data['data']['drain'][2]['statuses'][-1]) if m: connected_devices = int(m.group(1)) print('wifi.value %d' % connected_devices)
def get_uptime(): """get the current uptime""" session_id = fh.get_session_id() xhr_data = fh.get_xhr_content(session_id, PAGE) data = json.loads(xhr_data) for d in data['data']['drain']: if 'aktiv' in d['statuses']: matches = re.finditer(pattern, d['statuses']) if matches: hours = 0.0 for m in matches: if m.group(2) == dayLoc[locale]: hours += 24 * int(m.group(1)) if m.group(2) == hourLoc[locale]: hours += int(m.group(1)) if m.group(2) == minutesLoc[locale]: hours += int(m.group(1)) / 60.0 uptime = hours / 24 print("uptime.value %.2f" % uptime)
def get_uptime(): """get the current uptime""" server = os.environ['fritzbox_ip'] password = os.environ['fritzbox_password'] session_id = fh.get_session_id(server, password) xhr_data = fh.get_xhr_content(server, session_id, PAGE) data = json.loads(xhr_data) for d in data['data']['drain']: if 'aktiv' in d['statuses']: matches = re.finditer(pattern, d['statuses']) if matches: hours = 0.0 for m in matches: if m.group(2) == dayLoc[locale]: hours += 24 * int(m.group(1)) if m.group(2) == hourLoc[locale]: hours += int(m.group(1)) if m.group(2) == minutesLoc[locale]: hours += int(m.group(1)) / 60.0 uptime = hours / 24 print("uptime.value %.2f" % uptime)