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
Example #2
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
def test_single_instance_counter_with_instance(Aggregator, pdh_mocks_fixture):
    initialize_pdh_tests()
    instance = DEFAULT_INSTANCE
    with pytest.raises(AttributeError):
        PDHBaseCheck("testcheck", {}, {}, [instance],
                     INSTANCE_OF_SINGLE_INSTANCE_COUNTER)
Example #4
0
def test_default_admin_share():
    initialize_pdh_tests()
    c = PDHBaseCheck("testcheck", {}, {}, [DEFAULT_INSTANCE],
                     SINGLE_INSTANCE_COUNTER)
    nr = c._get_netresource('1.1.1.1')
    assert nr.lpRemoteName == '\\\\1.1.1.1\\c$'