Пример #1
0
def test_default_port_config(mock_connect):
    config = deepcopy(CACTI_CONFIG)

    cacti = CactiCheck('cacti', {}, [config])
    connection = cacti._get_connection()

    assert connection.port == 3306
Пример #2
0
def test_port_config_custom(mock_connect):
    config = deepcopy(CACTI_CONFIG)
    config['mysql_port'] = 3308

    cacti = CactiCheck('cacti', {}, [config])
    connection = cacti._get_connection()

    assert connection.port == 3308
Пример #3
0
def test_whitelist(aggregator):
    config = deepcopy(CACTI_CONFIG)
    config['rrd_whitelist'] = os.path.join(HERE, 'whitelist.txt')
    check = CactiCheck('cacti', {}, [config])

    mocks = _setup_mocks()

    # Run the check twice to set the timestamps and capture metrics on the second run
    check.check(config)
    check.check(config)

    for mock_func in mocks:
        mock_func.stop()

    # We are mocking the MySQL call so we won't have cacti.rrd.count or cacti.hosts.count metrics,
    # check for metrics that are returned from our mock data.
    aggregator.assert_metric('cacti.metrics.count', value=2, tags=CUSTOM_TAGS)
    aggregator.assert_metric('system.mem.buffered.max',
                             value=2,
                             tags=CUSTOM_TAGS)
    aggregator.assert_metric('system.mem.buffered', value=2, tags=CUSTOM_TAGS)
    aggregator.assert_metric('cacti.rrd.count', value=1, tags=CUSTOM_TAGS)
    aggregator.assert_metric('cacti.hosts.count', value=1, tags=CUSTOM_TAGS)
    aggregator.assert_all_metrics_covered()
Пример #4
0
def check():
    return CactiCheck('cacti', {}, {})
Пример #5
0
def check():
    return CactiCheck(CHECK_NAME, {}, {})
Пример #6
0
def check():
    return CactiCheck(CHECK_NAME, {}, [CACTI_CONFIG])