Changeset 430
- Timestamp:
- 05/09/08 13:24:35
- Arquivos:
-
- cacic/trunk/agente-linux/pycacic/src/cacic.py (modified) (7 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/col_hard.py (modified) (4 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/col_network.py (modified) (3 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/coletor.py (modified) (2 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/ccrypt.py (modified) (1 diff)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/ccrypt_lib.py (modified) (3 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/computador.py (modified) (14 diffs)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/url.py (modified) (1 diff)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/Crypto/__init__.py (modified) (1 diff)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc4 (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc4/Crypto (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc4/Crypto/Cipher (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc4/Crypto/Cipher/AES.so (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc4/Crypto/Cipher/__init__.py (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc4/Crypto/__init__.py (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc4/__init__.py (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc6 (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc6/Crypto (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc6/Crypto/Cipher (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc6/Crypto/Cipher/AES.so (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc6/Crypto/Cipher/__init__.py (added)
- cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/libc6/Crypto/__init__.py (added)
- cacic/trunk/agente-linux/pycacic/src/config/cacic.conf (modified) (2 diffs)
- cacic/trunk/agente-linux/pycacic/src/config/io.py (modified) (4 diffs)
- cacic/trunk/agente-linux/pycacic/src/ger_cols.py (modified) (12 diffs)
- cacic/trunk/agente-linux/pycacic/src/glade/logo.png (modified) (previous)
- cacic/trunk/agente-linux/pycacic/src/globals.py (added)
- cacic/trunk/agente-linux/pycacic/src/gui.py (modified) (3 diffs)
- cacic/trunk/agente-linux/pycacic/src/run.sh (added)
Legenda:
- Não modificado
- Adicionado
- Removido
- Modificado
- Copiado
- Movido
cacic/trunk/agente-linux/pycacic/src/cacic.py
r417 r430 8 8 from socket import * 9 9 from ger_cols import * 10 from config.io import Writer 11 from globals import Globals 10 12 11 13 class Cacic: … … 13 15 VERSION = '1.0.0' 14 16 15 def __init__(self): 16 17 sys.path[0] = self.getDir() 18 19 print "\n\tBem-Vindo ao PyCacic\n" 20 try: 17 def __init__(self): 18 #try: 19 if not Globals.INSTALLED: 20 self.install() 21 21 22 if not self.isRoot(): 22 23 raise Exception("Para executar o programa é necessário estar como super usuário (root).") 24 25 print "\n\tBem-Vindo ao PyCacic\n" 23 26 # flags do Gerente de Coletas 24 27 self.gc_stopped = False 25 28 self.gc_started = False 26 29 self.gc_ok = False 27 self.isforcada = False30 self.isforcada = [] 28 31 # Gerente de Coletas 29 32 self.gc = Ger_Cols(self.VERSION) … … 55 58 # se nao estiver executando e esta habilitado a executar 56 59 # ou e uma coleta forcada 57 if not self.gc_started and (self.gc_ok or self.isforcada):60 if not self.gc_started and (self.gc_ok or len(self.isforcada) > 0): 58 61 # muda estado para nao habilitado 59 62 self.gc_ok = False 60 63 # inicia coletas 61 self.gc.coleta _forcada= self.isforcada62 thread.start_new_thread(self.start, ()) 64 self.gc.coletas_forcadas = self.isforcada 65 thread.start_new_thread(self.start, ()) 63 66 # executa thread para escutar o socket 64 67 thread.start_new_thread(self.checkSocket, ()) … … 66 69 # fechando conexao 67 70 self.udp_sock.close() 68 except Exception, e: 69 print e 70 71 def getDir(self): 72 av = sys.argv[0] 73 if av[0] == "/": 74 return os.path.dirname(av) 75 else: 76 return os.path.dirname(os.getcwd() + "/" + av) 71 #except Exception, e: 72 # print e 77 73 78 74 def isRoot(self): … … 81 77 return False 82 78 return True 79 80 def install(self): 81 """Abre console para configuracao do PyCacic""" 82 print "\n\t--- Bem-Vindo a Configuracao do PyCacic ---" 83 print "\n\tapos preencher as informacoes abaixo o programa ira iniciar\n" 84 addr = raw_input("End. do Servidor ('ex: http://10.0.0.1'): ") 85 user = raw_input("Usuario do Servidor: ") 86 pwd = raw_input("Senha: ") 87 if raw_input("\n\t*** Os dados estao corretos? [y|n]").lower() != 'y': 88 self.install() 89 else: 90 Writer.setStatus('installed', True) 91 if addr[len(addr)-1] == '/': addr = addr[:-1] 92 Writer.setServer('address', addr) 93 Writer.setServer('username', user) 94 Writer.setServer('password', pwd) 95 print "\t--- Configuracao concluida com sucesso ---\n\n" 83 96 84 97 def start(self): … … 86 99 try: 87 100 self.gc_started = True 88 if self.isforcada: 89 self.isforcada = False 90 print '*** iniciando coleta forcada ***' 101 self.isforcada = [] 91 102 print(" --- INICIO DAS COLETAS ---") 92 print('\tColetas a serem feitas: \n\t%s' % ', '.join(self.gc.coletas)) 103 print 'Total Coletas: %s' % len(self.gc.coletores) 104 print('\tColetas a serem feitas: \n\t(%s)' % ', '.join(self.gc.coletores.keys())) 93 105 self.gc.startColeta() 94 106 self.gc.createDat() … … 113 125 """Verifica comunicacao com a interface""" 114 126 data, self.addr = self.udp_sock.recvfrom(self.buf) 115 self.isforcada = (data == 'col_hard')127 self.isforcada.append(data) 116 128 time.sleep(1) 117 129 118 130 119 131 if __name__ == '__main__': 132 ver = sys.version_info 133 version = int(''.join([ '%s' %sys.version_info[x] for x in range(3)])) 134 if version < 240: 135 print "ERROR: Python 2.4 or greater required" 136 sys.exit(1) 120 137 Cacic() 121 cacic/trunk/agente-linux/pycacic/src/coletores/col_hard.py
r419 r430 18 18 from time import strftime 19 19 from coletor import * 20 from lib.computador import *21 20 22 21 class Col_Hard(Coletor): … … 28 27 def __init__(self, computer): 29 28 Coletor.__init__(self, computer) 29 30 def getName(self): 31 return "col_hard" 30 32 31 33 def start(self): … … 52 54 # Placas de Video 53 55 if len(self.computer.getVideo()) > 0: 54 cores , desc, vmem = self.computer.getVideo()[0].getCores(), self.computer.getVideo()[0].getDescricao(), self.computer.getVideo()[0].getRam() 56 video = self.computer.getVideo()[0] 57 cores = video.getCores() 58 desc = video.getDescricao() 59 vmem = video.getRam() 60 resolucao = video.getResolucao() 55 61 else: 56 cores , desc, vmem ='', '', ''62 cores , desc, vmem, resolucao = '', '', '', '' 57 63 self.addChave('qt_placa_video_cores', cores) 58 64 self.addChave('te_placa_video_desc', desc) 65 self.addChave('te_placa_video_resolucao', resolucao) 59 66 self.addChave("qt_placa_video_mem", vmem) 60 67 # Placas de Som … … 77 84 self.addChave('Inicio', inicio) 78 85 self.addChave('Fim', strftime("%H:%M:%S")) 79 80 def getName(self):81 return "col_hard"82 86 83 def isReady(self): 84 return self.getUVCDat(self.OUTPUT_DAT, 'Coleta.Hardware') != self.getChave('UVC') 85 86 """ 87 def dictToPost(self): 88 d = {} 89 d['te_Tripa_TCPIP'] = self.encripta(self.dicionario['te_Tripa_TCPIP']) 90 d['te_Tripa_CPU'] = self.encripta(self.dicionario['te_Tripa_CPU']) 91 d['te_Tripa_CDROM'] = self.encripta(self.dicionario['te_Tripa_CDROM']) 92 d['te_mem_ram_desc'] = self.encripta(self.dicionario['te_mem_ram_desc']) 93 d['qt_mem_ram'] = self.encripta(self.dicionario['qt_mem_ram']) 94 d['te_bios_desc'] = self.encripta(self.dicionario['te_bios_desc']) 95 d['te_bios_data'] = self.encripta(self.dicionario['te_bios_data']) 96 d['te_bios_fabricante'] = self.encripta(self.dicionario['te_bios_fabricante']) 97 d['te_placa_mae_fabricante'] = self.encripta(self.dicionario['te_placa_mae_fabricante']) 98 d['te_placa_mae_desc'] = self.encripta(self.dicionario['te_placa_mae_desc']) 99 d['te_placa_video_desc'] = self.encripta(self.dicionario['te_placa_video_desc']) 100 d['qt_placa_video_cores'] = self.encripta(self.dicionario['qt_placa_video_cores']) 101 d['qt_placa_video_mem'] = self.encripta(self.dicionario['qt_placa_video_mem']) 102 d['te_placa_som_desc'] = self.encripta(self.dicionario['te_placa_som_desc']) 103 d['te_teclado_desc'] = self.encripta(self.dicionario['te_teclado_desc']) 104 d['te_modem_desc'] = self.encripta(self.dicionario['te_modem_desc']) 105 d['te_mouse_desc'] = self.encripta(self.dicionario['te_mouse_desc']) 106 return d 107 """ 87 def isReady(self, dat): 88 return self.getUVCDat(dat, 'Coleta.Hardware') != self.getChave('UVC') 108 89 109 90 def getFirst(self, list): cacic/trunk/agente-linux/pycacic/src/coletores/col_network.py
r424 r430 1 2 import socket 3 import struct 4 1 5 from coletor import * 2 6 from lib.computador import Rede 3 7 from lib.computador import Computador 4 import socket 5 import struct 8 from globals import Globals 6 9 7 10 class Col_Network(Coletor): … … 12 15 self.computer = computer 13 16 17 def isReady(self, dat=None): 18 # evita coletar network se estiver usando uma XML de outra maquina 19 return Globals.PC_XML == "" 20 14 21 def getName(self): 15 22 return "col_network" … … 19 26 20 27 def setDicionario(self): 21 """Monta o dicionario""" 28 """Monta o dicionario""" 29 net = None; 22 30 for nw in self.computer.getPlacaRede(): 23 if nw.getIP() == self.computer.ip _ativo:31 if nw.getIP() == self.computer.ipAtivo: 24 32 net = nw 25 33 break 26 34 self.dicionario.clear() 27 self.addChave("te_ip", self.computer.ip_ativo) 28 self.addChave('te_dns_primario', net.getDNS()[0]) 29 self.addChave('te_dns_secundario', net.getDNS()[1]) 30 self.addChave('te_dominio_dns', net.getDNSDomain()) 31 self.addChave('te_mascara', net.getMascara()) 32 self.addChave('te_nome_host', self.computer.getHostName()) 33 self.addChave('te_gateway', net.getGateway()) 34 self.addChave("te_serv_dhcp", net.getDHCP()) 35 if net != None: 36 self.addChave("te_ip", self.computer.ipAtivo) 37 self.addChave('te_dns_primario', net.getDNS()[0]) 38 self.addChave('te_dns_secundario', net.getDNS()[1]) 39 self.addChave('te_dominio_dns', net.getDNSDomain()) 40 self.addChave('te_mascara', net.getMascara()) 41 self.addChave('te_nome_host', self.computer.getHostName()) 42 self.addChave('te_gateway', net.getGateway()) 43 self.addChave("te_serv_dhcp", net.getDHCP()) 35 44 36 cacic/trunk/agente-linux/pycacic/src/coletores/coletor.py
r419 r430 15 15 from lib.arquivo import * 16 16 from lib.ccrypt import * 17 from lib.computador import Computador 18 from globals import Globals 17 19 18 20 class Coletor: … … 63 65 64 66 65 def isReady(self ):67 def isReady(self, dat=None): 66 68 """ Retorna True se o coletor está pronto/pretende enviar uma coleta, False caso contrário """ 67 69 return True cacic/trunk/agente-linux/pycacic/src/coletores/lib/ccrypt.py
r429 r430 33 33 AES.key_size = 32 # 32 bytes = 256 bits 34 34 mode = AES.MODE_CBC 35 KEY = 'Cacic Brasil'35 KEY = 'CacicES2005' 36 36 IV = 'abcdefghijklmnop' 37 37 cipher = AES.new cacic/trunk/agente-linux/pycacic/src/coletores/lib/ccrypt_lib.py
r419 r430 4 4 """ 5 5 import commands, sys 6 from globals import Globals 6 7 7 8 import sys … … 12 13 # AES.so paths 13 14 dic = { 14 '32' : '%s/coletores/lib/x32' % sys.path[0],15 '64' : '%s/coletores/lib/x64' % sys.path[0],16 '32_4' : '%s/coletores/lib/x32/libc4' % sys.path[0],15 '32' : '%s/coletores/lib/x32' % Globals.PATH, 16 '64' : '%s/coletores/lib/x64' % Globals.PATH, 17 '32_4' : '%s/coletores/lib/x32/libc4' % Globals.PATH, 17 18 } 18 19 # output uname shell … … 25 26 TODO: pegar a versao do glib instalada 26 27 """ 27 sys.path.append(dic['32 '])28 sys.path.append(dic['32_4']) 28 29 29 30 else: cacic/trunk/agente-linux/pycacic/src/coletores/lib/computador.py
r419 r430 21 21 import socket, fcntl, struct 22 22 from xml.dom import minidom, Node 23 from globals import Globals 23 24 24 25 … … 115 116 116 117 def __init__(self) : 118 self.res = "" 117 119 self.cores = 0 # int 118 120 self.ram = 0.0 # double … … 128 130 # returns 129 131 self.ram = ram 132 133 def getResolucao (self) : 134 """ retorna a resolução do video """ 135 # returns double 136 return self.res 137 138 def setResolucao (self, res) : 139 """ define a resolução do video """ 140 # returns 141 self.res = res 130 142 131 143 def getCores (self) : … … 273 285 Gets the Network IP based on this machine IP and the mask. 274 286 """ 275 longnetmask = struct.unpack('!I', socket.inet_aton(netmask))[0] 276 longip = struct.unpack('!I', socket.inet_aton(ip))[0] 277 longnetwork = longnetmask & longip 278 network = socket.inet_ntoa(struct.pack("!I", longnetwork)) 279 return network 287 if netmask != "": 288 longnetmask = struct.unpack('!I', socket.inet_aton(netmask))[0] 289 longip = struct.unpack('!I', socket.inet_aton(ip))[0] 290 longnetwork = longnetmask & longip 291 network = socket.inet_ntoa(struct.pack("!I", longnetwork)) 292 return network 293 return "" 280 294 281 295 def __getMac__(self, ip): … … 291 305 ls = commands.getoutput("netstat -rn | grep " + logicalname).split('\n') 292 306 for l in ls: 293 if self.__getIpList__(l)[0] == '0.0.0.0': 294 return self.__getIpList__(l)[1] 307 iplist = self.__getIpList__(l) 308 if len(iplist) > 0: 309 if self.__getIpList__(l)[0] == '0.0.0.0': 310 return self.__getIpList__(l)[1] 295 311 return '' 296 312 … … 493 509 def getXML(self): 494 510 """Executa o binario para gerar arquivo xml com as informacoes do hardware""" 495 lshw = "%s/coletores/lib/lshw" % sys.path[0] 511 if Globals.PC_XML != "": 512 f = open(Globals.PC_XML) 513 content = f.read() 514 return content 515 516 lshw = "%s/coletores/lib/lshw" % Globals.PATH 496 517 if os.path.exists(lshw): 497 518 # modificando a permissao do arquivo … … 519 540 raise ComputerException(e.message) 520 541 except Exception, e: 542 print e 543 import traceback 544 traceback.print_exc() 521 545 raise ComputerException('Erro ao abrir arquivo XML, formato inesperado') 522 546 … … 540 564 if a == 'id' and valor[0:3] == 'pci': 541 565 self.getPCIInfo(filho) 566 if a == 'id' and valor == 'display': 567 self.getVideoInfo(filho) 542 568 if a == 'id' and valor == 'bridge': 543 569 self.getRedeInfo(filho) … … 550 576 if filho.nodeName == 'version': 551 577 # expressao regular para pegar data da bios 552 p = re.compile('[0-9] [1-9]/[0-9][1-9]/[1-9][0-9][0-9][0-9]')578 p = re.compile('[0-9]{1,2}/[0-9]{1,2}/[0-9]{1,4}') 553 579 self.bios.setData(p.findall(filho.firstChild.nodeValue)[0]) 554 580 self.bios.setDescricao(filho.firstChild.nodeValue) … … 649 675 if filho.nodeName == 'product': 650 676 desc2 = filho.firstChild.nodeValue 651 if filho.nodeName == 'width':652 video.setCores(filho.firstChild.nodeValue)677 #if filho.nodeName == 'width': 678 # video.setCores(filho.firstChild.nodeValue) 653 679 video.setDescricao(desc1 + ' - ' + desc2) 654 video.setRam(self.getVideoSystemInfo())680 self.__getVideoSystemInfo__(video) 655 681 self.video.append(video) 656 682 657 def getVideoSystemInfo(self):658 """Pega as informacoes de Video atraves da linha de comando"""683 def __getVideoSystemInfo__(self, video): 684 """Pega as informacoes de Video atraves da linha de comando""" 659 685 s = commands.getoutput("grep -i video /var/log/Xorg.0.log") 660 686 s = s.lower() … … 664 690 fim = (s.find("k",primeiro)) 665 691 if(primeiro > 0 and fim > 0): 666 return int(s[primeiro:fim])/1024 667 return DEFAULT_STRING_VALUE 692 video.setRam(int(s[primeiro:fim])/1024) 693 s = commands.getoutput("grep -i *Built-in /var/log/Xorg.0.log") 694 pesqBus = s.find("*Built-in mode ") 695 if pesqBus > 0: 696 primeiro = pesqBus+16 697 fim = s.find("\n", primeiro) 698 video.setResolucao(s[primeiro:fim]) 699 s = commands.getoutput('grep -i "(--) Depth" /var/log/Xorg.0.log') 700 pesqBus = s.find("format is ") 701 if pesqBus > 0: 702 primeiro = pesqBus+10 703 fim = s.find(" ", primeiro) 704 video.setCores(s[primeiro:fim]) 668 705 669 706 def getIDEInfo(self, no): … … 954 991 def __init__(self): 955 992 devices = self.__get_input_devices__() 956 self.ip _ativo = ''993 self.ipAtivo = '' 957 994 self.hostName = self.__get_host_name__() 995 self.ultimoLogin = self.__get_last_login__() 958 996 self.so = SO_Info.getSO() 959 997 self.mouse = devices['mouse'] … … 978 1016 979 1017 def coletar(self): 980 print "COLETAR"981 1018 """Inicia a coleta de informacoes do computador""" 982 1019 try: … … 1000 1037 def __get_host_name__(self): 1001 1038 """Retorna o hostname da maquina atraves de socket""" 1002 return socket.gethostname() 1003 1039 return socket.gethostname() 1004 1040 1005 1041 def __get_last_login__(self): cacic/trunk/agente-linux/pycacic/src/coletores/lib/url.py
r419 r430 45 45 dados['te_nome_computador'] = defaults['hostname'] 46 46 dados['padding_key'] = defaults['padding_key'] 47 dados[' agente'] = defaults['agente_cacic']47 dados['AgenteLinux'] = defaults['agente_linux'] 48 48 49 49 query = urllib.urlencode(dados) cacic/trunk/agente-linux/pycacic/src/coletores/lib/x32/Crypto/__init__.py
r419 r430 1 cacic/trunk/agente-linux/pycacic/src/config/cacic.conf
r420 r430 2 2 <config> 3 3 <status> 4 <param id="install " value="OK" />5 <param id="test" value=" NOK" />4 <param id="installed" value="yes" /> 5 <param id="test" value="no" /> 6 6 </status> 7 7 <server id="gerente_web"> … … 22 22 <coletor id="col_network" page="set_tcp_ip.php" /> 23 23 <coletor id="col_hard" page="set_hardware.php" /> 24 <coletor id="col_soft" page="set_software.php" /> 25 <coletor id="col_patr" page="set_patrimonio.php" /> 24 26 </coletores> 25 27 </config> cacic/trunk/agente-linux/pycacic/src/config/io.py
r420 r430 15 15 from xml.dom import minidom, Node 16 16 17 18 17 class IOConfig: 19 18 """ … … 24 23 dele. 25 24 """ 26 25 27 26 FILE = '%s/config/cacic.conf' % sys.path[0] 28 27 … … 173 172 return node.replace(old, ('%s="%s"' % (attrib, value))) 174 173 175 def setServer( address, agent, password):176 """ Grava endereco, arquivo e password do Gerente Web no XML"""174 def setServer(node, value): 175 """Altera o no especificado das informacoes do servidor""" 177 176 config = IOConfig.getFile() 178 177 re_sv = re.compile('<server(?:.|\n)*</server>') 179 re_ws = re.compile('<ws.*</ws>') 180 re_ad = re.compile('<address.*</address>') 181 re_ag = re.compile('<agent.*</agent>') 182 re_pw = re.compile('<password.*</password>') 183 sv = re_sv.findall(config)[0] 184 ws = re_ws.findall(sv)[0] 185 ad = re_ad.findall(sv)[0] 186 ag = re_ag.findall(sv)[0] 187 pw = re_pw.findall(sv)[0] 178 re_node = re.compile('<%s.*</%s>' % (node, node)) 179 sv = re_sv.findall(config)[0] 180 if len(re_node.findall(sv)) == 0: 181 return False 182 node = re_node.findall(sv)[0] 188 183 server = sv 189 server = server.replace(ws, Writer.setNodeValue(ws, address)) 190 server = server.replace(ad, Writer.setNodeValue(ad, address)) 191 server = server.replace(ag, Writer.setNodeValue(ag, agent)) 192 server = server.replace(pw, Writer.setNodeValue(pw, password)) 184 server = server.replace(node, Writer.setNodeValue(node, value)) 193 185 Writer.saveXML(config.replace(sv, server)) 194 186 … … 202 194 status = st 203 195 if (v): 204 v = " OK"196 v = "yes" 205 197 else: 206 v = " NOK"198 v = "no" 207 199 status = status.replace(pr, Writer.setNodeAttrib(pr, "value", v)) 208 200 Writer.saveXML(config.replace(st, status)) cacic/trunk/agente-linux/pycacic/src/ger_cols.py
r417 r430 18 18 from coletores.col_network import * 19 19 from coletores.col_hard import * 20 from coletores.col_soft import * 21 from coletores.col_patr import * 20 22 21 23 from coletores.lib.url import * … … 30 32 31 33 from config.io import * 34 35 from globals import Globals 32 36 33 37 … … 44 48 """ 45 49 46 OUTPUT_DAT = '%s/cacic2.dat' % sys.path[0]50 OUTPUT_DAT = '%s/cacic2.dat' % Globals.PATH 47 51 48 52 def __init__(self, version): … … 78 82 self.update_user = '' 79 83 self.update_pass = '' 80 # coletores81 self.initColetores()82 84 # coletas a serem realizadas 83 self.colet as = []85 self.coletores = {} 84 86 self.coletas_enviar = {} 85 self.coleta_forcada = False 87 # lista com as coletas forcadas 88 self.coletas_forcadas = [] 89 # se for True forca todas as coletas 90 self.all_forcada = False 86 91 # Informacoes a serem passadas para o Gerente Web 87 self.computador.ip _ativo = self.computador.getIPAtivo(self.cacic_server)92 self.computador.ipAtivo = self.computador.getIPAtivo(self.cacic_server) 88 93 net = Rede() 89 netmask = net.__getMask__(self.computador.ip _ativo)90 iprede = net.__getIPRede__(self.computador.ip _ativo, netmask);94 netmask = net.__getMask__(self.computador.ipAtivo) 95 iprede = net.__getIPRede__(self.computador.ipAtivo, netmask); 91 96 self.defaults = { 92 'agente_ cacic' : self.coletor.encripta('pycacic'),97 'agente_linux' : self.coletor.encripta('PyCacic'), 93 98 'user' : self.coletor.encripta(server['username']), 94 99 'pwd' : self.coletor.encripta(server['password']), … … 97 102 'te_so' : self.coletor.encripta(self.computador.getSO()), 98 103 'hostname' : self.coletor.encripta(self.computador.getHostName()), 99 'ip' : self.coletor.encripta(self.computador.ip _ativo),104 'ip' : self.coletor.encripta(self.computador.ipAtivo), 100 105 'id_rede' : self.coletor.encripta(iprede), 101 'mac' : self.coletor.encripta(self.computador.getMACAtivo(self.computador.ip _ativo)),106 'mac' : self.coletor.encripta(self.computador.getMACAtivo(self.computador.ipAtivo)), 102 107 'padding_key' : self.coletor.getPadding(), 103 108 } … … 105 110 'te_versao_cacic' : version, 106 111 'te_versao_gercols' : version, 107 'in_chkcacic' : self.coletor.encripta( Reader.getStatus('install')['value']),108 'in_teste' : self.coletor.encripta( Reader.getStatus('test')['value']),112 'in_chkcacic' : self.coletor.encripta(''), 113 'in_teste' : self.coletor.encripta(''), 109 114 'te_workgroup' : self.coletor.encripta('Desconhecido'), 110 115 'te_nome_computador' : self.coletor.encripta(self.computador.getHostName()), … … 118 123 self.separador = '=CacicIsFree=' 119 124 120 def initColetores(self):121 self.coletores = {}122 """ Network """123 col_network = Col_Network(self.computador)124 self.coletores[col_network.getName()] = col_network125 """ Hardware """126 col_hard = Col_Hard(self.computador)127 self.coletores[col_hard.getName()] = col_hard128 125 129 126 def start(self): … … 169 166 170 167 def addColeta(self, col, valor): 171 """Adiciona a coletana lista, se o seu valor for 'S'"""168 """Adiciona o coletor na lista, se o seu valor for 'S'""" 172 169 if valor.upper() == 'S': 173 self.colet as.append(col)170 self.coletores[col.getName()] = col 174 171 175 172 def readXML(self, xml): 176 173 """ Le o XML gerado pelo servidor WEB """ 177 174 # returns void 178 self.coletas = ['tcp_ip']179 175 self.xml = minidom.parseString(xml) 180 176 # se nao achar o status==OK, retorna … … 182 178 raise Exception('Erro ao ler XML do servidor, status não disponível') 183 179 root = self.xml.getElementsByTagName('CONFIGS')[0] 180 # Coletores 181 self.coletores.clear() 182 self.addColeta(Col_Network(self.computador), 'S') 184 183 for no in root.childNodes: 185 184 if no.nodeType == Node.ELEMENT_NODE: … … 189 188 # COLETAS 190 189 elif no.nodeName == 'cs_coleta_forcada' and self.decode(no.firstChild.nodeValue) == 'OK': 191 self.coleta_forcada = True 192 elif no.nodeName == 'cs_coleta_compart': 193 self.addColeta('col_comp', self.decode(no.firstChild.nodeValue)) 190 self.all_forcada = True 191 elif no.nodeName == 'cs_coleta_compart': 192 #self.addColeta(None, self.decode(no.firstChild.nodeValue)) 193 pass 194 194 elif no.nodeName == 'cs_coleta_hardware': 195 self.addColeta( 'col_hard', self.decode(no.firstChild.nodeValue))195 self.addColeta(Col_Hard(self.computador), self.decode(no.firstChild.nodeValue)) 196 196 elif no.nodeName == 'cs_coleta_monitorado': 197 self.addColeta('col_moni', self.decode(no.firstChild.nodeValue)) 197 #self.addColeta(None, self.decode(no.firstChild.nodeValue)) 198 pass 198 199 elif no.nodeName == 'cs_coleta_software': 199 self.addColeta( 'col_soft', self.decode(no.firstChild.nodeValue))200 self.addColeta(Col_Soft(self.computador), self.decode(no.firstChild.nodeValue)) 200 201 elif no.nodeName == 'cs_coleta_unid_disc': 201 self.addColeta('col_undi', self.decode(no.firstChild.nodeValue)) 202 #self.addColeta(None, self.decode(no.firstChild.nodeValue)) 203 pass 202 204 # VERSOES 203 205 elif no.nodeName == 'DT_VERSAO_CACIC2_DISPONIVEL': … … 240 242 def isNew(self, current, new): 241 243 """Compara as versoes, atual com a disponivel.""" 242 return (current.replace('.','') < new.replace('.','')) 243 244 return (current.replace('.','') < new.replace('.','')) 244 245 245 246 def atualiza(self): 246 247 """Atualiza os modulos dos coletores""" 247 # returns void248 248 """ 249 249 TODO: definir como vai ficar a string de destino dos arquivos … … 262 262 263 263 def startColeta(self): 264 """ Inicia as Coletas """ 265 # returns void 266 """ 267 TODO: Habilitar outras coletas alem do Col_Hard (apos as mesmas estarem prontas) 268 """ 264 """ Inicia as Coletas""" 269 265 # limpa o dicionario da ultima coleta 270 266 self.coletas_enviar.clear() 271 267 self.computador.coletar() 268 # adiciona o coletor padrao (Col_Network) 272 269 for col in self.coletores.values(): 273 if self.coleta_forcada or col.isReady():274 col.start()270 col.start() 271 if self.all_forcada or (col.getName() in self.coletas_forcadas) or col.isReady(self.OUTPUT_DAT): 275 272 page = Reader.getColetor(col.getName())['page'] 276 273 dict = col.getEncryptedDict() cacic/trunk/agente-linux/pycacic/src/gui.py
r427 r430 8 8 import commands 9 9 from ger_cols import * 10 from config.io import * 10 from config.io import * 11 from globals import Globals 11 12 12 13 from socket import * … … 15 16 class GUI: 16 17 17 ICON_PATH = "%s/img/logo.png" % sys.path[0]18 GLADE_PATH = '%s/glade/' % sys.path[0]18 ICON_PATH = "%s/img/logo.png" % Globals.PATH 19 GLADE_PATH = '%s/glade/' % Globals.PATH 19 20 20 21 main_visible = False … … 136 137 if __name__ == '__main__': 137 138 try: 139 if not Globals.INSTALLED: 140 raise Exception("O PyCacic nao esta configurado, favor configura-lo.") 138 141 GUI() 139 142 gtk.main()
