Пример #1
0
	def __init__(self):
		super(Coletor, self).__init__()
		self.stoprequest = threading.Event()
		self.capt = Captura()
		self.capt.nomedocoletor("aluizio") #Para cada máquina virtual esse nome deve mudar
Пример #2
0
class Coletor(threading.Thread):
	def __init__(self):
		super(Coletor, self).__init__()
		self.stoprequest = threading.Event()
		self.capt = Captura()
		self.capt.nomedocoletor("aluizio") #Para cada máquina virtual esse nome deve mudar

	def run(self):
		while True:
			try:
				if not self.stoprequest.isSet():
					self.capt.captura()
			except (KeyboardInterrupt, SystemExit):
				coletor.stoprequest.set()
				log.setErro(sys.exc_info()[1],nomecoletor)
				print "Um erro ocorreu!"
				os._exit(0)


	def stop(self):
		if not self.stoprequest.isSet():
			self.stoprequest.set()
			self.capt.status("stop")


	def resume(self):
		if self.stoprequest.isSet():
			self.stoprequest.clear()
			self.capt.status("resume")
			print self.stoprequest.isSet()
			print self.capt.stats

	def teste(self):
		if self.stoprequest.isSet():
			self.capt.status("teste")
			self.capt.capturateste()

		else:
			self.capt.status("stop")
			self.capt.status("teste")
			self.capt.capturateste()
Пример #3
0
class Coletor(threading.Thread):
    def __init__(self):
        super(Coletor, self).__init__()
        self.stoprequest = threading.Event()
        self.capt = Captura()
        self.capt.nomedocoletor(
            "aluizio")  #Para cada máquina virtual esse nome deve mudar

    def run(self):
        while True:
            try:
                if not self.stoprequest.isSet():
                    self.capt.captura()
            except (KeyboardInterrupt, SystemExit):
                coletor.stoprequest.set()
                log.setErro(sys.exc_info()[1], nomecoletor)
                print "Um erro ocorreu!"
                os._exit(0)

    def stop(self):
        if not self.stoprequest.isSet():
            self.stoprequest.set()
            self.capt.status("stop")

    def resume(self):
        if self.stoprequest.isSet():
            self.stoprequest.clear()
            self.capt.status("resume")
            print self.stoprequest.isSet()
            print self.capt.stats

    def teste(self):
        if self.stoprequest.isSet():
            self.capt.status("teste")
            self.capt.capturateste()

        else:
            self.capt.status("stop")
            self.capt.status("teste")
            self.capt.capturateste()
Пример #4
0
 def __init__(self):
     super(Coletor, self).__init__()
     self.stoprequest = threading.Event()
     self.capt = Captura()
     self.capt.nomedocoletor(
         "aluizio")  #Para cada máquina virtual esse nome deve mudar
Пример #5
0
while 1:
    # Recebe mensagem do usuario e envia ao destino
    message = raw_input('Digite "descoberta" para parear com o servidor\n>>>')
    if message.upper() == "DESCOBERTA":
        clientSocket.sendto(message, (serverName, serverPort))  # envia mensagem para o server
        returnMessage, serverAddress = clientSocket.recvfrom(2048)  # Aguarda mensagem de retorno
        print ("\nServidor: " + returnMessage)
        break
    else:
        print "Comando invalido"

while 1:
    print "Aguandando ordens do Monitor"
    returnMessage, serverAddress = clientSocket.recvfrom(2048)  # Aguarda mensagem de retorno
    print ("\nServidor: " + returnMessage)
    if returnMessage.upper() == "COLETAR":
        print "\nColetando Pacotes..."
        captura = Captura()
        captura.captura()
        clientSocket.sendto("\nColeta de pacotes terminada.", (serverName, serverPort))  # envia mensagem para o server

    elif returnMessage.upper() == "CLASSIFICAR":
        print "\nClassificando Pacotes..."
        returnMessage, serverAddress = clientSocket.recvfrom(2048)  # Aguarda mensagem de retorno
    elif returnMessage.upper() == "LOG":
        print "\nAbrindo Log..."
        returnMessage, serverAddress = clientSocket.recvfrom(2048)  # Aguarda mensagem de retorno

clientSocket.close()