Exemple #1
0
def test_relative_but_no_absolute_levels(
    params,
    levels,
):
    section = parse_cpu(STRING_TABLE_RELATIVE)  # type: ignore[arg-type]
    assert section
    found_levels = {}
    for element in check_cpu_threads(params=params, section=section):
        if isinstance(element, Metric):
            found_levels[element.name] = element.levels
    assert found_levels == levels
Exemple #2
0
def test_basic_cpu_loads():
    section = parse_cpu(STRING_TABLE)  # type: ignore[arg-type]
    assert section
    result = list(
        check_cpu_load(
            params={"levels": (5.0, 10.0)},
            section=section,
        ))
    assert result == [
        Result(state=State.OK, summary="15 min load: 0.87"),
        Metric("load15", 0.87, levels=(40.0, 80.0)),
        Result(state=State.OK, summary="15 min load per core: 0.11 (8 cores)"),
        Metric("load1", 0.88, boundaries=(0.0, 8.0)),
        Metric("load5", 0.83, boundaries=(0.0, 8.0)),
    ]
Exemple #3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

# yapf: disable
# type: ignore

from cmk.base.plugins.agent_based.cpu import parse_cpu


checkname = 'cpu'

parsed = parse_cpu([[u'0.88', u'0.83', u'0.87', u'2/1748', u'21050', u'8'], [u'124069']])

discovery = {
    'threads': [(None, {})],
}

checks = {
    'threads': [(
        None,
        {
            'levels': (2000, 4000)
        },
        [
            (0, 'Count: 1748 threads', [('threads', 1748, 2000.0, 4000.0, None, None)]),
            (0, 'Usage: 1.41%', [('thread_usage', 1.408893438328672, None, None, None, None)]),
        ],
    )],
Exemple #4
0
def test_cpu_threads_regression(info, check_result):
    section = parse_cpu(info)
    assert section is not None
    params = {"levels": (2000, 4000)}
    assert list(discover_cpu_threads(section)) == [Service()]
    assert set(check_cpu_threads(params, section)) == check_result
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

# yapf: disable
# type: ignore

from cmk.base.plugins.agent_based.cpu import parse_cpu


checkname = 'cpu'

parsed = parse_cpu([[u'0.88', u'0.83', u'0.87', u'2/2148', u'21050', u'8']])

discovery = {
    'loads': [(None, 'cpuload_default_levels')],
    'threads': [(None, {})],
}

checks = {
    'loads': [(
        None,
        (5.0, 10.0),
        [(
            0,
            '15 min load: 0.87 at 8 cores (0.11 per core)',
            [
                ('load1', 0.88, 40.0, 80.0, 0, 8),
                ('load5', 0.83, 40.0, 80.0, 0, 8),