from services.mysql import Mysql from services.dataGenerator import getData from services.dataGenerator import alertaSlack import time #Inserir user, password, host, database mysql = Mysql('ProjetoAPI', 'urubu100', 'localhost', 'PROJETOAPI') mysql.connect() while True: values = getData() mysql.insert(values) Slack = alertaSlack(values) print(Slack) time.sleep(2)
nome = socket.gethostname() result = mysql.select(nome) # values = getData() dadosComponente = [] def getDataDevice(valNum): for row in valNum: dadosComponente.append({ "idMaquina": row[0], "nomeMaquina": row[1], "idComponente": row[2], "tipoComponente": row[3], "nomeLeitura": row[4] }) return dadosComponente componentes = [] componentes = getDataDevice(result) for componente in componentes: dataCpu.append(getData(componente)) while (i < len(dataCpu)): for info in dataCpu[i]: mysql.insert(info) print(info) i = i + 1 # time.sleep(2)