mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
🔺GraphQL v0.1 + Devices table rebuild + removal of backend compatible scripts
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
{
|
||||
"name": "devices",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_LastIP from DEVICES",
|
||||
"value": "SELECT devLastIP from DEVICES",
|
||||
"timeoutMultiplier": true
|
||||
}
|
||||
],
|
||||
@@ -740,7 +740,7 @@
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"default_value": "select rowid, * from Devices where dev_Name not in ({s-quote}null{s-quote}, {s-quote}(name not found){s-quote}, {s-quote}(unknown){s-quote})",
|
||||
"default_value": "select rowid, * from Devices where devName not in ({s-quote}null{s-quote}, {s-quote}(name not found){s-quote}, {s-quote}(unknown){s-quote})",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
|
||||
@@ -443,49 +443,49 @@ def mqtt_start(db):
|
||||
for device in devices:
|
||||
|
||||
# # debug statement START 🔻
|
||||
# if 'Moto' not in device["dev_Name"]:
|
||||
# if 'Moto' not in device["devName"]:
|
||||
# continue
|
||||
# # debug statement END 🔺
|
||||
|
||||
# Create devices in Home Assistant - send config messages
|
||||
deviceId = 'mac_' + device["dev_MAC"].replace(" ", "").replace(":", "_").lower()
|
||||
deviceId = 'mac_' + device["devMac"].replace(" ", "").replace(":", "_").lower()
|
||||
# Normalize the string and remove unwanted characters
|
||||
devDisplayName = re.sub('[^a-zA-Z0-9-_\\s]', '', normalize_string(device["dev_Name"]))
|
||||
devDisplayName = re.sub('[^a-zA-Z0-9-_\\s]', '', normalize_string(device["devName"]))
|
||||
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'last_ip', 'ip-network', device["dev_MAC"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'mac_address', 'folder-key-network', device["dev_MAC"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'is_new', 'bell-alert-outline', device["dev_MAC"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'vendor', 'cog', device["dev_MAC"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'first_connection', 'calendar-start', device["dev_MAC"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'last_connection', 'calendar-end', device["dev_MAC"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'last_ip', 'ip-network', device["devMac"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'mac_address', 'folder-key-network', device["devMac"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'is_new', 'bell-alert-outline', device["devMac"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'vendor', 'cog', device["devMac"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'first_connection', 'calendar-start', device["devMac"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'sensor', 'last_connection', 'calendar-end', device["devMac"])
|
||||
|
||||
|
||||
devJson = {
|
||||
"last_ip": device["dev_LastIP"],
|
||||
"is_new": str(device["dev_NewDevice"]),
|
||||
"vendor": sanitize_string(device["dev_Vendor"]),
|
||||
"mac_address": str(device["dev_MAC"]),
|
||||
"last_ip": device["devLastIP"],
|
||||
"is_new": str(device["devIsNew"]),
|
||||
"vendor": sanitize_string(device["devVendor"]),
|
||||
"mac_address": str(device["devMac"]),
|
||||
"model": devDisplayName,
|
||||
"last_connection": prepTimeStamp(str(device["dev_LastConnection"])),
|
||||
"first_connection": prepTimeStamp(str(device["dev_FirstConnection"])) }
|
||||
"last_connection": prepTimeStamp(str(device["devLastConnection"])),
|
||||
"first_connection": prepTimeStamp(str(device["devFirstConnection"])) }
|
||||
|
||||
# bulk update device sensors in home assistant
|
||||
publish_mqtt(mqtt_client, sensorConfig.state_topic, devJson)
|
||||
|
||||
# create and update is_present sensor
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'binary_sensor', 'is_present', 'wifi', device["dev_MAC"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'binary_sensor', 'is_present', 'wifi', device["devMac"])
|
||||
publish_mqtt(mqtt_client, sensorConfig.state_topic,
|
||||
{
|
||||
"is_present": to_binary_sensor(str(device["dev_PresentLastScan"]))
|
||||
"is_present": to_binary_sensor(str(device["devPresentLastScan"]))
|
||||
}
|
||||
)
|
||||
|
||||
# handle device_tracker
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'device_tracker', 'is_home', 'home', device["dev_MAC"])
|
||||
sensorConfig = create_sensor(mqtt_client, deviceId, devDisplayName, 'device_tracker', 'is_home', 'home', device["devMac"])
|
||||
|
||||
# <away|home> are only valid states
|
||||
state = 'away'
|
||||
if to_binary_sensor(str(device["dev_PresentLastScan"])) == "ON":
|
||||
if to_binary_sensor(str(device["devPresentLastScan"])) == "ON":
|
||||
state = 'home'
|
||||
|
||||
publish_mqtt(mqtt_client, sensorConfig.state_topic, state)
|
||||
|
||||
@@ -56,9 +56,9 @@ def main():
|
||||
|
||||
# Mock list of devices (replace with actual device_handler.getUnknown() in production)
|
||||
# unknown_devices = [
|
||||
# {'dev_MAC': '00:11:22:33:44:55', 'dev_LastIP': '192.168.1.121'},
|
||||
# {'dev_MAC': '00:11:22:33:44:56', 'dev_LastIP': '192.168.1.9'},
|
||||
# {'dev_MAC': '00:11:22:33:44:57', 'dev_LastIP': '192.168.1.82'},
|
||||
# {'devMac': '00:11:22:33:44:55', 'devLastIP': '192.168.1.121'},
|
||||
# {'devMac': '00:11:22:33:44:56', 'devLastIP': '192.168.1.9'},
|
||||
# {'devMac': '00:11:22:33:44:57', 'devLastIP': '192.168.1.82'},
|
||||
# ]
|
||||
|
||||
mylog('verbose', [f'[{pluginName}] Unknown devices count: {len(unknown_devices)}'])
|
||||
@@ -68,20 +68,20 @@ def main():
|
||||
ensure_avahi_running()
|
||||
|
||||
for device in unknown_devices:
|
||||
domain_name = execute_name_lookup(device['dev_LastIP'], timeout)
|
||||
domain_name = execute_name_lookup(device['devLastIP'], timeout)
|
||||
|
||||
# check if found and not a timeout ('to')
|
||||
if domain_name != '' and domain_name != 'to':
|
||||
plugin_objects.add_object(
|
||||
# "MAC", "IP", "Server", "Name"
|
||||
primaryId = device['dev_MAC'],
|
||||
secondaryId = device['dev_LastIP'],
|
||||
primaryId = device['devMac'],
|
||||
secondaryId = device['devLastIP'],
|
||||
watched1 = '', # You can add any relevant info here if needed
|
||||
watched2 = domain_name,
|
||||
watched3 = '',
|
||||
watched4 = '',
|
||||
extra = '',
|
||||
foreignKey = device['dev_MAC'])
|
||||
foreignKey = device['devMac'])
|
||||
|
||||
plugin_objects.write_result_file()
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
{
|
||||
"name": "ips",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_LastIP from DEVICES order by dev_MAC",
|
||||
"value": "SELECT devLastIP from DEVICES order by devMac",
|
||||
"timeoutMultiplier": true
|
||||
}
|
||||
],
|
||||
|
||||
@@ -141,7 +141,7 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
|
||||
# Cleanup New Devices
|
||||
if HRS_TO_KEEP_NEWDEV != 0:
|
||||
mylog('verbose', [f'[{pluginName}] Devices: Delete all New Devices older than {str(HRS_TO_KEEP_NEWDEV)} hours (HRS_TO_KEEP_NEWDEV setting)'])
|
||||
query = f"""DELETE FROM Devices WHERE dev_NewDevice = 1 AND dev_FirstConnection < date('now', '-{str(HRS_TO_KEEP_NEWDEV)} hour')"""
|
||||
query = f"""DELETE FROM Devices WHERE devIsNew = 1 AND devFirstConnection < date('now', '-{str(HRS_TO_KEEP_NEWDEV)} hour')"""
|
||||
mylog('verbose', [f'[{pluginName}] Query: {query} '])
|
||||
cursor.execute (query)
|
||||
|
||||
@@ -149,7 +149,7 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
|
||||
# Cleanup Offline Devices
|
||||
if HRS_TO_KEEP_OFFDEV != 0:
|
||||
mylog('verbose', [f'[{pluginName}] Devices: Delete all New Devices older than {str(HRS_TO_KEEP_OFFDEV)} hours (HRS_TO_KEEP_OFFDEV setting)'])
|
||||
query = f"""DELETE FROM Devices WHERE dev_PresentLastScan = 0 AND dev_LastConnection < date('now', '-{str(HRS_TO_KEEP_OFFDEV)} hour'))"""
|
||||
query = f"""DELETE FROM Devices WHERE devPresentLastScan = 0 AND devLastConnection < date('now', '-{str(HRS_TO_KEEP_OFFDEV)} hour'))"""
|
||||
mylog('verbose', [f'[{pluginName}] Query: {query} '])
|
||||
cursor.execute (query)
|
||||
|
||||
@@ -157,8 +157,8 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
|
||||
# Clear New Flag
|
||||
if CLEAR_NEW_FLAG != 0:
|
||||
mylog('verbose', [f'[{pluginName}] Devices: Clear "New Device" flag for all devices older than {str(CLEAR_NEW_FLAG)} hours (CLEAR_NEW_FLAG setting)'])
|
||||
query = f"""UPDATE Devices SET dev_NewDevice = 0 WHERE dev_NewDevice = 1 AND date(dev_FirstConnection, '+{str(CLEAR_NEW_FLAG)} hour') < date('now')"""
|
||||
# select * from Devices where dev_NewDevice = 1 AND date(dev_FirstConnection, '+3 hour' ) < date('now')
|
||||
query = f"""UPDATE Devices SET devIsNew = 0 WHERE devIsNew = 1 AND date(devFirstConnection, '+{str(CLEAR_NEW_FLAG)} hour') < date('now')"""
|
||||
# select * from Devices where devIsNew = 1 AND date(devFirstConnection, '+3 hour' ) < date('now')
|
||||
mylog('verbose', [f'[{pluginName}] Query: {query} '])
|
||||
cursor.execute(query)
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
{
|
||||
"name": "prev_ip",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_LastIP FROM Devices WHERE dev_MAC = 'Internet' "
|
||||
"value": "SELECT devLastIP FROM Devices WHERE devMac = 'Internet' "
|
||||
},
|
||||
{
|
||||
"name": "DDNS_UPDATE_URL",
|
||||
|
||||
@@ -1,967 +0,0 @@
|
||||
{
|
||||
"code_name": "events_notifications",
|
||||
"plugin_type": "flow",
|
||||
"template_type": "database-entry",
|
||||
"unique_prefix": "EVNTNTF",
|
||||
"enabled": true,
|
||||
"data_source": "template",
|
||||
"show_ui": false,
|
||||
"localized": ["display_name", "description", "icon"],
|
||||
"display_name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Known Devices"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The template used for known devices."
|
||||
}
|
||||
],
|
||||
"icon": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "<i class=\"fa fa-check\"></i>"
|
||||
}
|
||||
],
|
||||
"params": [
|
||||
{
|
||||
"name": "target_macs",
|
||||
"type": "setting",
|
||||
"value": "KNWN_target_macs"
|
||||
},
|
||||
{
|
||||
"name": "dev_AlertDeviceDown",
|
||||
"type": "setting",
|
||||
"value": "KNWN_dev_AlertDeviceDown"
|
||||
},
|
||||
{
|
||||
"name": "dev_AlertEvents",
|
||||
"type": "setting",
|
||||
"value": "KNWN_dev_AlertEvents"
|
||||
},
|
||||
{
|
||||
"name": "trigger_ids",
|
||||
"type": "array",
|
||||
"value": "trigger.Object_PrimaryID"
|
||||
},
|
||||
{
|
||||
"name": "trigger_objects",
|
||||
"type": "array",
|
||||
"value": "trigger"
|
||||
}
|
||||
],
|
||||
"settings": [
|
||||
{
|
||||
"function": "FLOW",
|
||||
"type": "json",
|
||||
"default_value": [
|
||||
{
|
||||
"name": "send_notification",
|
||||
"trigger": [
|
||||
{
|
||||
"object_event": "new",
|
||||
"object_filter": "",
|
||||
"object": "Events_Notifications"
|
||||
}
|
||||
],
|
||||
"steps": [
|
||||
{
|
||||
"step_type": "wait",
|
||||
"params": [
|
||||
{
|
||||
"days": 0,
|
||||
"hours": 0,
|
||||
"minutes": 0,
|
||||
"seconds": 30
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step_type": "condition",
|
||||
"params": [
|
||||
{
|
||||
"left": {
|
||||
"value": "triggers[0].object['dev_DeviceID']",
|
||||
"use_quotes": true,
|
||||
"js_template": "'{value}'.toString()"
|
||||
},
|
||||
"operator": {
|
||||
"value": "==",
|
||||
"data_type": "string"
|
||||
},
|
||||
"right": {
|
||||
"value": "device_id_param",
|
||||
"use_quotes": false,
|
||||
"js_template": "'{value}'.toString()"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step_type": "condition",
|
||||
"params": [
|
||||
{
|
||||
"left": {
|
||||
"value": "check_event_repetition(device_id_param, event_type_param, repetition_count_param)",
|
||||
"use_quotes": false,
|
||||
"js_template": "{value}"
|
||||
},
|
||||
"operator": {
|
||||
"value": "==",
|
||||
"data_type": "boolean"
|
||||
},
|
||||
"right": {
|
||||
"value": true,
|
||||
"use_quotes": false,
|
||||
"js_template": "{value}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step_type": "action",
|
||||
"params": [
|
||||
{
|
||||
"type": "run_plugin",
|
||||
"params": {
|
||||
"unique_prefix": "webhook"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step_type": "action",
|
||||
"params": [
|
||||
{
|
||||
"type": "run_plugin",
|
||||
"params": {
|
||||
"unique_prefix": "mqtt"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"options": [
|
||||
{
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device ID Parameter"
|
||||
}
|
||||
],
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": "1",
|
||||
"localized": ["name"]
|
||||
},
|
||||
{
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Event Type Parameter"
|
||||
}
|
||||
],
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": "device_down",
|
||||
"localized": ["name"]
|
||||
},
|
||||
{
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Repetition Count Parameter"
|
||||
}
|
||||
],
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "number" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 3,
|
||||
"localized": ["name"]
|
||||
}
|
||||
],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Plugin flow"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "This flow sends a notification after 30s every time a new event is logged."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "target_macs",
|
||||
"type": "list.readonly",
|
||||
"maxLength": 50,
|
||||
"default_value": [],
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Target devices"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The MAC address of the devices to update. Uneditable. This parameter is dynamically updated via a Flow."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "CMD",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"default_value": "UPDATE Devices SET dev_AlertDeviceDown = {KNWN_dev_AlertDeviceDown}, dev_AlertEvents = {KNWN_dev_AlertEvents} WHERE dev_MAC in ({target_macs})",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "UPDATE SQL"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "This SQL query is used to update target devices."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Name",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"maxLength": 50,
|
||||
"default_value": "(unknown)",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Name"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The name of the device. Uneditable as internal functionality is dependent on specific new device names."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Owner",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"maxLength": 30,
|
||||
"default_value": "House",
|
||||
"override_value": {
|
||||
"override": false
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Owner"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The owner of the device."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_DeviceType",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"maxLength": 30,
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Type"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The type of the device."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Vendor",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"maxLength": 250,
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Vendor"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The vendor of the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Favorite",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"override_value": {
|
||||
"override": false
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Favorite Device"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device is marked as a favorite."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Group",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"maxLength": 10,
|
||||
"default_value": "",
|
||||
"override_value": {
|
||||
"override": false
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Group"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The group to which the device belongs."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Comments",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Comments"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Additional comments or notes about the device."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_FirstConnection",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": "date-time",
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "First Connection"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The date and time of the first connection with the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LastConnection",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": "date-time",
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Last Connection"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The date and time of the last connection with the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LastIP",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"maxLength": 50,
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Last IP"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The last known IP address of the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_StaticIP",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 1,
|
||||
"override_value": {
|
||||
"override": true
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Static IP"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device has a static IP address."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_ScanCycle",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 1,
|
||||
"override_value": {
|
||||
"override": true
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Scan Cycle"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The default value of the <code>Scan device</code> dropdown. Enable if newly discovered devices should be scanned."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LogEvents",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"override_value": {
|
||||
"override": false
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Log Events"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether events related to the device shouldbe logged."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_AlertEvents",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"override_value": {
|
||||
"override": true
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Alert Events"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether events related to the device should trigger alerts. The default value of the <code>Alert Events</code> checkbox. Down and New Device notifications are always sent unless unselected in <code>NTFPRCS_INCLUDED_SECTIONS</code>."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_AlertDeviceDown",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Alert Device Down"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether an alert should be triggered when the device goes down. The default value of the <code>Alert Down</code> checkbox."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_SkipRepeated",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "number" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Skip Repeated"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The default value of the <code>Skip repeated notifications for</code> dropdown. Enter number of <b>hours</b> for which repeated notifications should be ignored for. If you enter <code>0</code> then you get notified on all events."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LastNotification",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": "date-time",
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Last Notification"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The date and time of the last notification sent for the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_PresentLastScan",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 1,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Present Last Scan"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device should be marked as present after detected in a scan."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_NewDevice",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": true,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "New Device"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device is considered a new device. The default value of the <code>New Device</code> checkbox."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Location",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"maxLength": 250,
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Location"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The location of the device."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Archived",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Archived"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device is archived. The default value of the <code>Archived</code> checkbox."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Network_Node_MAC_ADDR",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Network Node MAC Address"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The MAC address of the network node."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Network_Node_port",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Network Node Port"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The port number of the network node. Uneditable."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Icon",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Icon"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The icon associated with the device. Check the <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/ICONS.md\" target=\"_blank\">documentation on icons</a> for more details."
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"required": [
|
||||
"dev_MAC",
|
||||
"dev_Name",
|
||||
"dev_Owner",
|
||||
"dev_FirstConnection",
|
||||
"dev_LastConnection",
|
||||
"dev_LastIP",
|
||||
"dev_StaticIP",
|
||||
"dev_ScanCycle",
|
||||
"dev_LogEvents",
|
||||
"dev_AlertEvents",
|
||||
"dev_AlertDeviceDown",
|
||||
"dev_SkipRepeated",
|
||||
"dev_LastNotification",
|
||||
"dev_PresentLastScan",
|
||||
"dev_NewDevice",
|
||||
"dev_Location",
|
||||
"dev_Archived",
|
||||
"dev_Network_Node_MAC_ADDR",
|
||||
"dev_Network_Node_port",
|
||||
"dev_Icon"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
This plugin will not be loaded
|
||||
@@ -51,7 +51,7 @@
|
||||
{
|
||||
"name": "prev_ip",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_LastIP FROM Devices WHERE dev_MAC = 'Internet' "
|
||||
"value": "SELECT devLastIP FROM Devices WHERE devMac = 'Internet' "
|
||||
},
|
||||
{
|
||||
"name": "INTRNT_DIG_GET_IP_ARG",
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
## Overview
|
||||
|
||||
A simple template-based plugin for known devices. You can change to overwrite values for known devices.
|
||||
|
||||
### Usage
|
||||
|
||||
- Head to **Settings** > **Known Devices** to adjust the default values.
|
||||
|
||||
### Notes
|
||||
|
||||
- This plugin generates editable settings that are then used in the `device.py` script to initialize new values. TO FIX
|
||||
@@ -1,883 +0,0 @@
|
||||
{
|
||||
"code_name": "known_template",
|
||||
"template_type": "database-entry",
|
||||
"unique_prefix": "KNWN",
|
||||
"plugin_type": "system",
|
||||
"enabled": true,
|
||||
"data_source": "template",
|
||||
"show_ui": false,
|
||||
"localized": ["display_name", "description", "icon"],
|
||||
"display_name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Known Devices"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The template used for known devices."
|
||||
}
|
||||
],
|
||||
"icon": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "<i class=\"fa fa-check\"></i>"
|
||||
}
|
||||
],
|
||||
"params": [
|
||||
{
|
||||
"name": "target_macs",
|
||||
"type": "setting",
|
||||
"value": "KNWN_target_macs"
|
||||
},
|
||||
{
|
||||
"name": "dev_AlertDeviceDown",
|
||||
"type": "setting",
|
||||
"value": "KNWN_dev_AlertDeviceDown"
|
||||
},
|
||||
{
|
||||
"name": "dev_AlertEvents",
|
||||
"type": "setting",
|
||||
"value": "KNWN_dev_AlertEvents"
|
||||
},
|
||||
{
|
||||
"name": "trigger_ids",
|
||||
"type": "array",
|
||||
"value": "trigger.Object_PrimaryID"
|
||||
},
|
||||
{
|
||||
"name": "trigger_objects",
|
||||
"type": "array",
|
||||
"value": "trigger"
|
||||
}
|
||||
],
|
||||
"settings": [
|
||||
{
|
||||
"function": "FLOW",
|
||||
"type": "json",
|
||||
"default_value": [
|
||||
{
|
||||
"name": "apply_template",
|
||||
"trigger": [
|
||||
{
|
||||
"object_event": "new",
|
||||
"object_filter": "",
|
||||
"object": "Devices"
|
||||
}
|
||||
],
|
||||
"steps": [
|
||||
{
|
||||
"step_type": "wait",
|
||||
"params": [
|
||||
{
|
||||
"days": 3,
|
||||
"hours": 0,
|
||||
"minutes": 0,
|
||||
"seconds": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step_type": "condition",
|
||||
"params": [
|
||||
{
|
||||
"left": {
|
||||
"value": "triggers[0].object['dev_NewDevice']",
|
||||
"use_quotes": true,
|
||||
"js_template": "'{value}'.toString()"
|
||||
},
|
||||
"operator": {
|
||||
"value": "==",
|
||||
"data_type": "boolean"
|
||||
},
|
||||
"right": {
|
||||
"value": true,
|
||||
"use_quotes": false,
|
||||
"js_template": "'{value}'.toString()"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step_type": "action",
|
||||
"params": [
|
||||
{
|
||||
"type": "plugin",
|
||||
"params": {
|
||||
"unique_prefix": "KNWN",
|
||||
"overrides": [
|
||||
{
|
||||
"object_path": "settings.0",
|
||||
"key": "function",
|
||||
"value": "target_macs",
|
||||
"target_property": "default_value",
|
||||
"desired_value": "triggers.keys"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Plugin flow"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "This flow makes sure the template is applied to devices that are older than 3 days."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "target_macs",
|
||||
"type": "list.readonly",
|
||||
"maxLength": 50,
|
||||
"default_value": [],
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Target devices"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The MAC address of the devices to update. Uneditable. This parameter is dynamically updated via a Flow."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "CMD",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"default_value": "UPDATE Devices SET dev_AlertDeviceDown = {KNWN_dev_AlertDeviceDown}, dev_AlertEvents = {KNWN_dev_AlertEvents} WHERE dev_MAC in ({target_macs})",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "UPDATE SQL"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "This SQL query is used to update target devices."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Name",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"maxLength": 50,
|
||||
"default_value": "(unknown)",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Name"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The name of the device. Uneditable as internal functionality is dependent on specific new device names."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Owner",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"maxLength": 30,
|
||||
"default_value": "House",
|
||||
"override_value": {
|
||||
"override": false
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Owner"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The owner of the device."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_DeviceType",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"maxLength": 30,
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Type"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The type of the device."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Vendor",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"maxLength": 250,
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Vendor"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The vendor of the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Favorite",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"override_value": {
|
||||
"override": false
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Favorite Device"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device is marked as a favorite."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Group",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"maxLength": 10,
|
||||
"default_value": "",
|
||||
"override_value": {
|
||||
"override": false
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Group"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The group to which the device belongs."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Comments",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Comments"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Additional comments or notes about the device."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_FirstConnection",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": "date-time",
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "First Connection"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The date and time of the first connection with the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LastConnection",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": "date-time",
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Last Connection"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The date and time of the last connection with the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LastIP",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"maxLength": 50,
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Last IP"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The last known IP address of the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_StaticIP",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 1,
|
||||
"override_value": {
|
||||
"override": true
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Static IP"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device has a static IP address."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_ScanCycle",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 1,
|
||||
"override_value": {
|
||||
"override": true
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Scan Cycle"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The default value of the <code>Scan device</code> dropdown. Enable if newly discovered devices should be scanned."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LogEvents",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"override_value": {
|
||||
"override": false
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Log Events"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether events related to the device shouldbe logged."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_AlertEvents",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"override_value": {
|
||||
"override": true
|
||||
},
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Alert Events"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether events related to the device should trigger alerts. The default value of the <code>Alert All Events</code> checkbox."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_AlertDeviceDown",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Alert Device Down"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether an alert should be triggered when the device goes down. The default value of the <code>Alert Down</code> checkbox."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_SkipRepeated",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "number" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Skip Repeated"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The default value of the <code>Skip repeated notifications for</code> dropdown. Enter number of <b>hours</b> for which repeated notifications should be ignored for. If you enter <code>0</code> then you get notified on all events."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LastNotification",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": "date-time",
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Last Notification"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The date and time of the last notification sent for the device. Uneditable - Autodetected."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_PresentLastScan",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 1,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Present Last Scan"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device should be marked as present after detected in a scan."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_NewDevice",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": true,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "New Device"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device is considered a new device. The default value of the <code>New Device</code> checkbox."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Location",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"maxLength": 250,
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Location"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The location of the device."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Archived",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "type": "checkbox" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Archived"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Indicates whether the device is archived. The default value of the <code>Archived</code> checkbox."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Network_Node_MAC_ADDR",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Network Node MAC Address"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The MAC address of the network node."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Network_Node_port",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": 0,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Network Node Port"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The port number of the network node. Uneditable."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Icon",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{ "elementType": "input", "elementOptions": [], "transformers": [] }
|
||||
]
|
||||
},
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device Icon"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The icon associated with the device. Check the <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/ICONS.md\" target=\"_blank\">documentation on icons</a> for more details."
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"required": [
|
||||
"dev_MAC",
|
||||
"dev_Name",
|
||||
"dev_Owner",
|
||||
"dev_FirstConnection",
|
||||
"dev_LastConnection",
|
||||
"dev_LastIP",
|
||||
"dev_StaticIP",
|
||||
"dev_ScanCycle",
|
||||
"dev_LogEvents",
|
||||
"dev_AlertEvents",
|
||||
"dev_AlertDeviceDown",
|
||||
"dev_SkipRepeated",
|
||||
"dev_LastNotification",
|
||||
"dev_PresentLastScan",
|
||||
"dev_NewDevice",
|
||||
"dev_Location",
|
||||
"dev_Archived",
|
||||
"dev_Network_Node_MAC_ADDR",
|
||||
"dev_Network_Node_port",
|
||||
"dev_Icon"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
This plugin will not be loaded
|
||||
@@ -30,7 +30,7 @@
|
||||
{
|
||||
"name": "ips",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_LastIP from DEVICES order by dev_MAC",
|
||||
"value": "SELECT devLastIP from DEVICES order by devMac",
|
||||
"timeoutMultiplier": true
|
||||
},
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
{
|
||||
"name": "ips",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_LastIP from DEVICES order by dev_MAC",
|
||||
"value": "SELECT devLastIP from DEVICES order by devMac",
|
||||
"timeoutMultiplier": true
|
||||
}
|
||||
],
|
||||
|
||||
@@ -60,19 +60,19 @@ def main():
|
||||
# execute_name_lookup('192.168.1.121', timeout)
|
||||
|
||||
for device in unknown_devices:
|
||||
domain_name, dns_server = execute_name_lookup(device['dev_LastIP'], timeout)
|
||||
domain_name, dns_server = execute_name_lookup(device['devLastIP'], timeout)
|
||||
|
||||
if domain_name != '':
|
||||
plugin_objects.add_object(
|
||||
# "MAC", "IP", "Server", "Name"
|
||||
primaryId = device['dev_MAC'],
|
||||
secondaryId = device['dev_LastIP'],
|
||||
primaryId = device['devMac'],
|
||||
secondaryId = device['devLastIP'],
|
||||
watched1 = dns_server,
|
||||
watched2 = domain_name,
|
||||
watched3 = '',
|
||||
watched4 = '',
|
||||
extra = '',
|
||||
foreignKey = device['dev_MAC'])
|
||||
foreignKey = device['devMac'])
|
||||
|
||||
plugin_objects.write_result_file()
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_MAC",
|
||||
"function": "devMac",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -295,7 +295,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Name",
|
||||
"function": "devName",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -324,7 +324,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Owner",
|
||||
"function": "devOwner",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -338,7 +338,7 @@
|
||||
{
|
||||
"name": "value",
|
||||
"type": "sql",
|
||||
"value": "SELECT DISTINCT '' as id, '❌None' as name UNION SELECT dev_Owner as id, dev_Owner as name FROM (SELECT dev_Owner FROM Devices UNION SELECT 'House' ) AS all_devices ORDER BY id;"
|
||||
"value": "SELECT DISTINCT '' as id, '❌None' as name UNION SELECT devOwner as id, devOwner as name FROM (SELECT devOwner FROM Devices UNION SELECT 'House' ) AS all_devices ORDER BY id;"
|
||||
}
|
||||
],
|
||||
"localized": ["name", "description"],
|
||||
@@ -356,7 +356,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_DeviceType",
|
||||
"function": "devType",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -370,7 +370,7 @@
|
||||
{
|
||||
"name": "value",
|
||||
"type": "sql",
|
||||
"value": "SELECT DISTINCT 9 as ord, dev_DeviceType as id, dev_DeviceType as name FROM Devices WHERE dev_DeviceType NOT IN ('', 'Smartphone', 'Tablet', 'Laptop', 'Mini PC', 'PC', 'Printer', 'Server', 'Singleboard Computer (SBC)', 'NAS', 'Domotic', 'IP Camera', 'Game Console', 'SmartTV', 'TV Decoder', 'Virtual Assistance', 'Clock', 'House Appliance', 'Phone', 'Radio', 'AP', 'Gateway', 'Firewall', 'Hypervisor', 'Powerline', 'Switch', 'WLAN', 'PLC', 'Router', 'USB LAN Adapter', 'USB WIFI Adapter') UNION SELECT 0 as ord, '', '❌None' UNION SELECT 1 as ord, '-----', '-- 📱Handhelds --' UNION SELECT 1 as ord, 'Smartphone', 'Smartphone' UNION SELECT 1 as ord, 'Tablet', 'Tablet' UNION SELECT 2 as ord, '-----', '-- 💻Computers --' UNION SELECT 2 as ord, 'Laptop', 'Laptop' UNION SELECT 2 as ord, 'Mini PC', 'Mini PC' UNION SELECT 2 as ord, 'PC', 'PC' UNION SELECT 2 as ord, 'Printer', 'Printer' UNION SELECT 2 as ord, 'Server', 'Server' UNION SELECT 2 as ord, 'Singleboard Computer (SBC)', 'Singleboard Computer (SBC)' UNION SELECT 2 as ord, 'NAS', 'NAS' UNION SELECT 3 as ord, '-----', '-- 🏠Smart home --' UNION SELECT 3 as ord, 'Domotic', 'Domotic' UNION SELECT 3 as ord, 'IP Camera', 'IP Camera' UNION SELECT 3 as ord, 'Game Console', 'Game Console' UNION SELECT 3 as ord, 'SmartTV', 'SmartTV' UNION SELECT 3 as ord, 'TV Decoder', 'TV Decoder' UNION SELECT 3 as ord, 'Virtual Assistance', 'Virtual Assistance' UNION SELECT 4 as ord, '-----', '-- Wired --' UNION SELECT 4 as ord, 'Clock', 'Clock' UNION SELECT 4 as ord, 'House Appliance', 'House Appliance' UNION SELECT 4 as ord, 'Phone', 'Phone' UNION SELECT 4 as ord, 'Radio', 'Radio' UNION SELECT 5 as ord, '-----', '-- 📡Network nodes --' UNION SELECT 5 as ord, 'AP', 'AP' UNION SELECT 5 as ord, 'Gateway', 'Gateway' UNION SELECT 5 as ord, 'Firewall', 'Firewall' UNION SELECT 5 as ord, 'Hypervisor', 'Hypervisor' UNION SELECT 5 as ord, 'Powerline', 'Powerline' UNION SELECT 5 as ord, 'Switch', 'Switch' UNION SELECT 5 as ord, 'WLAN', 'WLAN' UNION SELECT 5 as ord, 'PLC', 'PLC' UNION SELECT 5 as ord, 'Router', 'Router' UNION SELECT 5 as ord, 'USB LAN Adapter', 'USB LAN Adapter' UNION SELECT 5 as ord, 'USB WIFI Adapter', 'USB WIFI Adapter' UNION SELECT 9 as ord, '-----', '-- ⚙Custom --' UNION SELECT 10 as ord, '-----', '-----' UNION SELECT 10 as ord, 'Other', 'Other' ORDER BY 1,2;"
|
||||
"value": "SELECT DISTINCT 9 as ord, devType as id, devType as name FROM Devices WHERE devType NOT IN ('', 'Smartphone', 'Tablet', 'Laptop', 'Mini PC', 'PC', 'Printer', 'Server', 'Singleboard Computer (SBC)', 'NAS', 'Domotic', 'IP Camera', 'Game Console', 'SmartTV', 'TV Decoder', 'Virtual Assistance', 'Clock', 'House Appliance', 'Phone', 'Radio', 'AP', 'Gateway', 'Firewall', 'Hypervisor', 'Powerline', 'Switch', 'WLAN', 'PLC', 'Router', 'USB LAN Adapter', 'USB WIFI Adapter') UNION SELECT 0 as ord, '', '❌None' UNION SELECT 1 as ord, '-----', '-- 📱Handhelds --' UNION SELECT 1 as ord, 'Smartphone', 'Smartphone' UNION SELECT 1 as ord, 'Tablet', 'Tablet' UNION SELECT 2 as ord, '-----', '-- 💻Computers --' UNION SELECT 2 as ord, 'Laptop', 'Laptop' UNION SELECT 2 as ord, 'Mini PC', 'Mini PC' UNION SELECT 2 as ord, 'PC', 'PC' UNION SELECT 2 as ord, 'Printer', 'Printer' UNION SELECT 2 as ord, 'Server', 'Server' UNION SELECT 2 as ord, 'Singleboard Computer (SBC)', 'Singleboard Computer (SBC)' UNION SELECT 2 as ord, 'NAS', 'NAS' UNION SELECT 3 as ord, '-----', '-- 🏠Smart home --' UNION SELECT 3 as ord, 'Domotic', 'Domotic' UNION SELECT 3 as ord, 'IP Camera', 'IP Camera' UNION SELECT 3 as ord, 'Game Console', 'Game Console' UNION SELECT 3 as ord, 'SmartTV', 'SmartTV' UNION SELECT 3 as ord, 'TV Decoder', 'TV Decoder' UNION SELECT 3 as ord, 'Virtual Assistance', 'Virtual Assistance' UNION SELECT 4 as ord, '-----', '-- Wired --' UNION SELECT 4 as ord, 'Clock', 'Clock' UNION SELECT 4 as ord, 'House Appliance', 'House Appliance' UNION SELECT 4 as ord, 'Phone', 'Phone' UNION SELECT 4 as ord, 'Radio', 'Radio' UNION SELECT 5 as ord, '-----', '-- 📡Network nodes --' UNION SELECT 5 as ord, 'AP', 'AP' UNION SELECT 5 as ord, 'Gateway', 'Gateway' UNION SELECT 5 as ord, 'Firewall', 'Firewall' UNION SELECT 5 as ord, 'Hypervisor', 'Hypervisor' UNION SELECT 5 as ord, 'Powerline', 'Powerline' UNION SELECT 5 as ord, 'Switch', 'Switch' UNION SELECT 5 as ord, 'WLAN', 'WLAN' UNION SELECT 5 as ord, 'PLC', 'PLC' UNION SELECT 5 as ord, 'Router', 'Router' UNION SELECT 5 as ord, 'USB LAN Adapter', 'USB LAN Adapter' UNION SELECT 5 as ord, 'USB WIFI Adapter', 'USB WIFI Adapter' UNION SELECT 9 as ord, '-----', '-- ⚙Custom --' UNION SELECT 10 as ord, '-----', '-----' UNION SELECT 10 as ord, 'Other', 'Other' ORDER BY 1,2;"
|
||||
},
|
||||
{
|
||||
"name": "uilang",
|
||||
@@ -393,7 +393,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Vendor",
|
||||
"function": "devVendor",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -422,7 +422,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Favorite",
|
||||
"function": "devFavorite",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
@@ -450,7 +450,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Group",
|
||||
"function": "devGroup",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -464,7 +464,7 @@
|
||||
{
|
||||
"name": "value",
|
||||
"type": "sql",
|
||||
"value": "SELECT DISTINCT '' as id, '❌None' as name UNION SELECT dev_Group as id, dev_Group as name FROM (SELECT dev_Group FROM Devices WHERE dev_Group <> '' UNION SELECT 'Personal' UNION SELECT 'Always on' UNION SELECT 'Friends' UNION SELECT 'Others' ) AS all_devices ORDER BY id;"
|
||||
"value": "SELECT DISTINCT '' as id, '❌None' as name UNION SELECT devGroup as id, devGroup as name FROM (SELECT devGroup FROM Devices WHERE devGroup <> '' UNION SELECT 'Personal' UNION SELECT 'Always on' UNION SELECT 'Friends' UNION SELECT 'Others' ) AS all_devices ORDER BY id;"
|
||||
}
|
||||
],
|
||||
"localized": ["name", "description"],
|
||||
@@ -482,7 +482,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Comments",
|
||||
"function": "devComments",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -506,7 +506,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_FirstConnection",
|
||||
"function": "devFirstConnection",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -535,7 +535,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LastConnection",
|
||||
"function": "devLastConnection",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -564,7 +564,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LastIP",
|
||||
"function": "devLastIP",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -593,7 +593,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_StaticIP",
|
||||
"function": "devStaticIP",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
@@ -621,7 +621,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_ScanCycle",
|
||||
"function": "devScan",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
@@ -649,7 +649,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LogEvents",
|
||||
"function": "devLogEvents",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
@@ -677,7 +677,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_AlertEvents",
|
||||
"function": "devAlertEvents",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
@@ -705,7 +705,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_AlertDeviceDown",
|
||||
"function": "devAlertDown",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
@@ -733,7 +733,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_SkipRepeated",
|
||||
"function": "devSkipRepeated",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -764,7 +764,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_LastNotification",
|
||||
"function": "devLastNotification",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -793,7 +793,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_PresentLastScan",
|
||||
"function": "devPresentLastScan",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
@@ -821,7 +821,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_NewDevice",
|
||||
"function": "devIsNew",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
@@ -849,7 +849,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Location",
|
||||
"function": "devLocation",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -863,7 +863,7 @@
|
||||
{
|
||||
"name": "value",
|
||||
"type": "sql",
|
||||
"value": "SELECT DISTINCT '' AS id, '❌None' AS name UNION SELECT dev_Location AS id, dev_Location AS name FROM Devices WHERE dev_Location NOT IN ('', 'null') AND dev_Location IS NOT NULL UNION SELECT 'Bathroom' AS id, 'Bathroom' AS name UNION SELECT 'Bedroom', 'Bedroom' UNION SELECT 'Dining room', 'Dining room' UNION SELECT 'Hall', 'Hall' UNION SELECT 'Kitchen', 'Kitchen' UNION SELECT 'Laundry', 'Laundry' UNION SELECT 'Living room', 'Living room' UNION SELECT 'Study', 'Study' UNION SELECT 'Attic', 'Attic' UNION SELECT 'Basement', 'Basement' UNION SELECT 'Garage', 'Garage' UNION SELECT 'Back yard', 'Back yard' UNION SELECT 'Garden', 'Garden' UNION SELECT 'Terrace', 'Terrace' ORDER BY id;"
|
||||
"value": "SELECT DISTINCT '' AS id, '❌None' AS name UNION SELECT devLocation AS id, devLocation AS name FROM Devices WHERE devLocation NOT IN ('', 'null') AND devLocation IS NOT NULL UNION SELECT 'Bathroom' AS id, 'Bathroom' AS name UNION SELECT 'Bedroom', 'Bedroom' UNION SELECT 'Dining room', 'Dining room' UNION SELECT 'Hall', 'Hall' UNION SELECT 'Kitchen', 'Kitchen' UNION SELECT 'Laundry', 'Laundry' UNION SELECT 'Living room', 'Living room' UNION SELECT 'Study', 'Study' UNION SELECT 'Attic', 'Attic' UNION SELECT 'Basement', 'Basement' UNION SELECT 'Garage', 'Garage' UNION SELECT 'Back yard', 'Back yard' UNION SELECT 'Garden', 'Garden' UNION SELECT 'Terrace', 'Terrace' ORDER BY id;"
|
||||
}
|
||||
],
|
||||
"localized": ["name", "description"],
|
||||
@@ -881,7 +881,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Archived",
|
||||
"function": "devIsArchived",
|
||||
"type": {
|
||||
"dataType": "integer",
|
||||
"elements": [
|
||||
@@ -909,7 +909,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Network_Node_MAC_ADDR",
|
||||
"function": "devParentMAC",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -922,7 +922,7 @@
|
||||
{
|
||||
"name": "value",
|
||||
"type": "sql",
|
||||
"value": "SELECT '❌None' as name, '' as id UNION SELECT Dev_Name as name, dev_MAC as id FROM Devices WHERE EXISTS (SELECT 1 FROM Settings WHERE Code_Name = 'NETWORK_DEVICE_TYPES' AND LOWER(value) LIKE '%' || LOWER(dev_DeviceType) || '%' AND dev_DeviceType <> '')"
|
||||
"value": "SELECT '❌None' as name, '' as id UNION SELECT devName as name, devMac as id FROM Devices WHERE EXISTS (SELECT 1 FROM Settings WHERE Code_Name = 'NETWORK_DEVICE_TYPES' AND LOWER(value) LIKE '%' || LOWER(devType) || '%' AND devType <> '')"
|
||||
},
|
||||
{
|
||||
"name": "target_macs",
|
||||
@@ -945,7 +945,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Network_Node_port",
|
||||
"function": "devParentPort",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -973,7 +973,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "dev_Icon",
|
||||
"function": "devIcon",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
@@ -982,7 +982,7 @@
|
||||
"elementOptions": [
|
||||
{ "cssClasses": "input-group-addon iconPreview" },
|
||||
{ "getStringKey": "Gen_SelectToPreview" },
|
||||
{ "customId": "NEWDEV_dev_Icon_preview" }
|
||||
{ "customId": "NEWDEV_devIcon_preview" }
|
||||
],
|
||||
"transformers": []
|
||||
},
|
||||
@@ -994,7 +994,7 @@
|
||||
{
|
||||
"onChange": "updateIconPreview(this)"
|
||||
},
|
||||
{ "customParams": "NEWDEV_dev_Icon,NEWDEV_dev_Icon_preview" }
|
||||
{ "customParams": "NEWDEV_devIcon,NEWDEV_devIcon_preview" }
|
||||
],
|
||||
"transformers": []
|
||||
}
|
||||
@@ -1006,7 +1006,7 @@
|
||||
{
|
||||
"name": "value",
|
||||
"type": "sql",
|
||||
"value": "WITH RECURSIVE SettingsIcons AS (SELECT REPLACE(REPLACE(REPLACE(Value, '[', ''), ']', ''), '''', '') AS icon_list FROM Settings WHERE Code_Name = 'UI_ICONS'), SplitIcons AS (SELECT TRIM(SUBSTR(icon_list, 1, INSTR(icon_list || ',', ',') - 1)) AS icon, SUBSTR(icon_list, INSTR(icon_list || ',', ',') + 1) AS remaining_icons FROM SettingsIcons WHERE icon_list <> '' UNION ALL SELECT TRIM(SUBSTR(remaining_icons, 1, INSTR(remaining_icons || ',', ',') - 1)) AS icon, SUBSTR(remaining_icons, INSTR(remaining_icons || ',', ',') + 1) AS remaining_icons FROM SplitIcons WHERE remaining_icons <> '') SELECT DISTINCT * FROM (SELECT icon as name, icon as id FROM SplitIcons UNION SELECT '❌None' AS name, '' AS id UNION SELECT Dev_Icon AS name, Dev_Icon AS id FROM Devices WHERE Dev_Icon <> '') AS combined_results;"
|
||||
"value": "WITH RECURSIVE SettingsIcons AS (SELECT REPLACE(REPLACE(REPLACE(Value, '[', ''), ']', ''), '''', '') AS icon_list FROM Settings WHERE Code_Name = 'UI_ICONS'), SplitIcons AS (SELECT TRIM(SUBSTR(icon_list, 1, INSTR(icon_list || ',', ',') - 1)) AS icon, SUBSTR(icon_list, INSTR(icon_list || ',', ',') + 1) AS remaining_icons FROM SettingsIcons WHERE icon_list <> '' UNION ALL SELECT TRIM(SUBSTR(remaining_icons, 1, INSTR(remaining_icons || ',', ',') - 1)) AS icon, SUBSTR(remaining_icons, INSTR(remaining_icons || ',', ',') + 1) AS remaining_icons FROM SplitIcons WHERE remaining_icons <> '') SELECT DISTINCT * FROM (SELECT icon as name, icon as id FROM SplitIcons UNION SELECT '❌None' AS name, '' AS id UNION SELECT devIcon AS name, devIcon AS id FROM Devices WHERE devIcon <> '') AS combined_results;"
|
||||
}
|
||||
],
|
||||
"localized": ["name", "description"],
|
||||
@@ -1025,27 +1025,6 @@
|
||||
}
|
||||
],
|
||||
"required": [
|
||||
"dev_MAC",
|
||||
"dev_Name",
|
||||
"dev_Owner",
|
||||
"dev_FirstConnection",
|
||||
"dev_LastConnection",
|
||||
"dev_LastIP",
|
||||
"dev_StaticIP",
|
||||
"dev_ScanCycle",
|
||||
"dev_LogEvents",
|
||||
"dev_AlertEvents",
|
||||
"dev_AlertDeviceDown",
|
||||
"dev_SkipRepeated",
|
||||
"dev_LastNotification",
|
||||
"dev_PresentLastScan",
|
||||
"dev_NewDevice",
|
||||
"dev_Location",
|
||||
"dev_Archived",
|
||||
"dev_Network_Node_MAC_ADDR",
|
||||
"dev_Network_Node_port",
|
||||
"dev_Icon",
|
||||
"LESS_NAME_CLEANUP"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@
|
||||
{
|
||||
"name": "ips",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_LastIP from DEVICES order by dev_MAC",
|
||||
"value": "SELECT devLastIP from DEVICES order by devMac",
|
||||
"timeoutMultiplier": true
|
||||
},
|
||||
{
|
||||
"name": "macs",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_MAC from DEVICES order by dev_MAC"
|
||||
"value": "SELECT devMac from DEVICES order by devMac"
|
||||
},
|
||||
{
|
||||
"name": "timeout",
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "You can specify a SQL where condition to filter out New Devices from notifications. For example <code>AND dev_LastIP NOT LIKE '192.168.3.%'</code> will always exclude New Device notifications for all devices with the IP starting with <code>192.168.3.%</code>."
|
||||
"string": "You can specify a SQL where condition to filter out New Devices from notifications. For example <code>AND devLastIP NOT LIKE '192.168.3.%'</code> will always exclude New Device notifications for all devices with the IP starting with <code>192.168.3.%</code>."
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -149,7 +149,7 @@
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "You can specify a SQL where condition to filter out Events from notifications. For example <code>AND dev_LastIP NOT LIKE '192.168.3.%'</code> will always exclude New Device notifications for all devices with the IP starting with <code>192.168.3.%</code>."
|
||||
"string": "You can specify a SQL where condition to filter out Events from notifications. For example <code>AND devLastIP NOT LIKE '192.168.3.%'</code> will always exclude New Device notifications for all devices with the IP starting with <code>192.168.3.%</code>."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
{
|
||||
"name": "ips",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_LastIP from DEVICES order by dev_MAC",
|
||||
"value": "SELECT devLastIP from DEVICES order by devMac",
|
||||
"timeoutMultiplier": true
|
||||
}
|
||||
],
|
||||
|
||||
@@ -59,19 +59,19 @@ def main():
|
||||
mylog('verbose', [f'[{pluginName}] Unknown devices count: {len(unknown_devices)}'])
|
||||
|
||||
for device in unknown_devices:
|
||||
domain_name, dns_server = execute_nslookup(device['dev_LastIP'], timeout)
|
||||
domain_name, dns_server = execute_nslookup(device['devLastIP'], timeout)
|
||||
|
||||
if domain_name != '':
|
||||
plugin_objects.add_object(
|
||||
# "MAC", "IP", "Server", "Name"
|
||||
primaryId = device['dev_MAC'],
|
||||
secondaryId = device['dev_LastIP'],
|
||||
primaryId = device['devMac'],
|
||||
secondaryId = device['devLastIP'],
|
||||
watched1 = dns_server,
|
||||
watched2 = domain_name,
|
||||
watched3 = '',
|
||||
watched4 = '',
|
||||
extra = '',
|
||||
foreignKey = device['dev_MAC'])
|
||||
foreignKey = device['devMac'])
|
||||
|
||||
plugin_objects.write_result_file()
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ def main():
|
||||
# log result
|
||||
plugin_objects.write_result_file()
|
||||
|
||||
#mylog(OMDLOGLEVEL, [f'[{pluginName}] TEST name from MAC: {device_handler.getValueWithMac('dev_Name','00:e2:59:00:a0:8e')}'])
|
||||
#mylog(OMDLOGLEVEL, [f'[{pluginName}] TEST name from MAC: {device_handler.getValueWithMac('devName','00:e2:59:00:a0:8e')}'])
|
||||
#mylog(OMDLOGLEVEL, [f'[{pluginName}] TEST MAC from IP: {get_mac_from_IP('192.168.0.1')} also {ietf2ieee_mac_formater(get_mac_from_IP('192.168.0.1'))}'])
|
||||
end_time = time.time()
|
||||
mylog('verbose', [f'[{pluginName}] execution completed in {end_time - start_time:.2f} seconds'])
|
||||
@@ -423,7 +423,7 @@ def get_device_data(omada_clients_output,switches_and_aps,device_handler):
|
||||
odevice_data_reordered = [ MAC, IP, NAME, SWITCH_AP, PORT_SSID, TYPE]
|
||||
odevice_data_reordered[MAC]=odevice_data[cMAC]
|
||||
odevice_data_reordered[IP]=odevice_data[cIP]
|
||||
real_naxname = device_handler.getValueWithMac('dev_Name',ieee2ietf_mac_formater(odevice_data[cMAC]))
|
||||
real_naxname = device_handler.getValueWithMac('devName',ieee2ietf_mac_formater(odevice_data[cMAC]))
|
||||
|
||||
#
|
||||
# if the name stored in Nax for a device is empty or the MAC addres or has some parenthhesis or is the same as in omada
|
||||
|
||||
@@ -31,9 +31,10 @@ The plugin operates in three different modes based on the configuration settings
|
||||
|
||||
#### Node (Source) Settings `[n]`
|
||||
|
||||
- **API Token** `[n,h]`: `API_TOKEN` (has to be same across all nodes)
|
||||
|
||||
- **When to Run** `[n,h]`: `SYNC_RUN`
|
||||
- **Schedule** `[n,h]`: `SYNC_RUN_SCHD`
|
||||
- **API Token** `[n,h]`: `SYNC_api_token`
|
||||
- **Encryption Key** `[n,h]`: `SYNC_encryption_key`
|
||||
- **Node Name** `[n]`: `SYNC_node_name`
|
||||
- **Hub URL** `[n]`: `SYNC_hub_url`
|
||||
@@ -42,9 +43,10 @@ The plugin operates in three different modes based on the configuration settings
|
||||
|
||||
#### Hub (Target) Settings `[h]`
|
||||
|
||||
- **API Token** `[n,h]`: `API_TOKEN` (has to be same across all nodes)
|
||||
|
||||
- **When to Run** `[n,h]`: `SYNC_RUN`
|
||||
- **Schedule** `[n,h]`: `SYNC_RUN_SCHD`
|
||||
- **API Token** `[n,h]`: `SYNC_api_token`
|
||||
- **Encryption Key** `[n,h]`: `SYNC_encryption_key`
|
||||
- **Nodes to Pull From** `[h]`: `SYNC_nodes`
|
||||
|
||||
|
||||
@@ -110,46 +110,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "api_token",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementHasInputValue": 1,
|
||||
"elementOptions": [{ "cssClasses": "col-xs-12" }],
|
||||
"transformers": []
|
||||
},
|
||||
{
|
||||
"elementType": "button",
|
||||
"elementOptions": [
|
||||
{ "getStringKey": "Gen_Generate" },
|
||||
{ "customParams": "SYNC_api_token" },
|
||||
{ "onClick": "generateApiToken(this, 20)" },
|
||||
{ "cssClasses": "col-xs-12" }
|
||||
],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"maxLength": 50,
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "API token [n,h]"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "API token to secure communication, you can generate one or enter any value. It's sent in the request header. The API token needs to be the same on the hub and on the nodes."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "encryption_key",
|
||||
"type": {
|
||||
|
||||
@@ -11,7 +11,7 @@ function checkAuthorization($method) {
|
||||
// Retrieve the authorization header
|
||||
$headers = apache_request_headers();
|
||||
$auth_header = $headers['Authorization'] ?? '';
|
||||
$expected_token = 'Bearer ' . getSettingValue('SYNC_api_token');
|
||||
$expected_token = 'Bearer ' . getSettingValue('API_TOKEN');
|
||||
|
||||
// Verify the authorization token
|
||||
if ($auth_header !== $expected_token) {
|
||||
|
||||
@@ -42,7 +42,7 @@ def main():
|
||||
|
||||
# Retrieve configuration settings
|
||||
plugins_to_sync = get_setting_value('SYNC_plugins')
|
||||
api_token = get_setting_value('SYNC_api_token')
|
||||
api_token = get_setting_value('API_TOKEN')
|
||||
encryption_key = get_setting_value('SYNC_encryption_key')
|
||||
hub_url = get_setting_value('SYNC_hub_url')
|
||||
node_name = get_setting_value('SYNC_node_name')
|
||||
@@ -165,7 +165,7 @@ def main():
|
||||
conn = sqlite3.connect(fullDbPath)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Collect all unique dev_MAC values from the JSON files
|
||||
# Collect all unique devMac values from the JSON files
|
||||
unique_mac_addresses = set()
|
||||
device_data = []
|
||||
|
||||
@@ -188,9 +188,9 @@ def main():
|
||||
with open(file_path, 'r') as f:
|
||||
data = json.load(f)
|
||||
for device in data['data']:
|
||||
if device['dev_MAC'] not in unique_mac_addresses:
|
||||
device['dev_SyncHubNodeName'] = tmp_SyncHubNodeName
|
||||
unique_mac_addresses.add(device['dev_MAC'])
|
||||
if device['devMac'] not in unique_mac_addresses:
|
||||
device['devSyncHubNode'] = tmp_SyncHubNodeName
|
||||
unique_mac_addresses.add(device['devMac'])
|
||||
device_data.append(device)
|
||||
|
||||
# Rename the file to "processed_" + current name
|
||||
@@ -204,27 +204,27 @@ def main():
|
||||
os.rename(file_path, new_file_path)
|
||||
|
||||
if len(device_data) > 0:
|
||||
# Retrieve existing dev_MAC values from the Devices table
|
||||
# Retrieve existing devMac values from the Devices table
|
||||
placeholders = ', '.join('?' for _ in unique_mac_addresses)
|
||||
cursor.execute(f'SELECT dev_MAC FROM Devices WHERE dev_MAC IN ({placeholders})', tuple(unique_mac_addresses))
|
||||
cursor.execute(f'SELECT devMac FROM Devices WHERE devMac IN ({placeholders})', tuple(unique_mac_addresses))
|
||||
existing_mac_addresses = set(row[0] for row in cursor.fetchall())
|
||||
|
||||
|
||||
# insert devices into the lats_result.log to manage state
|
||||
for device in device_data:
|
||||
if device['dev_PresentLastScan'] == 1:
|
||||
if device['devPresentLastScan'] == 1:
|
||||
plugin_objects.add_object(
|
||||
primaryId = device['dev_MAC'],
|
||||
secondaryId = device['dev_LastIP'],
|
||||
watched1 = device['dev_Name'],
|
||||
watched2 = device['dev_Vendor'],
|
||||
watched3 = device['dev_SyncHubNodeName'],
|
||||
watched4 = device['dev_GUID'],
|
||||
primaryId = device['devMac'],
|
||||
secondaryId = device['devLastIP'],
|
||||
watched1 = device['devName'],
|
||||
watched2 = device['devVendor'],
|
||||
watched3 = device['devSyncHubNode'],
|
||||
watched4 = device['devGUID'],
|
||||
extra = '',
|
||||
foreignKey = device['dev_GUID'])
|
||||
foreignKey = device['devGUID'])
|
||||
|
||||
# Filter out existing devices
|
||||
new_devices = [device for device in device_data if device['dev_MAC'] not in existing_mac_addresses]
|
||||
new_devices = [device for device in device_data if device['devMac'] not in existing_mac_addresses]
|
||||
|
||||
# Remove 'rowid' key if it exists
|
||||
for device in new_devices:
|
||||
|
||||
@@ -385,7 +385,7 @@
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Columns and their order that are shown on the Devices page. Drag and drop the order of columns, click <code>x</code> to remove columns. You can also click into the field to selectivelly add fields."
|
||||
"string": "Columns and their order that are shown on the Devices page. Drag and drop the order of columns, click <code>x</code> to remove columns. You can also click into the field to selectivelly add fields. The <code>Name</code> and <code>Status</code> fields are required."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -85,14 +85,14 @@ def update_vendors (dbPath, plugin_objects):
|
||||
|
||||
# Get devices without a vendor
|
||||
sql.execute ("""SELECT
|
||||
dev_MAC,
|
||||
dev_LastIP,
|
||||
dev_Name,
|
||||
dev_Vendor
|
||||
devMac,
|
||||
devLastIP,
|
||||
devName,
|
||||
devVendor
|
||||
FROM Devices
|
||||
WHERE dev_Vendor = '(unknown)'
|
||||
OR dev_Vendor = ''
|
||||
OR dev_Vendor IS NULL
|
||||
WHERE devVendor = '(unknown)'
|
||||
OR devVendor = ''
|
||||
OR devVendor IS NULL
|
||||
""")
|
||||
devices = sql.fetchall()
|
||||
conn.commit()
|
||||
|
||||
@@ -40,17 +40,12 @@
|
||||
{
|
||||
"name": "macs",
|
||||
"type": "sql",
|
||||
"value": "SELECT dev_MAC from DEVICES"
|
||||
"value": "SELECT devMac from DEVICES"
|
||||
},
|
||||
{
|
||||
"name": "urls",
|
||||
"type": "setting",
|
||||
"value": "WEBMON_urls_to_check"
|
||||
},
|
||||
{
|
||||
"name": "internet_ip",
|
||||
"type": "setting",
|
||||
"value": "WEBMON_SQL_internet_ip"
|
||||
}
|
||||
],
|
||||
"database_column_definitions": [
|
||||
@@ -677,42 +672,6 @@
|
||||
"string": "Servicios para ver. Ingrese la URL completa, por ejemplo, <code>https://google.com</code>. Los valores de esta configuración se usarán para reemplazar el comodín <code>{urls}</code> en la configuración < code>WEBMON_CMD</code>."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "SQL_internet_ip",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [{ "readonly": "true" }],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": "SELECT dev_LastIP FROM Devices WHERE dev_MAC = 'Internet'",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Helper variable"
|
||||
},
|
||||
{
|
||||
"language_code": "es_es",
|
||||
"string": "Variable de ayuda"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Unused setting - for demonstration only. Getting the IP address of the Router / Internet."
|
||||
},
|
||||
{
|
||||
"language_code": "es_es",
|
||||
"string": "Configuración no utilizada: solo para demostración. Obtener la dirección IP del enrutador / Internet."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user