Changeset 437
- Timestamp:
- 05/12/08 19:49:48
- Arquivos:
-
- cacic/trunk/agente-linux/pycacic/src/cacic.py (modified) (6 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/col_hard.py (modified) (1 diff)
- cacic/trunk/agente-linux/pycacic/src/coletores/col_network.py (modified) (3 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/col_soft.py (modified) (2 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/coletor.py (modified) (4 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/ccrypt.py (modified) (1 diff)
- cacic/trunk/agente-linux/pycacic/src/ger_cols.py (modified) (2 diffs)
- cacic/trunk/agente-linux/pycacic/src/run.sh (modified) (1 diff)
Legenda:
- Não modificado
- Adicionado
- Removido
- Modificado
- Copiado
- Movido
cacic/trunk/agente-linux/pycacic/src/cacic.py
r436 r437 27 27 # flags do Gerente de Coletas 28 28 self.gc_stopped = 0 # False 29 self.gc_started = 0 # False30 29 self.gc_ok = 0 # False 31 30 self.isforcada = [] … … 53 52 print(" `---- Coleta iniciara daqui a %s minutos" % (self.interval/60)) 54 53 #self.atualiza() 55 # se nao estiver executando e esta habilitado a executar 56 # ou e uma coleta forcada 57 if not self.gc_started and (self.gc_ok or len(self.isforcada) > 0): 54 # se esta habilitado a executar ou e uma coleta forcada 55 if self.gc_ok or len(self.isforcada) > 0: 58 56 # muda estado para nao habilitado 59 57 self.gc_ok = 0 # False … … 63 61 # inicia coletas 64 62 self.gc.coletas_forcadas = self.isforcada 65 thread.start_new_thread(self.start, ())63 self.start() 66 64 time.sleep(2) 67 65 # fechando conexao 68 66 self.udp_sock.close() 69 67 except Exception, e: 68 import traceback 69 traceback.print_exc() 70 70 print e 71 71 … … 74 74 if os.getuid() != 0: 75 75 return 0 # False 76 return 1 # True 76 return 1 # True 77 77 78 78 def start(self): 79 79 """Inicia as coletas""" 80 self.gc_started = 1 # True81 80 self.isforcada = [] 82 81 print(" --- INICIO DAS COLETAS ---") … … 86 85 self.gc.createDat() 87 86 self.gc.sendColetas() 88 self.gc_started = 0 # False89 87 print(" --- FIM DAS COLETAS ---") 90 88 … … 93 91 Espera determinado intervalo de tempo. E apos isto marca o estado 94 92 do Gerente de Coletas como nao parado e habilita execucao das coletas 95 """ 96 print '---- esperando intervalo' 93 """ 97 94 time.sleep(self.interval) 98 print '---- timeout !!!'99 95 self.gc_stopped = 0 # False 100 96 self.gc_ok = 1 # True cacic/trunk/agente-linux/pycacic/src/coletores/col_hard.py
r430 r437 30 30 def getName(self): 31 31 return "col_hard" 32 33 def getUVCKey(self): 34 return 'Coleta.Hardware' 32 35 33 36 def start(self): 34 37 self.setDicionario() 35 38 self.createDat(self.dicionario, self.PATH + self.OUTPUT_DAT, 'Col_Hard.') 36 self.addChave('Coleta.Hardware', self.getChave('UVC'))37 39 38 40 def setDicionario(self): cacic/trunk/agente-linux/pycacic/src/coletores/col_network.py
r430 r437 10 10 class Col_Network(Coletor): 11 11 """Classe responsavel por coletar os dados de TCP IP""" 12 13 # nome do arquivo de saida (DAT) 14 OUTPUT_DAT = 'col_network.dat' 12 15 13 16 def __init__(self, computer): … … 22 25 return "col_network" 23 26 27 def getUVCKey(self): 28 return 'Coleta.Network' 29 24 30 def start(self): 25 31 self.setDicionario() 32 self.createDat(self.dicionario, self.PATH + self.OUTPUT_DAT, 'Col_Network.') 26 33 27 34 def setDicionario(self): … … 42 49 self.addChave('te_gateway', net.getGateway()) 43 50 self.addChave("te_serv_dhcp", net.getDHCP()) 51 self.addChave('UVC', self.getUVC(self.dicionario)) 44 52 cacic/trunk/agente-linux/pycacic/src/coletores/col_soft.py
r434 r437 6 6 """Classe responsavel por coletar os dados de Software""" 7 7 8 # nome do arquivo de saida (DAT) 9 OUTPUT_DAT = 'col_soft.dat' 10 8 11 def __init__(self, computer): 9 12 Coletor.__init__(self, computer) … … 12 15 def getName(self): 13 16 return "col_soft" 17 18 def getUVCKey(self): 19 return 'Coleta.Software' 14 20 15 def isReady(self, dat=None): 21 def isReady(self, dat=None): 16 22 return 0 17 23 18 24 def start(self): 19 25 self.setDicionario() 26 self.createDat(self.dicionario, self.PATH + self.OUTPUT_DAT, 'Col_Soft.') 20 27 21 28 def setDicionario(self): 22 """Monta o dicionario""" 23 return29 """Monta o dicionario""" 30 self.addChave('UVC', self.getUVC(self.dicionario)) 24 31 cacic/trunk/agente-linux/pycacic/src/coletores/coletor.py
r434 r437 16 16 from lib.ccrypt import * 17 17 from lib.computador import Computador 18 from globals import Globals19 18 20 19 class Coletor: … … 58 57 raise Exception("Abstract method getName(), must override") 59 58 59 def getUVCKey(self): 60 """ Retorna o nome da chave do UVC """ 61 raise Exception("Abstract method getUVCKey(), must override") 62 60 63 def getEncryptedDict(self): 61 64 """ Retorna o dicionario de dados da coleta encryptado """ … … 63 66 self.dicionario[key] = self.encripta(self.dicionario[key]) 64 67 return self.dicionario 65 66 68 67 69 def isReady(self, dat=None): … … 86 88 """ 87 89 data = Arquivo.openFile(path) 88 dat = self.decripta(data) 90 dat = self.decripta(data) 89 91 for i in dat.split(self.spd_key): 90 92 item = i.split(self.spd_value) cacic/trunk/agente-linux/pycacic/src/coletores/lib/ccrypt.py
r435 r437 31 31 """ 32 32 33 KEY = 'Cacic Brasil'33 KEY = 'CacicES2005' 34 34 AES_KEY_SIZE = 32 35 35 AES_BLOCK_SIZE = 16 cacic/trunk/agente-linux/pycacic/src/ger_cols.py
r433 r437 183 183 # Coletores 184 184 self.coletores.clear() 185 # adiciona o coletor padrao (Col_Network) 185 186 self.addColeta(Col_Network(self.computador), 'S') 186 187 for no in root.childNodes: … … 269 270 self.coletas_enviar.clear() 270 271 self.computador.coletar() 271 # adiciona o coletor padrao (Col_Network)272 272 for col in self.coletores.values(): 273 273 col.start() 274 self.coletor.addChave(col.getUVCKey(), col.getChave('UVC')) 274 275 if self.all_forcada or (col.getName() in self.coletas_forcadas) or col.isReady(self.OUTPUT_DAT): 275 276 page = Reader.getColetor(col.getName())['page'] cacic/trunk/agente-linux/pycacic/src/run.sh
r430 r437 2 2 CAMINHO="`dirname $0`" 3 3 4 nome1="rogerio" 5 nome2="rogerio" 6 7 if [ "$nome1" = "$nome2" ]; then 8 echo "Hahaiee"; 9 fi 10 4 11 if [ -f "$CAMINHO/gui.py" ]; then 5 gksudo python "$CAMINHO/gui.py"; 12 echo 'a' 13 #gksudo python "$CAMINHO/gui.py"; 6 14 else 7 15 echo 'Arquivo não encontrado';
