Beispiel #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
Beispiel #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
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()
def check():
    return CactiCheck('cacti', {}, {})
def check():
    return CactiCheck(CHECK_NAME, {}, {})
Beispiel #6
0
def check():
    return CactiCheck(CHECK_NAME, {}, [CACTI_CONFIG])