def test_df_discovery_groups_with_parse(inventory_df_rules, filesystem_groups, expected_result): check = Check("df") def mocked_host_extra_conf_merged(_hostname, ruleset): if ruleset is check.context.get("inventory_df_rules"): return inventory_df_rules raise AssertionError( "Unknown/unhandled ruleset 'inventory_df_rules' used in mock of host_extra_conf_merged" ) def mocked_host_extra_conf(_hostname, ruleset): if ruleset is check.context.get("filesystem_groups"): return filesystem_groups raise AssertionError( "Unknown/unhandled ruleset 'filesystem_groups' used in mock of host_extra_conf" ) with MockHostExtraConf(check, mocked_host_extra_conf_merged, "host_extra_conf_merged"): with MockHostExtraConf(check, mocked_host_extra_conf, "host_extra_conf"): raw_discovery_result = check.run_discovery( parse_df(info_df_groups)) discovery_result = DiscoveryResult(raw_discovery_result) expected_result = DiscoveryResult(expected_result) assertDiscoveryResultsEqual(check, discovery_result, expected_result)
def test_df_check_groups_with_parse(add_params, expected_result): check = Check("df") params = make_test_df_params() params.update(add_params) actual = CheckResult(check.run_check("my-group", params, parse_df(info_df_groups))) expected = CheckResult(expected_result) assertCheckResultsEqual(actual, expected)
def test_df_discovery_with_parse(info, expected_result, inventory_df_rules): check = Check("df") def mocked_host_extra_conf_merged(_hostname, ruleset): if ruleset is check.context.get("inventory_df_rules"): return inventory_df_rules raise AssertionError( "Unknown/unhandled ruleset used in mock of host_extra_conf") with MockHostExtraConf(check, mocked_host_extra_conf_merged, "host_extra_conf_merged"): discovery_result = DiscoveryResult(check.run_discovery(parse_df(info))) assertDiscoveryResultsEqual(check, discovery_result, DiscoveryResult(expected_result))
parsed = parse_df([ ['tmpfs', 'tmpfs', '1620324', '2320', '1618004', '1%', '/run'], ['/dev/mapper/ubuntu--vg-root', 'ext4', '242791844', '59957024', '170431928', '27%', '/'], ['tmpfs', 'tmpfs', '8101604', '226244', '7875360', '3%', '/dev/shm'], ['tmpfs', 'tmpfs', '5120', '4', '5116', '1%', '/run/lock'], ['tmpfs', 'tmpfs', '8101604', '0', '8101604', '0%', '/sys/fs/cgroup'], ['/dev/nvme0n1p2', 'ext4', '721392', '294244', '374684', '44%', '/boot'], ['/dev/nvme0n1p1', 'vfat', '523248', '31468', '491780', '7%', '/boot/efi'], ['tmpfs', 'tmpfs', '1620320', '68', '1620252', '1%', '/run/user/1000'], ['tmpfs', 'tmpfs', '8101604', '8612', '8092992', '1%', '/opt/omd/sites/netapp/tmp'], ['tmpfs', 'tmpfs', '8101604', '6360', '8095244', '1%', '/opt/omd/sites/heute/tmp'], ['tmpfs', 'tmpfs', '8101604', '6460', '8095144', '1%', '/opt/omd/sites/site1/tmp'], ['tmpfs', 'tmpfs', '8101604', '6456', '8095148', '1%', '/opt/omd/sites/site2/tmp'], ['tmpfs', 'tmpfs', '8101604', '6484', '8095120', '1%', '/opt/omd/sites/site3/tmp'], ['tmpfs', 'tmpfs', '8101604', '6476', '8095128', '1%', '/opt/omd/sites/site4/tmp'], ['tmpfs', 'tmpfs', '8101604', '6404', '8095200', '1%', '/opt/omd/sites/site5/tmp'], ['tmpfs', 'tmpfs', '8101604', '6388', '8095216', '1%', '/opt/omd/sites/site10/tmp'], ['[df_inodes_start]'], ['tmpfs', 'tmpfs', '2025401', '1287', '2024114', '1%', '/run'], ['/dev/mapper/ubuntu--vg-root', 'ext4', '15491072', '1266406', '14224666', '9%', '/'], ['tmpfs', 'tmpfs', '2025401', '120', '2025281', '1%', '/dev/shm'], ['tmpfs', 'tmpfs', '2025401', '7', '2025394', '1%', '/run/lock'], ['tmpfs', 'tmpfs', '2025401', '18', '2025383', '1%', '/sys/fs/cgroup'], ['/dev/nvme0n1p2', 'ext4', '46848', '321', '46527', '1%', '/boot'], ['/dev/nvme0n1p1', 'vfat', '0', '0', '0', '-', '/boot/efi'], ['tmpfs', 'tmpfs', '2025401', '105', '2025296', '1%', '/run/user/1000'], ['tmpfs', 'tmpfs', '2025401', '1547', '2023854', '1%', '/opt/omd/sites/netapp/tmp'], ['tmpfs', 'tmpfs', '2025401', '1531', '2023870', '1%', '/opt/omd/sites/heute/tmp'], ['tmpfs', 'tmpfs', '2025401', '1541', '2023860', '1%', '/opt/omd/sites/site1/tmp'], ['tmpfs', 'tmpfs', '2025401', '1541', '2023860', '1%', '/opt/omd/sites/site2/tmp'], ['tmpfs', 'tmpfs', '2025401', '1541', '2023860', '1%', '/opt/omd/sites/site3/tmp'], ['tmpfs', 'tmpfs', '2025401', '1541', '2023860', '1%', '/opt/omd/sites/site4/tmp'], ['tmpfs', 'tmpfs', '2025401', '1541', '2023860', '1%', '/opt/omd/sites/site5/tmp'], ['tmpfs', 'tmpfs', '2025401', '1536', '2023865', '1%', '/opt/omd/sites/site10/tmp'], ['[df_inodes_end]'], ])
#!/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.df_section import parse_df checkname = 'df' parsed = parse_df([ ['C:\\\\', 'NTFS', '62553084', '16898384', '45654700', '28%', 'C:\\\\'], ['SQL_Database_[GROUPME]', 'NTFS', '10450940', '2932348', '7518592', '29%', 'D:\\\\'], ['Scratch_Volume_[GROUPME]', 'NTFS', '5208060', '791864', '4416196', '16%', 'E:\\\\'], ]) discovery = { '': [ ( 'C:\\\\ C://', { "item_appearance": "volume_name_and_mountpoint", "mountpoint_for_block_devices": "volume_name", }, ), ( 'SQL_Database_[GROUPME] D://', { "item_appearance": "volume_name_and_mountpoint",
def test_df_check_with_parse(item, params, info, expected_result): check = Check("df") actual = CheckResult(check.run_check(item, params, parse_df(info))) assertCheckResultsEqual(actual, CheckResult(expected_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.df_section import parse_df checkname = 'df' parsed = parse_df([ ['C:\\', 'NTFS', '8192620', '7724268', '468352', '95%', 'C:\\'], ['New_Volume', 'NTFS', '10240796', '186256', '10054540', '2%', 'E:\\'], ['New_Volume', 'NTFS', '124929596', '50840432', '74089164', '41%', 'F:\\'], ]) discovery = { '': [ ( 'C:/', { 'include_volume_name': False }, ), ( 'E:/', { 'include_volume_name': False },
#!/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.df_section import parse_df checkname = 'df' parsed = parse_df([ ['/dev/sda4', 'ext4', '143786696', '101645524', '34814148', '75%', '/'], ['/dev/sda2', 'ext4', '721392', '151120', '517808', '23%', '/boot'], ['[df_inodes_start]'], ['/dev/sda4', 'ext4', '9142272', '1654272', '7488000', '19%', '/'], ['/dev/sda2', 'ext4', '46848', '304', '46544', '1%', '/boot'], ['[df_inodes_end]'], ]) discovery = { '': [ ( '/', { 'include_volume_name': False }, ), ( '/boot', {
"32", "1", "0", ], ] ) @pytest.mark.parametrize( "section_mssql, section_df", [ ( SECTION_MSSQL, parse_df( [ ["Z:\\\\", "NTFS", "31463268", "16510812", "14952456", "53%", "Z:\\\\"], ] ), ), ( SECTION_MSSQL, None, ), ], ) def test_discovery_mssql_transactionlogs(section_mssql, section_df): assert sorted( msdt.discover_mssql_transactionlogs([{}], section_mssql, section_df), key=lambda s: s.item or "", # type: ignore[attr-defined] ) == [ Service(item="MSSQL46.CorreLog_Report_T.CorreLog_Report_T_log"),