예제 #1
0
 def analyze_windows_server(self):
     """
     Function wich manage all windows analyzer
     """      
     a_kb = None
     
     a_kb = asw.AnalyzeWindowsKB(self.server, self.config, self.lock)
     
     a_kb.start()
     a_kb.join() 
     
     # Print reports if setted in the configuration file
     if self.config.print_reports:
         a_kb.print_results()
         
     # Save results in a file at the logs path if setted in the configuration file
     if self.config.server_results_save_in_file or self.config.save_reports_in_file:
         file_result_name = self.server.name + "_server_report.txt"
         file_result = open(self.config.logs_path + file_result_name,"wb")
         
         orig_stdout = sys.stdout
         sys.stdout = file_result
 
         print self.server
         a_kb.print_results()
         
         sys.stdout = orig_stdout
         file_result.close()
     
     # Merge different logs files in a single file
     tools.merge_logs(self.config)
예제 #2
0
def Import_servers_from_folder(foldername, config):
    """ 
    Function which import several server archives in a folder
    """
    logger = tools.create_logger(__name__, config)
    
    if os.path.isdir(foldername):
        architecture_to_import = archi.Architecture()
        architecture_to_import.servers = devices.ServerList()
        file_list = os.listdir(foldername)
        for file_elem in file_list:
            path = os.path.join(foldername, file_elem)
            srv = Import_server_from_archive(path, config)
            architecture_to_import.servers.add_server(srv)
            
        create_ip_hostname_common(architecture_to_import)
        logger.info(str(architecture_to_import.servers.counter) + " servers imported from the folder : " + str(foldername))
        
        tools.merge_logs(config)
        return architecture_to_import

    else:
        logger.error("Folder not found")
        return False
예제 #3
0
 def analyze_debian_server(self):
     
     a_kernel = None
     a_packages = None
     a_process = None
     a_files = None
     a_ssh = None
     a_cron = None
     
     if "AnalyzeDebianKernel" in self.config.server_debian_scenarii:
         a_kernel = asd.AnalyzeDebianKernel(self.server, self.config, self.lock)
     if "AnalyzeDebianPackages" in self.config.server_debian_scenarii:
         a_packages = asd.AnalyzeDebianPackages(self.server, self.config, self.lock)
     if "AnalyzeProcesses" in self.config.server_debian_scenarii:
         a_process = asl.AnalyzeProcesses(self.server, self.config)
     if "AnalyzeFiles" in self.config.server_debian_scenarii:
         a_files = asl.AnalyzeFiles(self.server, self.config)
     if "AnalyzeSSH" in self.config.server_debian_scenarii:
         a_ssh = asl.AnalyzeSSH(self.server, self.config)
     if "AnalyzeCron" in self.config.server_debian_scenarii:
         a_cron = asl.AnalyzeCron(self.server, self.config)
         
     a_list = [a_kernel, a_packages, a_process, a_files, a_ssh, a_cron]
     
     start_time = time.time()
     for scenario in a_list:
         if scenario is not None:
             scenario.start()
     
     for scenario in a_list:
         if scenario is not None:
             scenario.join()
     
     stop_time = time.time()
     
     # Print reports if setted in the configuration file
     if self.config.print_reports:
         for scenario in a_list:
             if scenario is not None:
                 scenario.print_results()
     
     # Save results in a file at the logs path if setted in the configuration file
     if self.config.server_results_save_in_file or self.config.save_reports_in_file:
         file_result_name = self.server.name + "_server_report.txt"
         file_result = open(self.config.logs_path + file_result_name,"wb")
         
         orig_stdout = sys.stdout
         sys.stdout = file_result
 
         print self.server
         
         if a_ssh is not None:
             a_ssh.print_results()
         if a_packages is not None:
             a_packages.print_results(True)  
         if a_files is not None:
             a_files.print_results(True)
         if a_kernel is not None:
             a_kernel.print_results()
         if a_process is not None:
             a_process.print_results()
         if a_cron is not None:
             a_cron.print_results()
         
         sys.stdout = orig_stdout
         file_result.close()
     
     # Merge different logs files in a single file
     tools.merge_logs(self.config)
     
     print "Ellapsed time = " + str(stop_time - start_time)
예제 #4
0
    def analyze_redhat_server(self):
#        centos_packages = src.analyzer.CentOS.AnalyzeCentosPackages(self.server, self.config, self.lock)
        
#        a_packages = None
#        
#        a_packages = asrh.AnalyzeRedHatPackages(self.server, self.config, self.lock)
#        
#        start_time = time.time()
#        a_packages.start()
#        a_packages.join() 
#        stop_time = time.time()
#        
#        # Print reports if setted in the configuration file
#        if self.config.print_reports:
#            a_packages.print_results()
#        
#        # Save results in a file at the logs path if setted in the configuration file
#        if self.config.server_results_save_in_file or self.config.save_reports_in_file:
#            file_result_name = self.server.name + "_server_report.txt"
#            file_result = open(self.config.logs_path + file_result_name,"wb")
#            
#            orig_stdout = sys.stdout
#            sys.stdout = file_result
#    
#            print self.server
#            
#            if a_packages is not None:
#                a_packages.print_results(True)
#            
#            sys.stdout = orig_stdout
#            file_result.close()
#        
#        # Merge different logs files in a single file
#        tools.merge_logs(self.config)
#        
#        print "Ellapsed time = " + str(stop_time - start_time)
        
        a_packages = None
        a_process = None
        a_files = None
        a_ssh = None
        a_cron = None     
        
        if "AnalyzeRedHatPackages" in self.config.server_centos_scenarii:
            a_packages = asrh.AnalyzeRedHatPackages(self.server, self.config, self.lock)
        if "AnalyzeProcesses" in self.config.server_centos_scenarii:
            a_process = asl.AnalyzeProcesses(self.server, self.config)
        if "AnalyzeFiles" in self.config.server_centos_scenarii:
            a_files = asl.AnalyzeFiles(self.server, self.config)
        if "AnalyzeSSH" in self.config.server_centos_scenarii:
            a_ssh = asl.AnalyzeSSH(self.server, self.config)
        if "AnalyzeCron" in self.config.server_centos_scenarii:
            a_cron = asl.AnalyzeCron(self.server, self.config)
            
        a_list = [a_packages, a_process, a_files, a_ssh, a_cron]
        
        start_time = time.time()
        for scenario in a_list:
            if scenario is not None:
                scenario.start()
        
        for scenario in a_list:
            if scenario is not None:
                scenario.join()
        
        stop_time = time.time()
        
        # Print reports if setted in the configuration file
        if self.config.print_reports:
            for scenario in a_list:
                if scenario is not None:
                    scenario.print_results()
        
        # Save results in a file at the logs path if setted in the configuration file
        if self.config.server_results_save_in_file or self.config.save_reports_in_file:
            file_result_name = self.server.name + "_server_report.txt"
            file_result = open(self.config.logs_path + file_result_name,"wb")
            
            orig_stdout = sys.stdout
            sys.stdout = file_result
    
            print self.server
            
            if a_ssh is not None:
                a_ssh.print_results()
            if a_packages is not None:
                a_packages.print_results(True)  
            if a_files is not None:
                a_files.print_results(True)
            if a_process is not None:
                a_process.print_results()
            if a_cron is not None:
                a_cron.print_results()
            
            sys.stdout = orig_stdout
            file_result.close()
        
        # Merge different logs files in a single file
        tools.merge_logs(self.config)
        
        print "Ellapsed time = " + str(stop_time - start_time)