@@ -18,8 +18,7 @@ system debug.
1818 - [ Global args] ( #global-args )
1919 - [ Plugin config: ` --plugin-configs ` command] ( #plugin-config---plugin-configs-command )
2020 - [ Reference config: ` gen-reference-config ` command] ( #reference-config-gen-reference-config-command )
21- - [ nodescraper integration] ( #nodescraper-integration )
22-
21+ - ** Extending Node Scraper (integration & external plugins)** → See [ EXTENDING.md] ( EXTENDING.md )
2322
2423## Installation
2524### Install From Source
@@ -114,7 +113,6 @@ node-scraper --sys-name <remote_host> --sys-location REMOTE --connection-config
114113Plugins to run can be specified in two ways, using a plugin JSON config file or using the
115114' run-plugins' sub command. These two options are not mutually exclusive and can be used together.
116115
117-
118116# ### **'describe' subcommand**
119117
120118You can use the ` describe` subcommand to display details about built-in configs or plugins.
@@ -228,7 +226,6 @@ node-scraper summary --summary_path /<path_to_node-scraper_logs>
228226This will generate a new file ' /<path_to_node-scraper_logs>/summary.csv' file. This file will
229227contain the results from all ' nodescraper.csv' files from ' /<path_to_node-scarper_logs>' .
230228
231-
232229# ## Configs
233230A plugin JSON config should follow the structure of the plugin config model defined here.
234231The globals field is a dictionary of global key-value pairs; values in globals will be passed to
@@ -374,128 +371,3 @@ node-scraper gen-plugin-config --gen-reference-config-from-logs scraper_logs_<pa
374371` ` `
375372This will generate a reference config that includes plugins with logged results in
376373' scraper_log_<path>' and save the new config to ' custom_output_dir/reference_config.json' .
377-
378-
379- # # nodescraper integration
380- Nodescraper can be integrated inside another Python tool by leveraging its classes and functionality.
381- See below for a comprehensive example on how to create plugins and run the associated data
382- collection and analysis.
383- Sample run command:
384- ` ` ` sh
385- python3 sample.py
386- ` ` `
387-
388- Sample.py file:
389- ` ` ` python
390- import logging
391- import sys
392- from nodescraper.plugins.inband.bios.bios_plugin import BiosPlugin
393- from nodescraper.plugins.inband.bios.analyzer_args import BiosAnalyzerArgs
394- from nodescraper.plugins.inband.kernel.kernel_plugin import KernelPlugin
395- from nodescraper.plugins.inband.kernel.analyzer_args import KernelAnalyzerArgs
396- from nodescraper.plugins.inband.os.os_plugin import OsPlugin
397- from nodescraper.plugins.inband.os.analyzer_args import OsAnalyzerArgs
398- from nodescraper.models.systeminfo import SystemInfo, OSFamily
399- from nodescraper.enums import EventPriority, SystemLocation
400- from nodescraper.resultcollators.tablesummary import TableSummary
401- from nodescraper.connection.inband.inbandmanager import InBandConnectionManager
402- from nodescraper.connection.inband.sshparams import SSHConnectionParams
403- from nodescraper.pluginregistry import PluginRegistry
404- from nodescraper.models.pluginconfig import PluginConfig
405- from nodescraper.pluginexecutor import PluginExecutor
406-
407- def main ():
408-
409- # setting up my custom logger
410- log_level = " INFO"
411- handlers = [logging.StreamHandler(stream=sys.stdout)]
412- logging.basicConfig(
413- force=True,
414- level=log_level,
415- format=" %(asctime)25s %(levelname)10s %(name)25s | %(message)s" ,
416- datefmt=" %Y-%m-%d %H:%M:%S %Z" ,
417- handlers=handlers,
418- encoding=" utf-8" ,
419- )
420- logging.root.setLevel(logging.INFO)
421- logging.getLogger(" paramiko" ).setLevel(logging.ERROR)
422- logger = logging.getLogger(" nodescraper" )
423-
424- # setting up system info
425- system_info = SystemInfo(name=" test_host" ,
426- platform=" X" ,
427- os_familty=OSFamily.LINUX,
428- sku=" some_sku" )
429-
430- # initiate plugins
431- bios_plugin = BiosPlugin(system_info=system_info, logger=logger)
432- kernel_plugin = KernelPlugin(system_info=system_info, logger=logger)
433-
434- # launch data collection
435- _ = bios_plugin.collect ()
436- _ = kernel_plugin.collect ()
437-
438- # launch data analysis
439- bios_plugin.analyze(analysis_args=BiosAnalyzerArgs(exp_bios_version=" XYZ" ))
440- kernel_plugin.analyze(analysis_args=KernelAnalyzerArgs(exp_kernel=" ABC" ))
441-
442- # log plugin data models
443- logger.info(kernel_plugin.data.model_dump ())
444- logger.info(bios_plugin.data.model_dump ())
445-
446- # alternate method
447- all_res = []
448-
449- # launch plugin collection & analysis
450- bios_result = bios_plugin.run(analysis_args={" exp_bios_version" :" ABC" })
451- all_res.append(bios_result)
452- table_summary = TableSummary ()
453- table_summary.collate_results(all_res, None)
454-
455- # remote connection
456- system_info.location=SystemLocation.REMOTE
457- ssh_params = SSHConnectionParams(hostname=" my_system" ,
458- port=22,
459- username=" my_username" ,
460- key_filename=" /home/user/.ssh/ssh_key" )
461- conn_manager = InBandConnectionManager(system_info=system_info, connection_args=ssh_params)
462- os_plugin = OsPlugin(system_info=system_info, logger=logger, connection_manager=conn_manager)
463- os_plugin.run(analysis_args=OsAnalyzerArgs(exp_os=" DEF" ))
464-
465- # run multiple plugins through a queue
466- system_info.location=SystemLocation.LOCAL
467- config_dict = {
468- " global_args" : {
469- " collection" : 1,
470- " analysis" : 1
471- },
472- " plugins" : {
473- " BiosPlugin" : {
474- " analysis_args" : {
475- " exp_bios_version" : " 123" ,
476- }
477- },
478- " KernelPlugin" : {
479- " analysis_args" : {
480- " exp_kernel" : " ABC" ,
481- }
482- }
483- },
484- " result_collators" : {},
485- " name" : " plugin_config" ,
486- " desc" : " Auto generated config"
487- }
488-
489- config1 = PluginConfig(** config_dict)
490- plugin_executor = PluginExecutor(
491- logger=logger,
492- plugin_configs=[config1],
493- system_info=system_info
494- )
495- results = plugin_executor.run_queue ()
496-
497-
498-
499- if __name__ == " __main__" :
500- main ()
501- ` ` `
0 commit comments