cleanup, docs, devSyncHubNode #931

This commit is contained in:
jokob-sk
2025-01-07 21:03:20 +11:00
parent 07a7ace5fc
commit 0cc87e3cfc
9 changed files with 68 additions and 31 deletions

View File

@@ -131,6 +131,34 @@
}
]
},
{
"function": "IN_REGEX",
"type": {
"dataType": "string",
"elements": [
{
"elementType": "input",
"elementOptions": [],
"transformers": []
}
]
},
"default_value": ".*",
"options": [],
"localized": ["name", "description"],
"name": [
{
"language_code": "en_us",
"string": "Inclusion REGEX"
}
],
"description": [
{
"language_code": "en_us",
"string": "REGEX to specify which IPs are included in the scan. Examples: <code>192.168.1.*|10.0.0.1|172.16.5.*</code> (specific IPs or ranges). Use <code>.*</code> to include all IPs."
}
]
},
{
"function": "RUN_SCHD",
"type": {

View File

@@ -48,6 +48,7 @@ def main():
timeout = get_setting_value('ICMP_RUN_TIMEOUT')
args = get_setting_value('ICMP_ARGS')
in_regex = get_setting_value('ICMP_IN_REGEX')
# Create a database connection
db = DB() # instance of class DB
@@ -62,9 +63,19 @@ def main():
# Retrieve devices
all_devices = device_handler.getAll()
mylog('verbose', [f'[{pluginName}] Devices to PING: {len(all_devices)}'])
# Compile the regex for efficiency if it will be used multiple times
regex_pattern = re.compile(in_regex)
for device in all_devices:
# Filter devices based on the regex match
filtered_devices = [
device for device in all_devices
if regex_pattern.match(device['devLastIP'])
]
mylog('verbose', [f'[{pluginName}] Devices to PING: {len(filtered_devices)}'])
for device in filtered_devices:
is_online, output = execute_scan(device['devLastIP'], timeout, args)
mylog('verbose', [f'[{pluginName}] ip: "{device['devLastIP']}" is_online: "{is_online}"'])