def buildOptions(self): """Options, mostly to find where zenhub lives These options should be passed (by file) from zenhub. """ ZCmdBase.buildOptions(self) self.parser.add_option('--hubhost', dest='hubhost', default='localhost', help="Host to use for connecting to ZenHub") self.parser.add_option('--hubport', dest='hubport', type='int', help="Port to use for connecting to ZenHub", default=PB_PORT) self.parser.add_option( '--username', dest='username', help="Login name to use when connecting to ZenHub", default='zenoss') self.parser.add_option( '--password', dest='password', help="password to use when connecting to ZenHub", default='zenoss') self.parser.add_option( '--calllimit', dest='calllimit', type='int', help="Maximum number of remote calls before restarting worker", default=200)
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('-s', '--step', dest='step', type='int', default=300, help='Default step size in seconds') self.parser.add_option('-r', '--root', dest='root', default=performancePath(''), help='Root tree to convert') self.parser.add_option('-f', '--file', dest='filename', help='Root tree to convert') self.parser.add_option('--commit', dest='commit', action='store_true', default=False, help='Really put the converted files in place.') self.parser.add_option('--monitor', dest='monitor', default='localhost', help='Name of this collection host.')
def __init__(self, Klass): ZCmdBase.__init__(self, False, False, False) # It's super annoying to try to figure out how to get the # zenhub service to drop into debug mode. Use the following. setLogLevel(logging.DEBUG) logging.basicConfig() self.service = Klass(self.dmd, self.options.monitor)
def __init__(self): ZCmdBase.__init__(self) self.current = IDLE self.currentStart = 0 self.numCalls = 0 try: self.log.debug("establishing SIGUSR2 signal handler") signal.signal(signal.SIGUSR2, self.sighandler_USR2) except ValueError: # If we get called multiple times, this will generate an exception: # ValueError: signal only works in main thread # Ignore it as we've already set up the signal handler. pass self.zem = self.dmd.ZenEventManager loadPlugins(self.dmd) self.pid = os.getpid() self.services = {} factory = ReconnectingPBClientFactory() self.log.debug("Connecting to %s:%d", self.options.hubhost, self.options.hubport) reactor.connectTCP(self.options.hubhost, self.options.hubport, factory) self.log.debug("Logging in as %s", self.options.username) c = credentials.UsernamePassword(self.options.username, self.options.password) factory.gotPerspective = self.gotPerspective def stop(*args): reactor.callLater(0, reactor.stop) factory.clientConnectionLost = stop factory.startLogin(c)
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('--name', dest='name', default=getfqdn(), help=("host that roots the ping dependency " "tree: typically the collecting hosts' " "name; defaults to our fully qualified " "domain name (%s)" % getfqdn())) self.parser.add_option('--test', dest='test', default=False, action="store_true", help="Run in test mode: doesn't really ping," " but reads the list of IP Addresses that " " are up from /tmp/testping") self.parser.add_option( '--useFileDescriptor', dest='useFileDescriptor', default=None, help="use the given (privileged) file descriptor") self.parser.add_option('--minConfigWait', dest='minconfigwait', default=300, type='int', help="the minimal time, in seconds, " "between refreshes of the config")
def buildOptions(self): """ Command-line options specific to this command """ ZCmdBase.buildOptions(self) self.parser.add_option('-i', '--infile', dest='infile', help='Input file for import. Default is stdin') self.parser.add_option( '--noindex', dest='noindex', action='store_true', default=False, help='Do not try to index the freshly loaded objects.') self.parser.add_option('--chunksize', dest='chunk_size', help='Number of objects to commit at a time.', type='int', default=100) self.parser.add_option( '-n', '--noCommit', dest='noCommit', action='store_true', default=0, help='Do not store changes to the DMD (ie for debugging purposes)', )
def buildOptions(self): """ Add our command-line options to the basics """ ZCmdBase.buildOptions(self) self.parser.add_option('--show_options', dest="show_options", default=False, action="store_true", help="Show the various options understood by the loader") self.parser.add_option('--sample_configs', dest="sample_configs", default=False, action="store_true", help="Show an example configuration file.") self.parser.add_option('--showModelOutput', dest="showModelOutput", default=True, action="store_false", help="Show modelling activity") self.parser.add_option('--nocommit', dest="nocommit", default=False, action="store_true", help="Don't commit changes to the ZODB. Use for verifying config file.") self.parser.add_option('--nomodel', dest="nomodel", default=False, action="store_true", help="Don't model the remote devices. Must be able to commit changes.")
def __init__(self, *args, **kwargs): ZCmdBase.__init__(self, *args, **kwargs) self.defaults = {} self.collectorNames = self.dmd.Monitors.getPerformanceMonitorNames() self.loader = self.dmd.DeviceLoader.loadDevice self.fqdn = socket.getfqdn() self.baseEvent = dict( device=self.fqdn, component='', agent='zenbatchload', monitor='localhost', manager=self.fqdn, severity=SEVERITY_ERROR, # Note: Change_Add events get sent to history by the event class' Zen property eventClass=Change_Add, ) # Create the list of options we want people to know about self.loader_args = dict.fromkeys( self.loader.func_code.co_varnames ) unsupportable_args = [ 'REQUEST', 'device', 'self', 'xmlrpc', 'e', 'handler', ] for opt in unsupportable_args: if opt in self.loader_args: del self.loader_args[opt]
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('--commit', dest="commit", action='store_true', default=False, help="Commit changes to the database") self.parser.add_option('--name', dest="name", default='Test', help="Root name for test devices, etc.") self.parser.add_option('--repeat', dest="repeat", type="int", default=1, help="Number of devices to create") self.parser.add_option('--everywhere', dest="everywhere", default=False, action='store_true', help="Create device(s) for every existing" " event class") self.parser.add_option('--onlyleafclasses', dest="onlyleafclasses", default=False, action='store_true', help="If --everywhere then only create devices" " on leaf nodes of the device class tree.")
def buildOptions(self): """Options, mostly to find where zenhub lives These options should be passed (by file) from zenhub. """ ZCmdBase.buildOptions(self) self.parser.add_option('--hubhost', dest='hubhost', default='localhost', help="Host to use for connecting to ZenHub") self.parser.add_option('--hubport', dest='hubport', type='int', help="Port to use for connecting to ZenHub", default=PB_PORT) self.parser.add_option('--username', dest='username', help="Login name to use when connecting to ZenHub", default='zenoss') self.parser.add_option('--password', dest='password', help="password to use when connecting to ZenHub", default='zenoss') self.parser.add_option('--calllimit', dest='calllimit', type='int', help="Maximum number of remote calls before restarting worker", default=200)
def buildOptions(self): """basic options setup sub classes can add more options here""" ZCmdBase.buildOptions(self) self.parser.add_option("-i", "--infile", dest="infile", help="Input file for import. The default is stdin") print "Build option infile" self.parser.add_option( "-x", "--commitCount", dest="commitCount", default=20, type="int", help="How many lines should be loaded before a database commit", ) self.parser.add_option( "--noindex", dest="noindex", action="store_true", default=False, help="Do not try to index data that was just loaded", ) self.parser.add_option( "-n", "--noCommit", dest="noCommit", action="store_true", default=0, help="Do not store changes to the Dmd (for debugging)", )
def buildOptions(self): """Add optparse options to the options parser.""" ZCmdBase.buildOptions(self) self.parser.add_option( '--hubhost', dest='hubhost', default='localhost', help="Host to use for connecting to ZenHub", ) self.parser.add_option( '--hubport', dest='hubport', type='int', default=PB_PORT, help="Port to use for connecting to ZenHub", ) self.parser.add_option( '--hubusername', dest='hubusername', default='admin', help="Login name to use when connecting to ZenHub", ) self.parser.add_option( '--hubpassword', dest='hubpassword', default='zenoss', help="password to use when connecting to ZenHub", ) self.parser.add_option( '--call-limit', dest='call_limit', type='int', default=200, help="Maximum number of remote calls before restarting worker", ) self.parser.add_option( '--profiling', dest='profiling', action='store_true', default=False, help="Run with profiling on", ) self.parser.add_option( '--monitor', dest='monitor', default='localhost', help='Name of the performance monitor this hub runs on', ) self.parser.add_option( '--workerid', dest='workerid', type='int', default=0, help=SUPPRESS_HELP, )
def buildOptions(self): """ Command-line options specific to this command """ ZCmdBase.buildOptions(self) self.parser.add_option('-i', '--infile', dest='infile', help='Input file for import. Default is stdin' ) self.parser.add_option('--noindex', dest='noindex', action='store_true', default=False, help='Do not try to index the freshly loaded objects.' ) self.parser.add_option('--chunksize', dest='chunk_size', help='Number of objects to commit at a time.', type='int', default=100 ) self.parser.add_option( '-n', '--noCommit', dest='noCommit', action='store_true', default=0, help='Do not store changes to the DMD (ie for debugging purposes)', )
def buildOptions(self): """ Add our command-line options to the basics """ ZCmdBase.buildOptions(self) self.parser.add_option('--root', dest = "root", default = "", help = "Set the root Device Path to dump (eg: /Devices/Servers " "or /Devices/Network/Cisco/Nexus; default: /Devices)") self.parser.add_option('-o', '--outFile', dest = 'outFile', default = sys.__stdout__, help = "Specify file to which zenbatchdump will write output") self.parser.add_option('--regex', dest = 'regex', default = '.*', help = "Specify include filter for device objects") self.parser.add_option('--prune', dest = 'prune', default = False, action = 'store_true', help = "Should DeviceClasses only be dumped if part of root path") self.parser.add_option('--allzprops', dest = 'allzprops', default = False, action = 'store_true', help = "Should z properties (including acquired values) be dumped?") self.parser.add_option('--noorganizers', dest = 'noorganizers', default = False, action = 'store_true', help = "Should organizers (device classes, groups, etc) be dumped?")
def sigTerm(self, signum=None, frame=None): """ Controlled shutdown of main loop on interrupt. """ try: ZCmdBase.sigTerm(self, signum, frame) except SystemExit: self.finish()
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('-f', '--force', dest='force', action='store_true', default=0, help="Force load all the reports")
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('-i', '-f', '--file', dest='eventFile', help='Name of the file to replay') self.parser.set_defaults(logseverity=logging.DEBUG)
def __init__(self): signal.signal(signal.SIGUSR2, signal.SIG_IGN) ZCmdBase.__init__(self) if self.options.profiling: self.profiler = ContinuousProfiler('zenhubworker', log=self.log) self.profiler.start() self.current = IDLE self.currentStart = 0 self.numCalls = Metrology.meter("zenhub.workerCalls") try: self.log.debug("establishing SIGUSR1 signal handler") signal.signal(signal.SIGUSR1, self.sighandler_USR1) self.log.debug("establishing SIGUSR2 signal handler") signal.signal(signal.SIGUSR2, self.sighandler_USR2) except ValueError: # If we get called multiple times, this will generate an exception: # ValueError: signal only works in main thread # Ignore it as we've already set up the signal handler. pass self.zem = self.dmd.ZenEventManager loadPlugins(self.dmd) self.pid = os.getpid() self.services = {} factory = ReconnectingPBClientFactory(pingPerspective=False) self.log.debug("Connecting to %s:%d", self.options.hubhost, self.options.hubport) reactor.connectTCP(self.options.hubhost, self.options.hubport, factory) self.log.debug("Logging in as %s", self.options.username) c = credentials.UsernamePassword(self.options.username, self.options.password) factory.gotPerspective = self.gotPerspective def stop(*args): reactor.callLater(0, reactor.stop) factory.clientConnectionLost = stop factory.setCredentials(c) self.log.debug("Creating async MetricReporter") daemonTags = { 'zenoss_daemon': 'zenhub_worker_%s' % self.options.workernum, 'zenoss_monitor': self.options.monitor, 'internal': True } def stopReporter(): if self.metricreporter: return self.metricreporter.stop() # Order of the shutdown triggers matter. Want to stop reporter first, calling metricWriter() below # registers shutdown triggers for the actual metric http and redis publishers. reactor.addSystemEventTrigger('before', 'shutdown', stopReporter) self.metricreporter = TwistedMetricReporter( metricWriter=metricWriter(), tags=daemonTags) self.metricreporter.start()
def __init__(self): """ Initializer that creates an output file, or if nothing is specified with the command-line option --outfile, sends to stdout. """ ZCmdBase.__init__(self) if not self.options.outfile: self.outfile = sys.stdout else: self.outfile = open(self.options.outfile, 'w')
def buildOptions(self): """ Add our command-line options to the basics """ ZCmdBase.buildOptions(self) self.parser.add_option( '--show_options', dest="show_options", default=False, action="store_true", help="Show the various options understood by the loader") self.parser.add_option('--sample_configs', dest="sample_configs", default=False, action="store_true", help="Show an example configuration file.") self.parser.add_option('--showModelOutput', dest="showModelOutput", default=True, action="store_false", help="Show modelling activity") self.parser.add_option( '--nocommit', dest="nocommit", default=False, action="store_true", help= "Don't commit changes to the ZODB. Use for verifying config file.") self.parser.add_option( '--nomodel', dest="nomodel", default=False, action="store_true", help= "Don't model the remote devices. Must be able to commit changes.") self.parser.add_option( '--reject_file', dest="reject_file", help= "If specified, use as the name of a file to store unparseable lines" ) self.parser.add_option( '--must_be_resolvable', dest="must_be_resolvable", default=False, action="store_true", help="Do device entries require an IP address or be DNS resolvable?" )
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('-f', '--force', dest='force', action='store_true', default=0, help="Load all reports, overwriting any existing reports.") self.parser.add_option('-d', '--dir', dest='dir', default="reports", help="Directory from which to load reports: default '%default'") self.parser.add_option('-p', '--zenpack', dest='zenpack', default='', help="ZenPack from which to load reports")
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option( '--monitor', dest='monitor', default='localhost', help="Specify the collector to collect against.") self.parser.add_option('-d', '--device', dest='device', help="Show the configs for a single device")
def buildOptions(self): """ Add our command-line options to the basics """ ZCmdBase.buildOptions(self) self.parser.add_option( '--root', dest="root", default="", help="Set the root Device Path to dump (eg: /Devices/Servers " "or /Devices/Network/Cisco/Nexus; default: /Devices)") self.parser.add_option( '-o', '--outFile', dest='outFile', default=sys.__stdout__, help="Specify file to which zenbatchdump will write output") self.parser.add_option( '--regex', dest='regex', default='', help="Specify include filter for device objects") self.parser.add_option( '--prune', dest='prune', default=False, action='store_true', help="Should DeviceClasses only be dumped if part of root path") self.parser.add_option( '--allzprops', dest='allzprops', default=False, action='store_true', help="Should z properties (including acquired values) be dumped?") self.parser.add_option( '--noorganizers', dest='noorganizers', default=False, action='store_true', help="Should organizers (device classes, groups, etc) be dumped?") self.parser.add_option( '--collectors_only', dest='collectors_only', default=False, action='store_true', help="Dump only the distributed hub/collector information?")
def buildOptions(self): """ Command-line options """ ZCmdBase.buildOptions(self) self.parser.add_option( '--mibsdir', dest='mibsdir', default=zenPath('share/mibs/site'), help="Directory of input MIB files [ default: %default ]") self.parser.add_option( '--mibdepsdir', dest='mibdepsdir', default=zenPath('share/mibs'), help="Directory of input MIB files [ default: %default ]") self.parser.add_option('--path', dest='path', default="/", help="Path to load MIB into the DMD") self.parser.add_option( '--nocommit', action='store_true', dest='nocommit', default=False, help="Don't commit the MIB to the DMD after loading") self.parser.add_option( '--keeppythoncode', action='store_true', dest='keeppythoncode', default=False, help="Don't commit the MIB to the DMD after loading") self.parser.add_option('--pythoncodedir', dest='pythoncodedir', default=tempfile.gettempdir() + "/mib_pythoncode/", help="This is the directory where the converted MIB will be output. " \ "[ default: %default ]") self.parser.add_option('--downloaddir', dest='downloaddir', default=tempfile.gettempdir() + "/mib_downloads/", help="This is the directory where the MIB will be downloaded. " \ "[ default: %default ]") self.parser.add_option('--extractdir', dest='extractdir', default=tempfile.gettempdir() + "/mib_extract/", help="This is the directory where unzipped MIB files will be stored. " \ "[ default: %default ]") self.parser.add_option('--evalSavedPython', dest='evalSavedPython', default=[], action='append', help="Execute the Python code previously generated" \ " and saved.") self.parser.add_option( '--keepMiddleZeros', dest='keep_middle_zeros', default=False, action='store_true', help="Does not remove zeros found in the middle of the oid.")
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('--cycletime', dest='cycletime', default=60, type="int", help="check events every cycletime seconds") self.parser.add_option( '--zopeurl', dest='zopeurl', default=getDefaultZopeUrl(), help="http path to the root of the zope server") self.parser.add_option("--monitor", dest="monitor", default=DEFAULT_MONITOR, help="Name of monitor instance to use for heartbeat " " events. Default is %s." % DEFAULT_MONITOR)
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('-x', '--commitCount', dest='commitCount', default=20, type="int", help='how many lines should be loaded before commit') self.parser.add_option('-n', '--noCommit', dest='noCommit', action="store_true", default=0, help='Do not store changes to the Dmd (for debugging)')
def __init__(self, noopts=0, app=None, keeproot=False): """ Initializer @param noopts: don't use sys.argv for command-line options @type noopts: boolean @param app: app @type app: object @param keeproot: keeproot @type keeproot: boolean """ ZCmdBase.__init__(self, noopts, app, keeproot) ContentHandler.__init__(self)
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option( '--jabber_pass', dest='jabber_pass', help='Password used to connect to the XMPP server') self.parser.add_option( '--jabber_user', dest='jabber_user', help='Username used to connect to the XMPP server') self.parser.add_option( '--jabber_host', dest='jabber_host', default='localhost', help='XMPP server to connect') self.parser.add_option( '--jabber_port', dest='jabber_port', default='5222', help='Port used to connect to the XMPP server') self.parser.add_option( '--first_user', dest='first_user', help='User mapping to bootstrap the bot with at least on authorized user. Example specification myzenossname,[email protected]') self.parser.add_option( '--im_host', dest='im_host', help='Optional option for addressing IM users when the server is not known. If this is ommitted, jabber_host will be used.') self.parser.add_option( '--ssl', dest='ssl', action='store_true', help='Use ssl.') self.parser.add_option( '--group_server', dest='group_server', help='Conference/groupchat server. If the name has no dots, it will use group_server.jabber_host') self.parser.add_option( '--chatroom', dest='chatroom', help='First chatroom joined to when connecting') self.parser.add_option('--cycletime', dest='cycletime', default=60, type='int', help='check events every cycletime seconds') self.parser.add_option( '--zopeurl', dest='zopeurl', default='http://%s:%d' % (socket.getfqdn(), 8080), help='http path to the root of the zope server') self.parser.add_option('--monitor', dest='monitor', default=DEFAULT_MONITOR, help='Name of monitor instance to use for heartbeat events. Default is %s.' % DEFAULT_MONITOR)
def buildOptions(self): """ Command-line options setup """ ZCmdBase.buildOptions(self) self.parser.add_option('-o', '--outfile', dest="outfile", help="Output file for exporting XML objects. Default is stdout") self.parser.add_option('--ignore', action="append", dest="ignorerels", default=[], help="Relations that should be ignored. Every relation to" + \ " ignore must be specified with a separate --ignorerels option." )
def buildOptions(self): """Add ZenHub command-line options.""" ZCmdBase.buildOptions(self) self.parser.add_option( '--xmlrpcport', '-x', dest='xmlrpcport', type='int', default=server_config.defaults.xmlrpcport, help='Port to use for XML-based Remote Procedure Calls (RPC)') self.parser.add_option('--pbport', dest='pbport', type='int', default=server_config.defaults.pbport, help="Port to use for Twisted's pb service") self.parser.add_option('--passwd', dest='passwordfile', type='string', default=zenPath('etc', 'hubpasswd'), help='File where passwords are stored') self.parser.add_option( '--monitor', dest='monitor', default='localhost', help='Name of the distributed monitor this hub runs on') self.parser.add_option( '--workers-reserved-for-events', dest='workersReservedForEvents', type='int', default=1, help="Number of worker instances to reserve for handling events") self.parser.add_option( '--invalidation-poll-interval', type='int', default=30, help="Interval at which to poll invalidations (default: %default)") self.parser.add_option('--profiling', dest='profiling', action='store_true', default=False, help="Run with profiling on") self.parser.add_option( '--modeling-pause-timeout', type='int', default=server_config.defaults.modeling_pause_timeout, help='Maximum number of seconds to pause modeling during ZenPack' ' install/upgrade/removal (default: %default)') notify(ParserReadyForOptionsEvent(self.parser))
def buildOptions(self): """ Command-line options setup """ ZCmdBase.buildOptions(self) self.parser.add_option( '-o', '--outfile', dest="outfile", help="Output file for exporting XML objects. Default is stdout") self.parser.add_option('--ignore', action="append", dest="ignorerels", default=[], help="Relations that should be ignored. Every relation to" + \ " ignore must be specified with a separate --ignorerels option." )
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('--class', dest='deviceClass', default='/', help="Device class to operate on") self.parser.add_option('--zproperty', dest='zPropName', default=None, help="Name of the zProperty to remove from" " devices") self.parser.add_option('-r', '--recurse', dest='recurse', action="store_true", default=False, help="Recurse into subclasses of --class")
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option( '-x', '--commitCount', dest='commitCount', default=20, type="int", help='how many lines should be loaded before commit') self.parser.add_option( '-n', '--noCommit', dest='noCommit', action="store_true", default=0, help='Do not store changes to the Dmd (for debugging)')
def setUp(cls): zope.component.testing.setUp(cls) zope.component.provideAdapter(DefaultTraversable, (None, )) zcml.load_config('testing-noevent.zcml', Products.ZenTestCase) zodb = ZCmdBase(noopts=True) zem = zodb.dmd.ZenEventManager cls.zem = zem cls._evids = []
def __init__(self): # I don't know a suitable way to get dmd, so # ask ZCmdBase for it. # FIXME 09JUN09: This can have side-effects cmd = ZCmdBase(noopts=True) self.dmd = cmd.dmd self.evManager = self.dmd.ZenEventManager self.stateMap = self.eventStates()
def buildOptions(self): """Options, mostly to find where zenhub lives These options should be passed (by file) from zenhub. """ ZCmdBase.buildOptions(self) self.parser.add_option('--hubhost', dest='hubhost', default='localhost', help="Host to use for connecting to ZenHub") self.parser.add_option('--hubport', dest='hubport', type='int', help="Port to use for connecting to ZenHub", default=PB_PORT) self.parser.add_option( '--username', dest='username', help="Login name to use when connecting to ZenHub", default='zenoss') self.parser.add_option( '--password', dest='password', help="password to use when connecting to ZenHub", default='zenoss') self.parser.add_option( '--calllimit', dest='calllimit', type='int', help="Maximum number of remote calls before restarting worker", default=200) self.parser.add_option('--profiling', dest='profiling', action='store_true', default=False, help="Run with profiling on") self.parser.add_option( '--monitor', dest='monitor', default='localhost', help='Name of the distributed monitor this hub runs on') self.parser.add_option('--workernum', dest='workernum', type='int', default=0)
def __init__(self, reactor): """Initialize a ZenHubWorker instance.""" ZCmdBase.__init__(self) self.__reactor = reactor if self.options.profiling: self.profiler = ContinuousProfiler('ZenHubWorker', log=self.log) self.profiler.start() reactor.addSystemEventTrigger( 'before', 'shutdown', self.profiler.stop, ) self.instanceId = self.options.workerid self.current = IDLE self.currentStart = 0 self.numCalls = Metrology.meter("zenhub.workerCalls") self.zem = self.dmd.ZenEventManager loadPlugins(self.dmd) serviceFactory = ServiceReferenceFactory(self) self.__registry = HubServiceRegistry(self.dmd, serviceFactory) # Configure/initialize the ZenHub client creds = UsernamePassword( self.options.hubusername, self.options.hubpassword, ) endpointDescriptor = "tcp:{host}:{port}".format( host=self.options.hubhost, port=self.options.hubport, ) endpoint = clientFromString(reactor, endpointDescriptor) self.__client = ZenHubClient(reactor, endpoint, creds, self, 10.0) # Setup Metric Reporting self.log.debug("Creating async MetricReporter") self._metric_manager = MetricManager( daemon_tags={ 'zenoss_daemon': 'zenhub_worker_%s' % self.options.workerid, 'zenoss_monitor': self.options.monitor, 'internal': True, }, )
def buildOptions(self): """ Add our command-line options to the basics """ ZCmdBase.buildOptions(self) self.parser.add_option('--show_options', dest="show_options", default=False, action="store_true", help="Show the various options understood by " "the loader") self.parser.add_option('--sample_configs', dest="sample_configs", default=False, action="store_true", help="Show an example configuration file.") self.parser.add_option('--showModelOutput', dest="showModelOutput", default=True, action="store_false", help="Show modelling activity") self.parser.add_option('--nocommit', dest="nocommit", default=False, action="store_true", help="Don't commit changes to the ZODB. " "Use for verifying config file.") self.parser.add_option('--nomodel', dest="nomodel", default=False, action="store_true", help="Don't model the remote devices. " "Must be able to commit changes.") self.parser.add_option('--reject_file', dest="reject_file", help="If specified, use as the name of a file " "to store unparseable lines") self.parser.add_option('--must_be_resolvable', dest="must_be_resolvable", default=False, action="store_true", help="Do device entries require an IP address " "or be DNS resolvable?")
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.usage = "%prog [options] report_plugin [report_paramater=value]*" self.parser.remove_option('--daemon') self.parser.remove_option('--cycle') self.parser.remove_option('--watchdog') self.parser.remove_option('--watchdogPath') self.parser.remove_option('--socketOption') self.parser.add_option("--list", action="store_true", default=False, help="Show full names of all plugins to run. If the plugin" \ " name is unique, just the name may be used." ) self.parser.add_option("--export", default='python', help="Export the values as 'python' (default) or 'csv'") self.parser.add_option("--export_file", default='', help="Optional filename to store the output")
def buildOptions(self): """basic options setup sub classes can add more options here""" ZCmdBase.buildOptions(self) self.parser.add_option("--createcatalog", action="store_true", default=False, help="Create global catalog and populate it") self.parser.add_option("--forceindex", action="store_true", default=False, help="works with --createcatalog to re-create index, if catalog exists it will be "\ "dropped first") self.parser.add_option("--reindex", action="store_true", default=False, help="reindex existing catalog") self.parser.add_option("--permissionsOnly", action="store_true", default=False, help="Only works with --reindex, only update the permissions catalog")
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option( '-f', '--force', dest='force', action='store_true', default=0, help="Load all reports, overwriting any existing reports.") self.parser.add_option( '-d', '--dir', dest='dir', default="reports", help="Directory from which to load reports: default '%default'") self.parser.add_option('-p', '--zenpack', dest='zenpack', default='', help="ZenPack from which to load reports")
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.usage = "%prog [options] report_plugin [report_paramater=value]*" self.parser.remove_option('--daemon') self.parser.remove_option('--cycle') self.parser.remove_option('--watchdog') self.parser.remove_option('--watchdogPath') self.parser.remove_option('--socketOption') self.parser.add_option("--list", action="store_true", default=False, help="Show full names of all plugins to run. If the plugin" \ " name is unique, just the name may be used." ) self.parser.add_option( "--export", default='python', help="Export the values as 'python' (default) or 'csv'") self.parser.add_option("--export_file", default='', help="Optional filename to store the output")
def buildOptions(self): """ Adds our command line options to ZCmdBase command line options. """ ZCmdBase.buildOptions(self) self.parser.add_option( '--xmlrpcport', '-x', dest='xmlrpcport', type='int', default=XML_RPC_PORT, help='Port to use for XML-based Remote Procedure Calls (RPC)') self.parser.add_option( '--pbport', dest='pbport', type='int', default=PB_PORT, help="Port to use for Twisted's pb service") self.parser.add_option( '--passwd', dest='passwordfile', type='string', default=zenPath('etc', 'hubpasswd'), help='File where passwords are stored') self.parser.add_option( '--monitor', dest='monitor', default='localhost', help='Name of the distributed monitor this hub runs on') self.parser.add_option( '--workers-reserved-for-events', dest='workersReservedForEvents', type='int', default=1, help="Number of worker instances to reserve for handling events") self.parser.add_option( '--invalidation-poll-interval', type='int', default=30, help="Interval at which to poll invalidations (default: %default)") self.parser.add_option( '--profiling', dest='profiling', action='store_true', default=False, help="Run with profiling on") self.parser.add_option( '--modeling-pause-timeout', type='int', default=3600, help='Maximum number of seconds to pause modeling during ZenPack' ' install/upgrade/removal (default: %default)') notify(ParserReadyForOptionsEvent(self.parser))
def buildOptions(self): """ Command-line options """ ZCmdBase.buildOptions(self) self.parser.add_option('--mibsdir', dest='mibsdir', default=zenPath('share/mibs/site'), help="Directory of input MIB files [ default: %default ]") self.parser.add_option('--mibdepsdir', dest='mibdepsdir', default=zenPath('share/mibs'), help="Directory of input MIB files [ default: %default ]") self.parser.add_option('--path', dest='path', default="/", help="Path to load MIB into the DMD") self.parser.add_option('--nocommit', action='store_true', dest='nocommit', default=False, help="Don't commit the MIB to the DMD after loading") self.parser.add_option('--keeppythoncode', action='store_true', dest='keeppythoncode', default=False, help="Don't commit the MIB to the DMD after loading") self.parser.add_option('--pythoncodedir', dest='pythoncodedir', default=tempfile.gettempdir() + "/mib_pythoncode/", help="This is the directory where the converted MIB will be output. " \ "[ default: %default ]") self.parser.add_option('--downloaddir', dest='downloaddir', default=tempfile.gettempdir() + "/mib_downloads/", help="This is the directory where the MIB will be downloaded. " \ "[ default: %default ]") self.parser.add_option('--extractdir', dest='extractdir', default=tempfile.gettempdir() + "/mib_extract/", help="This is the directory where unzipped MIB files will be stored. " \ "[ default: %default ]") self.parser.add_option('--evalSavedPython', dest='evalSavedPython', default=[], action='append', help="Execute the Python code previously generated" \ " and saved.") self.parser.add_option('--keepMiddleZeros', dest='keep_middle_zeros', default=False, action='store_true', help="Does not remove zeros found in the middle of the oid.")
def __init__(self): PBDaemon.__init__(self, keeproot=True) ZCmdBase.__init__(self) self.log.info('Starting...') wants_ssl = self.options.ssl if wants_ssl and not HAVE_SSL: self.log.error('SSL was requested for Jabber connection, but pyopenssl is not installed. Please install it and start the xmppBot again.') sys.exit(2) if not self.options.jabber_pass: self.log.error('--jabber_pass is required') sys.exit(2) if not self.options.jabber_user: self.log.error('--jabber_user is required') sys.exit(2) if self.options.first_user: try: zenUser, jabberId = self.options.first_user.split(',') except ValueError: self.log.error('--first_user option must contain both zenuser and jabberid separated by a comma. Example: chudler,[email protected]') sys.exit(2) if zenUser and jabberId: self.setFirstUser(zenUser, jabberId) else: self.log.error('--first_user option must contain both zenuser and jabberid separated by a comma. Example: chudler,[email protected]') sys.exit(2) # taken from zenactions.py self.schedule = Schedule(self.options, self.dmd) self.actions = [] self.loadActionRules() self.updateCheck = UpdateCheck() self.sendEvent(Event.Event(device=self.options.monitor, eventClass=App_Start, summary='Jabber Bot started', severity=0, component='xmppbot')) self.adapter = JabberAdapter(True) password = self.options.jabber_pass chatroom = self.options.chatroom username = self.options.jabber_user host = self.options.jabber_host port = self.options.jabber_port groupServer = self.options.group_server realHost = self.options.im_host server = '%s:%s' % (host, port) client = TwistedJabberClient(dialogHandler = self.adapter, server = server, userId = username, userPassword = password, firstRoom = chatroom, debug = True, groupServer = groupServer, realHost = realHost, wants_ssl = wants_ssl) self.adapter.client = client path = os.path.realpath(sys.argv[0]) pluginPath = os.path.dirname(path) + '/Jabber/plugins' self.log.info("xmppBot plugins will be loaded from %s" % pluginPath) plugins = [pluginFile.split('/')[-1].split('.py')[0] for pluginFile in glob.glob( os.path.join(pluginPath, '*.py') )] initPluginSystem({'pluginPath': pluginPath, 'plugins': plugins}) self.log.info('started') # connect to the jabber server jabber_reactor = client.connect() # begin looking for zenevents self.schedule.start() self.runCycle() # start event loop which will process jabber messages and zenevents jabber_reactor.run()
def __init__(self): ZCmdBase.__init__(self)
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('--monitor', '--collector', dest='monitor', default='localhost', help="Specify the collector to collect against.") self.parser.add_option('-d', '--device', dest='device', help="Show the configs for a single device")
def __init__(self, *args, **kwargs): ZCmdBase.__init__(self, *args, **kwargs) self.defaults = {} self.emittedDeviceClasses = set()
def buildOptions(self): ZCmdBase.buildOptions(self) self.parser.add_option('-i', '--file', dest = "input_file", help = "Events.xml file to import")