本文整理汇总了Python中collectd.register_read方法的典型用法代码示例。如果您正苦于以下问题:Python collectd.register_read方法的具体用法?Python collectd.register_read怎么用?Python collectd.register_read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collectd
的用法示例。
在下文中一共展示了collectd.register_read方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_config
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def handle_config(root):
for child in root.children:
instance_name = None
if child.key == 'Instance':
instance_name = child.values[0]
url = None
for ch2 in child.children:
if ch2.key == 'URL':
url = ch2.values[0]
if not url:
collectd.warning('No URL found in dump1090 Instance ' + instance_name)
else:
collectd.register_read(callback=handle_read,
data=(instance_name, urlparse.urlparse(url).hostname, url),
name='dump1090.' + instance_name)
collectd.register_read(callback=handle_read_1min,
data=(instance_name, urlparse.urlparse(url).hostname, url),
name='dump1090.' + instance_name + '.1min',
interval=60)
else:
collectd.warning('Ignored config entry: ' + child.key)
示例2: init_callback
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def init_callback(self):
self.client = docker.Client(
base_url=self.docker_url,
version=DockerPlugin.MIN_DOCKER_API_VERSION)
self.client.timeout = self.timeout
# Check API version for stats endpoint support.
try:
version = self.client.version()['ApiVersion']
if StrictVersion(version) < \
StrictVersion(DockerPlugin.MIN_DOCKER_API_VERSION):
raise Exception
except:
collectd.warning(('Docker daemon at {url} does not '
'support container statistics!')
.format(url=self.docker_url))
return False
collectd.register_read(self.read_callback)
collectd.info(('Collecting stats about Docker containers from {url} '
'(API version {version}; timeout: {timeout}s).')
.format(url=self.docker_url,
version=version,
timeout=self.timeout))
return True
示例3: configure
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def configure(configobj):
global INTERVAL
global cl
global queues_to_count
config = {c.key: c.values for c in configobj.children}
INTERVAL = config['interval'][0]
host = config['host'][0]
port = int(config['port'][0])
username = config['username'][0]
password = config['password'][0]
queues_to_count = []
if 'message_count' in config:
queues_to_count = config['message_count']
collectd.info('rabbitmq_monitoring: Interval: {}'.format(INTERVAL))
cl = Client('{}:{}'.format(host, port), username, password)
collectd.info(
'rabbitmq_monitoring: Connecting to: {}:{} as user:{} password:{}'
.format(host, port, username, password))
collectd.info(
'rabbitmq_monitoring: Counting messages on: {}'
.format(queues_to_count))
collectd.register_read(read, INTERVAL)
示例4: register_read
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def register_read(self, docker_plugin):
pass
示例5: add_read_callback
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def add_read_callback(self, callback, **kwargs):
"""Register a read callback with collectd.
kwargs will be passed to collectd.register_read.
The callback will be called by collectd without arguments.
"""
collectd.register_read(callback, **kwargs)
示例6: add_write_callback
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def add_write_callback(self, callback, **kwargs):
"""Register a write callback with collectd.
kwargs will be passed to collectd.register_read.
The callback will be called by collectd with a collectd.
Values object as the only argument.
"""
collectd.register_write(callback)
示例7: configure
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def configure(cfg):
global INTERVAL
global interfaces
global namespaces
interfaces = []
namespaces = []
config = {c.key: c.values for c in cfg.children}
INTERVAL = config['interval'][0]
collectd.register_read(read, INTERVAL)
if 'interfaces' in config:
interfaces = config['interfaces']
if 'namespaces' in config :
namespaces = config['namespaces']
示例8: configure_callback
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def configure_callback(self, configobj):
for node in configobj.children:
val = str(node.values[0])
if node.key == 'Interval':
self.interval = int(float(val))
elif node.key == 'Prefix':
self.prefix = val
elif node.key == 'User':
self.user = val
elif node.key == 'Password':
self.password = val
elif node.key == 'AuthURL':
self.authurl = val
elif node.key == 'AuthVersion':
self.authversion = val
elif node.key == 'Project':
self.project = val
else:
collectd.warning(
'collectd-swift-stat: Unknown config key: {}'
.format(node.key))
read_plugin = True
if not self.prefix:
collectd.error('collectd-swift-stat: Prefix Undefined')
read_plugin = False
if not self.user:
collectd.error('collectd-swift-stat: User Undefined')
read_plugin = False
if not self.password:
collectd.error('collectd-swift-stat: Password Undefined')
read_plugin = False
if not self.authurl:
collectd.error('collectd-swift-stat: AuthURL Undefined')
read_plugin = False
if not self.authversion:
collectd.error('collectd-swift-stat: AuthVersion Undefined')
read_plugin = False
if not self.project:
collectd.error('collectd-swift-stat: Project Undefined')
read_plugin = False
if read_plugin:
collectd.info(
'swift_stat: Connecting with user={}, password={}, tenant={}, auth_url={},'
' auth_version={}'.format(
self.user, self.password, self.project, self.authurl, self.authversion))
self.swift_conn = self.create_swift_session()
collectd.register_read(self.read_swift_stat, self.interval)
else:
collectd.error('collectd_swift_stat: Invalid configuration')
示例9: configure_callback
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def configure_callback(self, conf):
"""
Receive configuration block
"""
for node in conf.children:
val = str(node.values[0])
if node.key == 'Path':
self.iostat_path = val
elif node.key == 'Interval':
self.interval = float(val)
elif node.key == 'IostatInterval':
self.iostat_interval = int(float(val))
elif node.key == 'Count':
self.iostat_count = int(float(val))
elif node.key == 'Disks':
self.iostat_disks = val.split(',')
elif node.key == 'NiceNames':
self.iostat_nice_names = val in ['True', 'true']
elif node.key == 'DisksRegex':
self.iostat_disks_regex = val
elif node.key == 'UdevNameAttr':
self.iostat_udevnameattr = val
elif node.key == 'PluginName':
self.plugin_name = val
elif node.key == 'Verbose':
self.verbose_logging = val in ['True', 'true']
elif node.key == 'SkipPhysicalMultipath':
self.skip_multipath = val in [ 'True', 'true' ]
elif node.key == 'NoDisplayDMName':
self.iostat_no_dm_name = val in [ 'True', 'true' ]
else:
collectd.warning(
'%s plugin: Unknown config key: %s.' % (
self.plugin_name,
node.key))
self.log_verbose(
'Configured with iostat=%s, interval=%s, count=%s, disks=%s, '
'disks_regex=%s udevnameattr=%s skip_multipath=%s no_dm_name=%s' % (
self.iostat_path,
self.iostat_interval,
self.iostat_count,
self.iostat_disks,
self.iostat_disks_regex,
self.iostat_udevnameattr,
self.skip_multipath,
self.iostat_no_dm_name))
collectd.register_read(self.read_callback, self.interval)
示例10: configure_callback
# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import register_read [as 别名]
def configure_callback(self, config):
for node in config.children:
val = str(node.values[0])
if node.key == 'CephRadosBench':
self.ceph_rados_bench = val in ['True', 'true']
elif node.key == 'CephMONStats':
self.ceph_mon_stats = val in ['True', 'true']
elif node.key == 'CephOSDStats':
self.ceph_osd_stats = val in ['True', 'true']
elif node.key == 'CephPGStats':
self.ceph_pg_stats = val in ['True', 'true']
elif node.key == 'CephPoolStats':
self.ceph_pool_stats = val in ['True', 'true']
elif node.key == 'CephCluster':
self.ceph_cluster = val
elif node.key == 'CephRadosBenchInterval':
self.ceph_rados_bench_interval = int(float(val))
elif node.key == 'CephMONStatsInterval':
self.ceph_mon_stats_interval = int(float(val))
elif node.key == 'CephOSDStatsInterval':
self.ceph_osd_stats_interval = int(float(val))
elif node.key == 'CephPGStatsInterval':
self.ceph_pg_stats_interval = int(float(val))
elif node.key == 'CephPoolStatsInterval':
self.ceph_pool_stats_interval = int(float(val))
else:
collectd.warning(
'collectd-ceph-storage: Unknown config key: {}'
.format(node.key))
if not self.ceph_cluster:
collectd.warning('collectd-ceph-storage: CephCluster Undefined')
if self.ceph_rados_bench:
collectd.info('Registered Ceph Rados Bench')
collectd.register_read(
self.read_ceph_rados_bench,
self.ceph_rados_bench_interval, name='ceph-rados-bench')
if self.ceph_mon_stats:
collectd.info('Registered Ceph Mon')
collectd.register_read(
self.read_ceph_mon, self.ceph_mon_stats_interval,
name='ceph-monitor')
if self.ceph_osd_stats:
collectd.info('Registered Ceph OSD')
collectd.register_read(
self.read_ceph_osd, self.ceph_osd_stats_interval,
name='ceph-osd')
if self.ceph_pg_stats:
collectd.info('Registered Ceph PG')
collectd.register_read(
self.read_ceph_pg, self.ceph_pg_stats_interval, name='ceph-pg')
if self.ceph_pool_stats:
collectd.info('Registered Ceph Pool')
collectd.register_read(
self.read_ceph_pool, self.ceph_pool_stats_interval,
name='ceph-pool')