Skip to content

Commit 91fa616

Browse files
committed
Merge branch 'development' into alex_dmesg_logs
2 parents f6ace34 + cc410e4 commit 91fa616

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ The Node Scraper CLI can be used to run Node Scraper plugins on a target system.
1717
options are available:
1818

1919
```sh
20-
usage: node-scraper [-h] [--sys-name STRING] [--sys-location {LOCAL,REMOTE}] [--sys-interaction-level {PASSIVE,INTERACTIVE,DISRUPTIVE}]
21-
[--sys-sku STRING] [--sys-platform STRING] [--plugin-configs [STRING ...]] [--system-config STRING]
22-
[--connection-config STRING] [--log-path STRING] [--log-level {CRITICAL,FATAL,ERROR,WARN,WARNING,INFO,DEBUG,NOTSET}]
23-
[--gen-reference-config]
20+
usage: node-scraper [-h] [--sys-name STRING] [--sys-location {LOCAL,REMOTE}] [--sys-interaction-level {PASSIVE,INTERACTIVE,DISRUPTIVE}] [--sys-sku STRING]
21+
[--sys-platform STRING] [--plugin-configs [STRING ...]] [--system-config STRING] [--connection-config STRING] [--log-path STRING]
22+
[--log-level {CRITICAL,FATAL,ERROR,WARN,WARNING,INFO,DEBUG,NOTSET}] [--gen-reference-config] [--skip-sudo]
2423
{summary,run-plugins,describe,gen-plugin-config} ...
2524

2625
node scraper CLI
@@ -39,8 +38,7 @@ options:
3938
--sys-location {LOCAL,REMOTE}
4039
Location of target system (default: LOCAL)
4140
--sys-interaction-level {PASSIVE,INTERACTIVE,DISRUPTIVE}
42-
Specify system interaction level, used to determine the type of actions that plugins can perform (default:
43-
INTERACTIVE)
41+
Specify system interaction level, used to determine the type of actions that plugins can perform (default: INTERACTIVE)
4442
--sys-sku STRING Manually specify SKU of system (default: None)
4543
--sys-platform STRING
4644
Specify system platform (default: None)
@@ -55,9 +53,43 @@ options:
5553
Change python log level (default: INFO)
5654
--gen-reference-config
5755
Generate reference config from system. Writes to ./reference_config.json. (default: False)
56+
--skip-sudo Skip plugins that require sudo permissions (default: False)
5857

5958
```
6059
60+
### Execution Methods
61+
62+
Node Scraper can operate in two modes: LOCAL and REMOTE, determined by the `--sys-location` argument.
63+
64+
- **LOCAL** (default): Node Scraper is installed and run directly on the target system. All data collection and plugin execution occur locally.
65+
- **REMOTE**: Node Scraper runs on your local machine but targets a remote system over SSH. In this mode, Node Scraper does not need to be installed on the remote system; all commands are executed remotely via SSH.
66+
67+
To use remote execution, specify `--sys-location REMOTE` and provide a connection configuration file with `--connection-config`.
68+
69+
#### Example: Remote Execution
70+
71+
```sh
72+
node-scraper --sys-name <remote_host> --sys-location REMOTE --connection-config ./connection_config.json run-plugins DmesgPlugin
73+
```
74+
75+
##### Example connection_config.json
76+
77+
```json
78+
{
79+
"InBandConnectionManager": {
80+
"hostname": "remote_host.example.com",
81+
"port": 22,
82+
"username": "myuser",
83+
"password": "mypassword",
84+
"key_filename": "/path/to/private/key"
85+
}
86+
}
87+
```
88+
89+
**Notes:**
90+
- If using SSH keys, specify `key_filename` instead of `password`.
91+
- The remote user must have permissions to run the requested plugins and access required files. If needed, use the `--skip-sudo` argument to skip plugins requiring sudo.
92+
6193
### Subcommmands
6294
6395
Plugins to run can be specified in two ways, using a plugin JSON config file or using the

nodescraper/connection/inband/inbandremote.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(
5757
) -> None:
5858
self.ssh_params = ssh_params
5959
self.client = paramiko.SSHClient()
60+
self.client.load_system_host_keys()
6061
self.client.set_missing_host_key_policy(self.host_key_policy())
6162

6263
def connect_ssh(self):

nodescraper/pluginexecutor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ def run_queue(self) -> list[PluginResult]:
194194
self.logger.exception("Unexpected exception running plugin queue: %s", str(e))
195195
finally:
196196
self.logger.info("Closing connections")
197-
for connection_manager in self.connection_library.values():
198-
connection_manager.disconnect()
199197

200198
if self.plugin_config.result_collators:
201199
self.logger.info("Running result collators")
@@ -217,6 +215,8 @@ def run_queue(self) -> list[PluginResult]:
217215
],
218216
**collator_args,
219217
)
218+
for connection_manager in self.connection_library.values():
219+
connection_manager.disconnect()
220220

221221
return plugin_results
222222

0 commit comments

Comments
 (0)