• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python checks.AgentCheck类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中monasca_agent.collector.checks.AgentCheck的典型用法代码示例。如果您正苦于以下问题:Python AgentCheck类的具体用法?Python AgentCheck怎么用?Python AgentCheck使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AgentCheck类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, name, init_config, agent_config, instances=None):
     AgentCheck.__init__(self, name, init_config, agent_config, instances)
     if instances is not None and len(instances) > 1:
         raise Exception('cAdvisor host check only supports one configured'
                         ' instance.')
     self.connection_timeout = int(init_config.get('connection_timeout',
                                                   DEFAULT_TIMEOUT))
     self.cadvisor_url = None
     self.cadvisor_machine_url = None
     self.total_mem = 0
     self.num_cores = 0
开发者ID:openstack,项目名称:monasca-agent,代码行数:11,代码来源:cadvisor_host.py


示例2: __init__

    def __init__(self, name, init_config, agent_config):
        AgentCheck.__init__(self, name, init_config, agent_config)

        # Load any custom metrics from conf.d/sqlserver.yaml
        for row in init_config.get('custom_metrics', []):
            if row['type'] not in VALID_METRIC_TYPES:
                self.log.error('%s has an invalid metric type: %s' % (row['name'], row['type']))
            self.METRICS.append((row['name'], row['type'], row['counter_name'],
                                 row.get('instance_name', ''), row.get('tag_by', None)))

        # Cache connections
        self.connections = {}
开发者ID:TomEros,项目名称:monasca-agent,代码行数:12,代码来源:sqlserver.py


示例3: __init__

 def __init__(self, name, init_config, agent_config, instances=None):
     AgentCheck.__init__(self, name, init_config, agent_config, instances=[{}])
     self.instance_cache_file = "{0}/{1}".format(self.init_config.get('cache_dir'),
                                                 'libvirt_instances.json')
     self.metric_cache_file = "{0}/{1}".format(self.init_config.get('cache_dir'),
                                               'libvirt_metrics.json')
     self.use_bits = self.init_config.get('network_use_bits')
     if self.init_config.get('disk_collection_period'):
         self._disk_collection_period = int(self.init_config.get('disk_collection_period'))
         self._last_disk_collect_time = datetime.fromordinal(1)
     else:
         self._disk_collection_period = 0
     self._skip_disk_collection = False
开发者ID:fhtxl,项目名称:monasca-agent,代码行数:13,代码来源:libvirt.py


示例4: __init__

    def __init__(self, name, init_config, agent_config, instances=None):
        AgentCheck.__init__(self, name, init_config, agent_config, instances=[{}])
        self.instance_cache_file = "{0}/{1}".format(self.init_config.get('cache_dir'),
                                                    'libvirt_instances.json')
        self.metric_cache_file = "{0}/{1}".format(self.init_config.get('cache_dir'),
                                                  'libvirt_metrics.json')
        self.use_bits = self.init_config.get('network_use_bits')

        self._collect_intervals = {}

        self._set_collection_intervals('disk', 'disk_collection_period')
        self._set_collection_intervals('vnic', 'vnic_collection_period')

        pool_size = self.init_config.get('max_ping_concurrency', 8)
        self.pool = Pool(pool_size)
开发者ID:jobrs,项目名称:monasca-agent,代码行数:15,代码来源:libvirt.py


示例5: setUp

    def setUp(self):
        agent_config = base_config.get_config(sections='Main')

        self._instances = [{'name': 'test',
                            'mapping': {
                                'gauges': ['stats.(MessagesAvg)'],
                                'counters': ['MessagesTotal'],
                                'dimensions': {
                                    'index': 'index',
                                    'simple_dimension': 'simple_label',
                                    'complex_dimension': {
                                        'source_key': 'complex_label',
                                        'regex': 'k8s_([._\-a-zA-Z0-9]*)_postfix'
                                    },
                                    'complex_dimension_rest': {
                                        'source_key': 'complex_label',
                                        'regex': 'k8s_([._\-a-zA-Z0-9]*_postfix)'
                                    }
                                },
                                'groups': {
                                    'testgroup': {
                                        'dimensions': {
                                            'user': 'user'
                                        },
                                        'rates': ['.*\.Responses.*', '(sec_auth_.*).stats',
                                                  '(io_service_bytes)_stats_Total']
                                    }
                                    # dimensions should be inherited from above
                                }}}]
        self.check = AgentCheck("DynCheckHelper-Teset", {}, agent_config, self._instances)  # TODO mock check
        self.helper = DynamicCheckHelper(self.check, 'dynhelper')
开发者ID:openstack,项目名称:monasca-agent,代码行数:31,代码来源:test_checks_utils.py


示例6: __init__

 def __init__(self, name, init_config, agent_config, instances=None):
     AgentCheck.__init__(self, name, init_config,
                         agent_config, instances=[{}])
     cache_dir = self.init_config.get('cache_dir')
     self.enable_vm = self.init_config.get('enable_vm')
     self.enable_ecn = self.init_config.get('enable_ecn')
     self.s_factor = self.init_config.get('s_factor')
     self.collect_period = self.init_config.get('collect_period')
     self.cong_cache_file = os.path.join(cache_dir,
                                         'congestion_status.json')
     self.session = keystone.get_session(**self.init_config)
     self.chain_exist = False
     self.rule_exist = False
     self._check_chain()
     self.checked = []
     if self.enable_ecn:
         self._activate_ecn()
开发者ID:openstack,项目名称:monasca-agent,代码行数:17,代码来源:congestion.py


示例7: __init__

    def __init__(self, name, init_config, agent_config, instances=None):
        AgentCheck.__init__(self, name, init_config,
                            agent_config, instances=[{}])

        cache_dir = self.init_config.get('cache_dir')
        self.ctr_cache_file = os.path.join(cache_dir, 'ovs_metrics.json')
        self.port_cache_file = os.path.join(cache_dir, 'ovs_ports.json')

        self.use_bits = self.init_config.get('network_use_bits')
        self.check_router_ha = self.init_config.get('check_router_ha')
        self.ovs_cmd = OVS_CMD % self.init_config.get('ovs_cmd')
        include_re = self.init_config.get('included_interface_re', None)
        self.use_absolute_metrics = self.init_config.get('use_absolute_metrics')
        if include_re is None:
            include_re = 'qg.*'
        else:
            include_re = include_re + '|' + 'qg.*'
        self.include_iface_re = re.compile(include_re)
开发者ID:Chillisystems,项目名称:monasca-agent,代码行数:18,代码来源:ovs.py


示例8: testBadMetricKeepBatch

    def testBadMetricKeepBatch(self):
        agent_config = base_config.get_config(sections='Main')

        check = AgentCheck("foo", {}, agent_config)

        dimensions = {'A': 'B', 'B': 'C', 'D': 'E'}
        check.submit_metric("Foo",
                            5,
                            metrics_pkg.Gauge,
                            dimensions=dimensions,
                            delegated_tenant=None,
                            hostname=None,
                            device_name=None,
                            value_meta=None)
        self.assertEqual(len(check.aggregator.metrics), 1)

        dimensions = {'A': '{}', 'B': 'C', 'D': 'E'}
        check.submit_metric("Bar",
                            5,
                            metrics_pkg.Gauge,
                            dimensions=dimensions,
                            delegated_tenant=None,
                            hostname=None,
                            device_name=None,
                            value_meta=None)
        self.assertEqual(len(check.aggregator.metrics), 1)

        dimensions = {'A': 'B', 'B': 'C', 'D': 'E'}
        check.submit_metric("Baz",
                            5,
                            metrics_pkg.Gauge,
                            dimensions=dimensions,
                            delegated_tenant=None,
                            hostname=None,
                            device_name=None,
                            value_meta=None)
        self.assertEqual(len(check.aggregator.metrics), 2)
开发者ID:openstack,项目名称:monasca-agent,代码行数:37,代码来源:test_agent_check.py


示例9: __init__

    def __init__(self, name, init_config, agent_config):
        AgentCheck.__init__(self, name, init_config, agent_config)

        # Host status needs to persist across all checks
        self.cluster_status = {}
开发者ID:Rubab-Syed,项目名称:monasca-agent,代码行数:5,代码来源:elastic.py


示例10: __init__

 def __init__(self, name, init_config, agent_config):
     AgentCheck.__init__(self, name, init_config, agent_config)
     self._last_state_by_server = {}
开发者ID:fhtxl,项目名称:monasca-agent,代码行数:3,代码来源:mongo.py


示例11: __init__

    def __init__(self, name, init_config, agent_config):
        AgentCheck.__init__(self, name, init_config, agent_config)

        # Host status needs to persist across all checks
        self.host_status = defaultdict(lambda: defaultdict(lambda: None))
开发者ID:fhtxl,项目名称:monasca-agent,代码行数:5,代码来源:haproxy.py


示例12: __init__

 def __init__(self, name, init_config, agent_config):
     AgentCheck.__init__(self, name, init_config, agent_config)
     self.high_watermarks = {}
开发者ID:Chillisystems,项目名称:monasca-agent,代码行数:3,代码来源:jenkins.py


示例13: __init__

 def __init__(self, name, init_config, agent_config):
     AgentCheck.__init__(self, name, init_config, agent_config)
     self.dbs = {}
     self.versions = {}
开发者ID:Chillisystems,项目名称:monasca-agent,代码行数:4,代码来源:postgres.py


示例14: __init__

 def __init__(self, name, init_config, agent_config):
     AgentCheck.__init__(self, name, init_config, agent_config, instances=[{}])
     self.max_objects = init_config.get("vcenter_max_objects", 100000)
开发者ID:openstack,项目名称:monasca-agent,代码行数:3,代码来源:vcenter_slim.py


示例15: __init__

 def __init__(self, name, init_config, agent_config, instances):
     AgentCheck.__init__(self, name, init_config, agent_config, instances=instances)
     self._max_objects = 1000
     self.session = None
     self.is_new_session = True
     self._resource_moid_dict = {}
开发者ID:jobrs,项目名称:monasca-agent,代码行数:6,代码来源:vcenter.py


示例16: __init__

 def __init__(self, name, init_config, agent_config, instances=None):
     AgentCheck.__init__(self, name, init_config, agent_config, instances)
     self.assumed_url = {}
开发者ID:Rubab-Syed,项目名称:monasca-agent,代码行数:3,代码来源:lighttpd.py


示例17: __init__

 def __init__(self, name, init_config, agent_config, instances=None):
     AgentCheck.__init__(self, name, init_config, agent_config, instances)
开发者ID:fhtxl,项目名称:monasca-agent,代码行数:2,代码来源:mk_livestatus.py


示例18: __init__

 def __init__(self, name, init_config, agent_config):
     AgentCheck.__init__(self, name, init_config, agent_config)
     self.wmi_conns = {}
开发者ID:sripadkollur,项目名称:monasca-agent,代码行数:3,代码来源:iis.py


示例19: __init__

    def __init__(self, name, init_config, agent_config, instances=None):
        AgentCheck.__init__(self, name, init_config, agent_config, instances)
        for k in ["mean", "median", "95", "99", "100"]:
            [self.keys.append(m + "_" + k) for m in self.stat_keys]

        self.prev_coord_redirs_total = -1
开发者ID:Chillisystems,项目名称:monasca-agent,代码行数:6,代码来源:riak.py


示例20: TestDynamicCheckHelper

class TestDynamicCheckHelper(unittest.TestCase):
    def setUp(self):
        agent_config = base_config.get_config(sections='Main')

        self._instances = [{'name': 'test',
                            'mapping': {
                                'gauges': ['stats.(MessagesAvg)'],
                                'counters': ['MessagesTotal'],
                                'dimensions': {
                                    'index': 'index',
                                    'simple_dimension': 'simple_label',
                                    'complex_dimension': {
                                        'source_key': 'complex_label',
                                        'regex': 'k8s_([._\-a-zA-Z0-9]*)_postfix'
                                    },
                                    'complex_dimension_rest': {
                                        'source_key': 'complex_label',
                                        'regex': 'k8s_([._\-a-zA-Z0-9]*_postfix)'
                                    }
                                },
                                'groups': {
                                    'testgroup': {
                                        'dimensions': {
                                            'user': 'user'
                                        },
                                        'rates': ['.*\.Responses.*', '(sec_auth_.*).stats',
                                                  '(io_service_bytes)_stats_Total']
                                    }
                                    # dimensions should be inherited from above
                                }}}]
        self.check = AgentCheck("DynCheckHelper-Teset", {}, agent_config, self._instances)  # TODO mock check
        self.helper = DynamicCheckHelper(self.check, 'dynhelper')

    def run_check(self):
        self.check.run()
        metric_dict = {"sec": {"auth": [{"user": "me", "total.stats": 10}, {"user": "you", "total.stats": 15}]},
                       "io_service_bytes": {"stats": {"Total": 10}}}
        self.helper.push_metric_dict(self._instances[0], metric_dict, group="testgroup",
                                     labels={'simple_label': 'simple_label_test',
                                             'complex_label': 'k8s_monasca-api-a8109321_postfix'}, max_depth=3)
        self.helper.push_metric(self._instances[0], metric='req.ResponsesOk', value=10.0,
                                group="testgroup",
                                labels={'simple_label': 'simple_label_test',
                                        'complex_label': 'k8s_monasca-api-a8109321_postfix'})
        self.helper.push_metric(self._instances[0], metric='stats.MessagesAvg', value=5.0,
                                labels={'simple_label': 'simple_label_test',
                                        'complex_label': 'k8s_monasca-api-a8109321_postfix'})
        self.helper.push_metric(self._instances[0], metric='MessagesTotal', value=1)
        time.sleep(1)
        self.helper.push_metric_dict(self._instances[0], metric_dict, group="testgroup",
                                     labels={'simple_label': 'simple_label_test',
                                             'complex_label': 'k8s_monasca-api-a8109321_postfix'}, max_depth=3)
        self.helper.push_metric(self._instances[0], metric='req.ResponsesOk', value=15.0,
                                group="testgroup",
                                labels={'simple_label': 'simple_label_test',
                                        'complex_label': 'k8s_monasca-api-a8109321_postfix'})
        self.helper.push_metric(self._instances[0], metric='MessagesTotal', value=100)
        metrics = self.check.get_metrics()

        return metrics

    def testMeasurements(self):
        metrics = self.run_check()
        for m in metrics:
            print "metric: {0}, dimensions: {1}".format(m['measurement']['name'], repr(m['measurement']['dimensions']))
        metric1 = sorted(filter(lambda m: m['measurement']['name'] == 'dynhelper.messages_avg', metrics))
        metric2 = sorted(filter(lambda m: m['measurement']['name'] == 'dynhelper.messages_total', metrics))
        metric3 = sorted(filter(lambda m: m['measurement']['name'] == 'dynhelper.testgroup.req_responses_ok', metrics))
        metric4 = sorted(filter(lambda m: m['measurement']['name'] == 'dynhelper.testgroup.sec_auth_total', metrics))
        self.assertTrue(len(metric1) > 0,
                        'gauge dynhelper.messages_avg missing in metric list {0}'.format(repr(metrics)))
        self.assertEqual(metric1[0]['measurement']['dimensions'],
                          {'simple_dimension': 'simple_label_test', 'complex_dimension': 'monasca-api-a8109321',
                           'complex_dimension_rest': 'monasca-api-a8109321_postfix',
                           'hostname': metric1[0]['measurement']['dimensions'].get('hostname')})
        self.assertTrue(len(metric2) > 0,
                        'rate dynhelper.messages_total missing in metric list {0}'.format(repr(metrics)))
        self.assertEqual(metric2[0]['measurement']['dimensions'],
                          {'hostname': metric2[0]['measurement']['dimensions'].get('hostname')})
        self.assertTrue(len(metric3) > 0,
                        'rate dynhelper.testgroup.req_responses_ok missing in metric list {0}'.format(repr(metrics)))
        self.assertEqual(metric3[0]['measurement']['dimensions'],
                          {'simple_dimension': 'simple_label_test', 'complex_dimension': 'monasca-api-a8109321',
                           'complex_dimension_rest': 'monasca-api-a8109321_postfix',
                           'hostname': metric3[0]['measurement']['dimensions'].get('hostname')})
        self.assertTrue(len(metric4) == 2,
                        'rate dynhelper.testgroup.sec_auth_total missing in metric list {0}'.format(repr(metrics)))
        self.assertEqual(metric4[0]['measurement']['dimensions'],
                          {'simple_dimension': 'simple_label_test', 'complex_dimension': 'monasca-api-a8109321',
                           'complex_dimension_rest': 'monasca-api-a8109321_postfix',
                           'user': 'me', 'hostname': metric4[0]['measurement']['dimensions'].get('hostname')})
        self.assertEqual(metric4[1]['measurement']['dimensions'],
                          {'simple_dimension': 'simple_label_test', 'complex_dimension': 'monasca-api-a8109321',
                           'complex_dimension_rest': 'monasca-api-a8109321_postfix',
                           'user': 'you', 'hostname': metric4[1]['measurement']['dimensions'].get('hostname')})
开发者ID:openstack,项目名称:monasca-agent,代码行数:95,代码来源:test_checks_utils.py



注:本文中的monasca_agent.collector.checks.AgentCheck类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.add_links_to_resource函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.validate_authorization函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap