def launch_scan(self): print "Info: I try to launch scan", self.scan scan_id = self.scan.get('_id') nmap = self.scan.get('use_nmap') vmware = self.scan.get('use_vmware') names = self.scan.get('names') state = self.scan.get('state') print "Info: IN SCAN WORKER:", nmap, vmware, names, state # Updating the scan entry state self.db.scans.update({'_id': scan_id}, {'$set': {'state': 'preparing'}}) from shinken.discovery.discoverymanager import DiscoveryManager elts = names.splitlines() targets = ' '.join(elts) print "Info: Launching Nmap with targets", targets macros = [('NMAPTARGETS', targets)] overwrite = False runners = ['nmap'] output_dir = None dbmod = 'Mongodb' # By default I want only hosts I never see # TODO: make this an option d = DiscoveryManager('/home/shinken/shinken/etc/discovery.cfg', macros, overwrite, runners, output_dir=output_dir, dbmod=dbmod, only_new_hosts=True) # Set the scan as launched state self.db.scans.update({'_id': scan_id}, {'$set': {'state': 'launched'}}) # #Ok, let start the plugins that will give us the data d.launch_runners() d.wait_for_runners_ends() # We get the results, now we can reap the data d.get_runners_outputs() # and parse them d.read_disco_buf() # Now look for rules d.match_rules() # Ok, we know what to create, now do it! d.write_config() # Set the scan as done :) self.db.scans.update({'_id': scan_id}, {'$set': {'state': 'done'}})
def launch_scan(self): print "Info: I try to launch scan", self.scan scan_id = self.scan.get('_id') names = self.scan.get('names') state = self.scan.get('state') runners = self.scan.get('runners') print "Info: IN SCAN WORKER:", runners, names, state # Updating the scan entry state self.db.scans.update({'_id': scan_id}, {'$set': { 'state': 'preparing' }}) elts = names.splitlines() targets = ' '.join(elts) print "Info: Launching Nmap with targets", targets macros = [('NMAPTARGETS', targets)] overwrite = False output_dir = None dbmod = self.discovery_backend_module # By default I want only hosts I never see # TODO: make this an option d = DiscoveryManager(self.discovery_cfg, macros, overwrite, runners, output_dir=output_dir, dbmod=dbmod, only_new_hosts=True) # Set the scan as launched state self.db.scans.update({'_id': scan_id}, {'$set': {'state': 'launched'}}) # #Ok, let start the plugins that will give us the data d.launch_runners() d.wait_for_runners_ends() # We get the results, now we can reap the data d.get_runners_outputs() # and parse them d.read_disco_buf() # Now look for rules d.match_rules() # Ok, we know what to create, now do it! d.write_config() # Set the scan as done :) self.db.scans.update({'_id': scan_id}, {'$set': {'state': 'done'}})
# if h.get_name() == parent: # print "Houray, we find our parent", self.h.get_name(), "->", h.get_name() # self.parents.append(h.get_name()) cfg_input = opts.cfg_input output_dir = opts.output_dir overwrite = opts.overwrite dbmod = opts.dbmod modules_path = opts.modules_path or '' # Get the Manager for all of the discovery thing d = DiscoveryManager(cfg_input, macros, overwrite, runners, output_dir=output_dir, dbmod=dbmod, backend=backend, modules_path=modules_path, merge=merge) # #Ok, let start the plugins that will give us the data d.launch_runners() d.wait_for_runners_ends() # We get the results, now we can reap the data d.get_runners_outputs() # and parse them d.read_disco_buf()
# for h in all_hosts: # print "Is it you?", h.get_name() # if h.get_name() == parent: # print "Houray, we find our parent", self.h.get_name(), "->", h.get_name() # self.parents.append(h.get_name()) cfg_input = opts.cfg_input output_dir = opts.output_dir overwrite = opts.overwrite dbmod = opts.dbmod modules_path = opts.modules_path or '' # Get the Manager for all of the discovery thing d = DiscoveryManager(cfg_input, macros, overwrite, runners, output_dir=output_dir, dbmod=dbmod, backend=backend, modules_path=modules_path, merge=merge) # #Ok, let start the plugins that will give us the data d.launch_runners() d.wait_for_runners_ends() # We get the results, now we can reap the data d.get_runners_outputs() # and parse them d.read_disco_buf() # Now look for rules d.match_rules() d.loop_discovery()