def __init__(self, basedir=version.BROBASE, cfgfile=version.CFGFILE, broscriptdir=version.BROSCRIPTDIR, ui=TermUI(), state=None): self.ui = ui self.brobase = basedir self.localaddrs = execute.get_local_addrs(self.ui) self.config = config.Configuration(self.brobase, cfgfile, broscriptdir, self.ui, self.localaddrs, state) if self.config.debug != "0": # clear the log handlers (set by previous calls to logging.*) logging.getLogger().handlers = [] logging.basicConfig(filename=self.config.debuglog, format="%(asctime)s [%(module)s] %(message)s", datefmt=self.config.timefmt, level=logging.DEBUG) self.executor = execute.Executor(self.localaddrs, self.config.helperdir, int(self.config.commandtimeout)) self.plugins = pluginreg.PluginRegistry() self.setup() self.controller = control.Controller(self.config, self.ui, self.executor, self.plugins)
def __init__(self, basedir=version.BROBASE, cfgfile=version.CFGFILE, broscriptdir=version.BROSCRIPTDIR, ui=TermUI(), state=None): self.ui = ui self.brobase = basedir self.config = config.Configuration(self.brobase, cfgfile, broscriptdir, self.ui, state) # Remove all log handlers (set by any previous calls to logging.*) logging.getLogger().handlers = [] if self.config.debug: # Add a log handler that logs to a file. try: logging.basicConfig( filename=self.config.debuglog, format="%(asctime)s [%(module)s] %(message)s", datefmt=self.config.timefmt, level=logging.DEBUG) except IOError as err: raise RuntimeEnvironmentError( "%s\nCheck if the user running BroControl has write access to the debug log file." % err) else: # Add a log handler that does nothing. h = NullHandler() logging.getLogger().addHandler(h) self.executor = execute.Executor(self.config) self.plugins = pluginreg.PluginRegistry() self.setup() self.controller = control.Controller(self.config, self.ui, self.executor, self.plugins)
import time from BroControl import execute from BroControl import config import ssh_runner config.Configuration("/bro/etc/broctl.cfg", '/bro', '', '') config.Config.initPostPlugins() bro_cmds = [] runner_cmds = [] for node in config.Config.nodes('workers'): bro_cmds.append((node, '/bin/echo %s' % node.name)) runner_cmds.append((node.host, ["/bin/echo", node.name])) bro_cmds.sort() runner_cmds.sort() def current(): for res in execute.executeCmdsParallel(bro_cmds): pass #print res m = ssh_runner.MultiMasterManager() def new(): for res in m.exec_multihost_commands(runner_cmds, timeout=15):