本文整理汇总了Python中Products.ZenUtils.ZCmdBase.ZCmdBase.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python ZCmdBase.__init__方法的具体用法?Python ZCmdBase.__init__怎么用?Python ZCmdBase.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.ZenUtils.ZCmdBase.ZCmdBase
的用法示例。
在下文中一共展示了ZCmdBase.__init__方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
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)
示例2: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
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]
示例3: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
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)
示例4: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
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')
示例5: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
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)
示例6: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
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,
},
)
示例7: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
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()
示例8: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
def __init__(self, *args, **kwargs):
ZCmdBase.__init__(self, *args, **kwargs)
self.defaults = {}
self.emittedDeviceClasses = set()
示例9: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
def __init__(self):
ZCmdBase.__init__(self)
示例10: __init__
# 需要导入模块: from Products.ZenUtils.ZCmdBase import ZCmdBase [as 别名]
# 或者: from Products.ZenUtils.ZCmdBase.ZCmdBase import __init__ [as 别名]
def __init__(self):
PBDaemon.__init__(self, keeproot=True)
ZCmdBase.__init__(self)
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'))
password = self.options.jabber_pass
chatrooms = self.options.chatrooms
username = self.options.jabber_user
server = self.options.jabber_host
port = self.options.jabber_port
groupServer = self.options.group_server
realHost = self.options.im_host
resource = self.options.resource
self.client = TwistedJabberClient(server=server, username=username, password=password,
port=port,
groupServer=groupServer,
chatrooms=chatrooms, ssl=wants_ssl,
realHost=realHost, resource=resource)
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') )]
self.log.debug("xmppBot loading pugins %s" % ', '.join(plugins))
initPluginSystem(pluginPath=pluginPath, plugins=plugins, jabberClient=self.client)
# connect to the jabber server
self.log.info('Connecting to server')
reactor = self.client.connect()
# begin looking for zenevents
self.schedule.start()
self.runCycle()
reactor.suggestThreadPoolSize(10)
reactor.run()