def test_single_instance_counter(aggregator, pdh_mocks_fixture): # noqa F811 initialize_pdh_tests() instance = DEFAULT_INSTANCE c = PDHBaseCheck("testcheck", {}, {}, [instance], SINGLE_INSTANCE_COUNTER) c.check(instance) aggregator.assert_metric("test.system.mem.available", tags=None, count=1)
def test_additional_metrics(aggregator, pdh_mocks_fixture): # noqa F811 initialize_pdh_tests() instance = copy.deepcopy(DEFAULT_INSTANCE) instance['additional_metrics'] = SINGLE_INSTANCE_COUNTER c = PDHBaseCheck("testcheck", {}, [instance], counter_list=[]) c.check(instance) aggregator.assert_metric("test.system.mem.available", tags=None, count=1)
def test_multi_instance_counter_specific_instances( aggregator, pdh_mocks_fixture): # noqa F811 initialize_pdh_tests() instance = DEFAULT_INSTANCE c = PDHBaseCheck("testcheck", {}, {}, [instance], MULTI_INSTANCE_COUNTER_WITH_INSTANCES) c.check(instance) for t in ['test.processor_time_0', 'test.processor_time_1']: aggregator.assert_metric(t, tags=None, count=1) assert aggregator.metrics_asserted_pct == 100.0
def test_multi_instance_counter(aggregator, pdh_mocks_fixture): # noqa F811 initialize_pdh_tests() instance = DEFAULT_INSTANCE c = PDHBaseCheck("testcheck", {}, {}, [instance], MULTI_INSTANCE_COUNTER) c.check(instance) for t in ['instance:0', 'instance:1', 'instance:_Total']: aggregator.assert_metric("test.processor_time", tags=['%s' % t], count=1) assert aggregator.metrics_asserted_pct == 100.0
def test_returns_partial_metrics(Aggregator, pdh_mocks_fixture): COUNTER_LIST = [ [ "NTDS", None, "LDAP Client Sessions", "active_directory.ldap.client_sessions", "gauge" ], [ "NTDS", None, "LDAP Bind Time", "active_directory.ldap.bind_time", "gauge" ], [ "NTDS", None, "LDAP Successful Binds/sec", "active_directory.ldap.successful_binds_persec", "gauge" ], [ "NTDS", None, "LDAP Searches/sec", "active_directory.ldap.searches_persec", "gauge" ], ## these two don't exist [ "NTDS", None, "Kerberos Authentications/sec", "active_directory.kerberos.auths_persec", "gauge" ], [ "NTDS", None, "NTLM Authentications/sec", "active_directory.ntlm.auths_persec", "gauge" ], ] initialize_pdh_tests() instance = DEFAULT_INSTANCE c = PDHBaseCheck("testcheck", {}, {}, [instance], COUNTER_LIST) c.check(instance) Aggregator.assert_metric("active_directory.ldap.client_sessions", tags=None, count=1) Aggregator.assert_metric("active_directory.ldap.bind_time", tags=None, count=1) Aggregator.assert_metric("active_directory.ldap.successful_binds_persec", tags=None, count=1) Aggregator.assert_metric("active_directory.ldap.searches_persec", tags=None, count=1) assert Aggregator.metrics_asserted_pct == 100.0
def test_returns_partial_metrics(aggregator, pdh_mocks_fixture): # noqa F811 initialize_pdh_tests() instance = DEFAULT_INSTANCE c = PDHBaseCheck("testcheck", {}, [instance], PARTIAL_COUNTER_LIST) c.check(instance) aggregator.assert_metric("active_directory.ldap.client_sessions", tags=None, count=1) aggregator.assert_metric("active_directory.ldap.bind_time", tags=None, count=1) aggregator.assert_metric("active_directory.ldap.successful_binds_persec", tags=None, count=1) aggregator.assert_metric("active_directory.ldap.searches_persec", tags=None, count=1) assert aggregator.metrics_asserted_pct == 100.0