コード例 #1
0
def test_process_matches(ps_line, ps_pattern, user_pattern, result):
    psi = ps.ps_info(ps_line[0])  # type: ignore[call-arg]
    matches_attr = ps.process_attributes_match(psi, user_pattern,
                                               (None, False))
    matches_proc = ps.process_matches(ps_line[1:], ps_pattern)

    assert (matches_attr and matches_proc) == result
コード例 #2
0
def test_parse_ps(capture, result):
    cpu_core, lines = ps_section.parse_ps(capture)
    assert cpu_core == result[0]  # cpu_cores

    for (ps_info_item, cmd_line), ref in itertools.zip_longest(lines, result[1]):
        assert ps_info_item == ps.ps_info(*ref[0])
        assert cmd_line == ref[1:]
コード例 #3
0
def test_host_labels_ps_match():
    section = (
        1,
        [
            (
                ps.ps_info("(root,4056,1512,0.0/52-04:56:05,5689)".split()
                           ),  # type: ignore[call-arg]
                ["/usr/lib/ssh/sshd"],
            ),
        ])
    params = [
        {
            "default_params": {},
            "descr": "SSH",
            "match": "~.*ssh?",
            "label": {
                'marco': 'polo'
            },
        },
        {},
    ]
    assert list(ps.host_labels_ps(params,
                                  section)) == [  # type: ignore[arg-type]
                                      HostLabel('marco', 'polo')
                                  ]
コード例 #4
0
def test_host_labels_ps_no_match_pattern():
    section = (
        1,
        [
            (
                ps.ps_info("(root,4056,1512,0.0/52-04:56:05,5689)".split()
                           ),  # type: ignore[call-arg]
                ["/usr/lib/ssh/sshd"],
            ),
        ])
    params = [
        Parameters({
            "default_params": {},
            "descr": "SSH",
            "match": "~wat?",
            "label": DiscoveredHostLabels(HostLabel(u'marco', u'polo')),
        }),
        Parameters({}),
    ]
    assert list(ps.host_labels_ps(params, section)) == []
コード例 #5
0
ファイル: test_ps.py プロジェクト: tboerger/checkmk
def test_host_labels_ps_no_match_attr():
    section = (
        1,
        [
            (
                ps.ps_info("(root,4056,1512,0.0/52-04:56:05,5689)".split()
                           ),  # type: ignore[call-arg]
                ["/usr/lib/ssh/sshd"],
            ),
        ])
    params = [
        Parameters({
            "default_params": {},
            "descr": "SSH",
            "match": "~.*ssh?",
            "user": "******",
            "label": {
                'marco': 'polo'
            },
        }),
        Parameters({}),
    ]
    assert list(ps.host_labels_ps(params, section)) == []