def main(): threading.Timer(SENT_INTERVAL, main).start() device = [{ 'id': DEVICE_FRIENDLY_NAME, 'sensors': get_memory() + get_disks() + get_battery() + get_networks() + get_internet_speed() + get_ohm_sensors() }] connection = http.client.HTTPSConnection(UBEAC_URL) connection.request('POST', GATEWAY_URL, json.dumps(device)) response = connection.getresponse() print(response.read().decode())
def get_sensors_data(self): self.sensors_data = { "cpu_load": str(get_cpus()[0]['data']) + '%', "temperature": get_temperatures()[0]['data']['Current'], "network_speed": get_networks()[0]['data'], "memory_space": { 'Usage': str(get_memory()[1]['data']) + '%', 'Total': str(get_memory()[0]['data']['Total'] / 1000) + 'GB', 'Used': str(get_memory()[0]['data']['Used'] / 1000) + 'GB', 'Available': str(get_memory()[0]['data']['Available'] / 1000) + 'GB', }, "swap_space": { 'Usage': str(get_memory()[3]['data']) + '%', 'Total': str(get_memory()[2]['data']['Total'] / 1000) + 'GB', 'Used': str(get_memory()[2]['data']['Used'] / 1000) + 'GB', 'Free': str(get_memory()[2]['data']['Free'] / 1000) + 'GB' }, "disk_usage": get_disks() } return self.sensors_data