def automation_get_check_manpage(args): if len(args) != 1: raise MKAutomationError("Need exactly one argument.") check_type = args[0] manpage = man_pages.load_man_page(args[0]) # Add a few informations from check_info. Note: active checks do not # have an entry in check_info if check_type in check_info: manpage["type"] = "check_mk" info = check_info[check_type] for key in [ "snmp_info", "has_perfdata", "service_description" ]: if key in info: manpage[key] = info[key] if "." in check_type: section = check_type.split(".")[0] if section in check_info and "snmp_info" in check_info[section]: manpage["snmp_info"] = check_info[section]["snmp_info"] if "group" in info: manpage["group"] = info["group"] # Assume active check elif check_type.startswith("check_"): manpage["type"] = "active" else: raise MKAutomationError("Could not detect type of manpage: %s. " "Maybe the check is missing." % check_type) return manpage
def test_load_man_page_format(): page = man_pages.load_man_page("if64") assert type(page) == dict _check_man_page_structure(page) # Check optional keys for key in ['item', 'inventory']: assert key in page["header"]
def test_load_man_page_format(): page = man_pages.load_man_page("if64") assert type(page) == dict _check_man_page_structure(page) # Check optional keys for key in ['perfdata', 'item', 'examples', 'inventory']: assert key in page["header"] for entry in page["configuration"]: assert type(entry) == tuple assert len(entry) == 2 for entry in page["parameters"]: assert type(entry) == tuple assert len(entry) == 2
def test_load_man_page_format(): page = man_pages.load_man_page("if64") assert type(page) == dict _check_man_page_structure(page) # Check optional keys for key in [ 'perfdata', 'item', 'examples', 'inventory']: assert key in page["header"] for entry in page["configuration"]: assert type(entry) == tuple assert len(entry) == 2 for entry in page["parameters"]: assert type(entry) == tuple assert len(entry) == 2
def test_load_all_man_pages(): for name in man_pages.all_man_pages().keys(): man_page = man_pages.load_man_page(name) assert type(man_page) == dict _check_man_page_structure(man_page)
def test_load_man_page_not_existing(): assert man_pages.load_man_page("not_existing") == None