def opt3(self, ip, community, time1, time2): ''' Executa o agendamento do collector, que ira coletar informacoes de gerenciamento dos hosts cadastrados. ''' if time1 < time2: resultado = 'O tempo digitado para execução é menor que o intervalo de tempo' else: while (time.time() < time2): t = Timer(30.0, dbmanager.reg_hosts_db()) t.start()
def opt1(): ''' Cadastro manual de Hosts. ''' sair = 1 subprocess.call('clear') while sair: l = [] ip = raw_input('Endereco IP: ') host = raw_input('Nome do Host: ') if (ip != '') and (host != ''): l.append((ip, host)) laux = dbmanager.reg_query_db('{0}{1}'.format(INSTALL_PATH, DB), l) dbmanager.reg_hosts_db('{0}{1}'.format(INSTALL_PATH, DB), laux) else: print 'IP ou Host vazio nao sao validos' print '\n0) Sair' print '1) Continuar cadastrando' try: sair = input('Escolher: ') except: 'Opcao invalida!' sair = 0
def reg_hosts(l): laux = reg_query_db('{0}{1}'.format(settings.INSTALL_PATH, settings.DB), l) reg_hosts_db('{0}{1}'.format(settings.INSTALL_PATH, settings.DB), laux)