0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-24 13:14:11 +00:00
netdata_netdata/integrations/check_collector_metadata.py
Austin S. Hemmelgarn 183bb1db19
Add initial tooling for generating integrations.js file. ()
* Fix link tags in deploy.

* Add initial tooling for generating integrations.js file.

* Skip integrations directory for eslint.

* Add README to explain how to generate integrations.js locally.

* Fix ID/name for top-level categories.

* Deduplicate categories entries.

* Properly render related resources information.

* Warn on and skip bad references for related resources.

* Add CI workflow to rebuild integrations as-needed.

* Add integrations.js to build artifacts.

* Fix actionlint complaints.

* Assorted template fixes.

* Add script to check collector metadata.

* Add default categories for collectors when they have no categories.

* Fix template formatting issues.

* Link related resources properly.

* Skip more sections in rendered output if they are not present in source data.

* Temporarily skip config syntax section.

It needs further work and is not critical at the moment.

* Fix metrics table rendering.

* Hide most overview content if method_description is empty.

* Fix metrics table rendering (again).

* Add detailed description to setup options section.

* Fix detailed description handling for config options.

* Fix config example folding logic.

* Fix multi-instance selection.

* Properly fix multi-instance selection.

* Add titles for labels and metrics charts.

* Include monitored instance name in integration ID.

This is required to disambiguate some ‘virtual’ integrations.

* Indicate if there are no alerts defined for an integration.

* Fix multi-instance in template.

* Improve warning handling in script and fix category handling.

* Hide debug messages by default.

* Fix invalid category name in cgroups plugin.

* Completely fix invalid categories in cgroups plugin.

* Warn about and ignore duplicate integration ids.

* Flag integration type in integrations list.

* Add configuration syntax samples.

* Fix issues in gen_integrations.py

* Validate categories.yaml on load.

* Add support for handling deployment information.

* Fix bugs in gen_integrations.py

* Add code to handle exporters.

* Add link to integrations pointing to their source files.

* Fix table justification.

* Add notification handling to script.

Also tidy up a few other things.

* Fix numerous bugs in gen_integrations.py

* remove trailing space from deploy.yaml command

* make availability one column

* Switch back to multiple columns for availability.

And also switch form +/- to a dot for positive and empty cell for
negative.

* Render setup description.

* Fix platform info rendering in deploy integrations.

* Fix sourcing of cloud-notifications metadata.

* Fix rendering of empty metrics.

* Fix alerts template.

* Add per-instance templating for templated keys.

* Fix go plugin links.

* Fix overview template.

* Fix handling of exporters.

* Fix loading of cloud notification integrations.

* Always show full collector overview.

* Add static troubleshooting content when appropriate.

* Assorted deploy integration updates.

* Add initial copy of integrations.js.

---------

Co-authored-by: Fotis Voutsas <fotis@netdata.cloud>
2023-08-01 17:23:16 -04:00

89 lines
2.6 KiB
Python
Executable file

#!/usr/bin/env python3
import sys
from pathlib import Path
from jsonschema import ValidationError
from gen_integrations import (CATEGORIES_FILE, SINGLE_PATTERN, MULTI_PATTERN, SINGLE_VALIDATOR, MULTI_VALIDATOR,
load_yaml, get_category_sets)
def main():
if len(sys.argv) != 2:
print(':error:This script takes exactly one argument.')
return 2
check_path = Path(sys.argv[1])
if not check_path.is_file():
print(f':error file={ check_path }:{ check_path } does not appear to be a regular file.')
return 1
if check_path.match(SINGLE_PATTERN):
variant = 'single'
print(f':debug:{ check_path } appears to be single-module metadata.')
elif check_path.match(MULTI_PATTERN):
variant = 'multi'
print(f':debug:{ check_path } appears to be multi-module metadata.')
else:
print(f':error file={ check_path }:{ check_path } does not match required file name format.')
return 1
categories = load_yaml(CATEGORIES_FILE)
if not categories:
print(':error:Failed to load categories file.')
return 2
_, valid_categories = get_category_sets(categories)
data = load_yaml(check_path)
if not data:
print(f':error file={ check_path }:Failed to load data from { check_path }.')
return 1
check_modules = []
if variant == 'single':
try:
SINGLE_VALIDATOR.validate(data)
except ValidationError as e:
print(f':error file={ check_path }:Failed to validate { check_path } against the schema.')
raise e
else:
check_modules.append(data)
elif variant == 'multi':
try:
MULTI_VALIDATOR.validate(data)
except ValidationError as e:
print(f':error file={ check_path }:Failed to validate { check_path } against the schema.')
raise e
else:
for item in data['modules']:
item['meta']['plugin_name'] = data['plugin_name']
check_modules.append(item)
else:
print(':error:Internal error encountered.')
return 2
failed = False
for idx, module in enumerate(check_modules):
invalid_cats = set(module['meta']['monitored_instance']['categories']) - valid_categories
if invalid_cats:
print(f':error file={ check_path }:Invalid categories found in module { idx } in { check_path }: { ", ".joiin(invalid_cats) }.')
failed = True
if failed:
return 1
else:
print('{ check_path } is a valid collector metadata file.')
return 0
if __name__ == '__main__':
sys.exit(main())