mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-30 23:03:03 -07:00
BE: CurrentScan table leanup - column rename
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
34
back/app.sql
34
back/app.sql
@@ -150,21 +150,21 @@ CREATE TABLE Plugins_Language_Strings(
|
||||
PRIMARY KEY("Index" AUTOINCREMENT)
|
||||
);
|
||||
CREATE TABLE CurrentScan (
|
||||
cur_MAC STRING(50) NOT NULL COLLATE NOCASE,
|
||||
cur_IP STRING(50) NOT NULL COLLATE NOCASE,
|
||||
cur_Vendor STRING(250),
|
||||
cur_ScanMethod STRING(10),
|
||||
cur_Name STRING(250),
|
||||
cur_LastQuery STRING(250),
|
||||
cur_DateTime STRING(250),
|
||||
cur_SyncHubNodeName STRING(50),
|
||||
cur_NetworkSite STRING(250),
|
||||
cur_SSID STRING(250),
|
||||
cur_devVlan STRING(250),
|
||||
cur_NetworkNodeMAC STRING(250),
|
||||
cur_PORT STRING(250),
|
||||
cur_Type STRING(250),
|
||||
UNIQUE(cur_MAC)
|
||||
scanMac STRING(50) NOT NULL COLLATE NOCASE,
|
||||
scanLastIP STRING(50) NOT NULL COLLATE NOCASE,
|
||||
scanVendor STRING(250),
|
||||
scanSourcePlugin STRING(10),
|
||||
scanName STRING(250),
|
||||
scanLastQuery STRING(250),
|
||||
scanLastConnection STRING(250),
|
||||
scanSyncHubNode STRING(50),
|
||||
scanSite STRING(250),
|
||||
scanSSID STRING(250),
|
||||
scanVlan STRING(250),
|
||||
scanParentMAC STRING(250),
|
||||
scanParentPort STRING(250),
|
||||
scanType STRING(250),
|
||||
UNIQUE(scanMac)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "AppEvents" (
|
||||
"Index" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -237,9 +237,9 @@ CREATE VIEW LatestEventsPerMAC AS
|
||||
c.*
|
||||
FROM RankedEvents AS e
|
||||
LEFT JOIN Devices AS d ON e.eve_MAC = d.devMac
|
||||
INNER JOIN CurrentScan AS c ON e.eve_MAC = c.cur_MAC
|
||||
INNER JOIN CurrentScan AS c ON e.eve_MAC = c.scanMac
|
||||
WHERE e.row_num = 1
|
||||
/* LatestEventsPerMAC(eve_MAC,eve_IP,eve_DateTime,eve_EventType,eve_AdditionalInfo,eve_PendingAlertEmail,eve_PairEventRowid,row_num,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps,cur_MAC,cur_IP,cur_Vendor,cur_ScanMethod,cur_Name,cur_LastQuery,cur_DateTime,cur_SyncHubNodeName,cur_NetworkSite,cur_SSID,cur_NetworkNodeMAC,cur_PORT,cur_Type) */;
|
||||
/* LatestEventsPerMAC(eve_MAC,eve_IP,eve_DateTime,eve_EventType,eve_AdditionalInfo,eve_PendingAlertEmail,eve_PairEventRowid,row_num,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps,scanMac,scanLastIP,scanVendor,scanSourcePlugin,scanName,scanLastQuery,scanLastConnection,scanSyncHubNode,scanSite,scanSSID,scanParentMAC,scanParentPort,scanType) */;
|
||||
CREATE VIEW Sessions_Devices AS SELECT * FROM Sessions LEFT JOIN "Devices" ON ses_MAC = devMac
|
||||
/* Sessions_Devices(ses_MAC,ses_IP,ses_EventTypeConnection,ses_DateTimeConnection,ses_EventTypeDisconnection,ses_DateTimeDisconnection,ses_StillConnected,ses_AdditionalInfo,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps) */;
|
||||
CREATE VIEW Convert_Events_to_Sessions AS SELECT EVE1.eve_MAC,
|
||||
|
||||
@@ -54,7 +54,7 @@ Input data from the plugin might cause mapping issues in specific edge cases. Lo
|
||||
17:31:05 [Plugin utils] In pluginObjects there are 2 events with the status "missing-in-last-scan"
|
||||
17:31:05 [Plugin utils] In pluginObjects there are 2 events with the status "watched-not-changed"
|
||||
17:31:05 [Plugins] Mapping objects to database table: CurrentScan
|
||||
17:31:05 [Plugins] SQL query for mapping: INSERT into CurrentScan ( "cur_MAC", "cur_IP", "cur_LastQuery", "cur_Name", "cur_Vendor", "cur_ScanMethod") VALUES ( ?, ?, ?, ?, ?, ?)
|
||||
17:31:05 [Plugins] SQL query for mapping: INSERT into CurrentScan ( "scanMac", "scanLastIP", "scanLastQuery", "scanName", "scanVendor", "scanSourcePlugin") VALUES ( ?, ?, ?, ?, ?, ?)
|
||||
17:31:05 [Plugins] SQL sqlParams for mapping: [('01:01:01:01:01:01', '172.30.0.1', 0, 'aaaa', 'vvvvvvvvv', 'PIHOLE'), ('02:42:ac:1e:00:02', '172.30.0.2', 0, 'dddd', 'vvvvv2222', 'PIHOLE')]
|
||||
🔺
|
||||
17:31:05 [API] Update API starting
|
||||
|
||||
@@ -268,7 +268,7 @@ To import plugin data into NetAlertX tables for device discovery or notification
|
||||
"database_column_definitions": [
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"show": true,
|
||||
"type": "device_mac",
|
||||
"localized": ["name"],
|
||||
@@ -287,7 +287,7 @@ To always map a static value (not read from plugin output):
|
||||
```json
|
||||
{
|
||||
"column": "NameDoesntMatter",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "MYPLN"
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ To import plugin data into the device scan pipeline (for notifications, heuristi
|
||||
"database_column_definitions": [
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"show": true,
|
||||
"type": "device_mac",
|
||||
"localized": ["name"],
|
||||
@@ -448,7 +448,7 @@ To import plugin data into the device scan pipeline (for notifications, heuristi
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
"localized": ["name"],
|
||||
@@ -456,7 +456,7 @@ To import plugin data into the device scan pipeline (for notifications, heuristi
|
||||
},
|
||||
{
|
||||
"column": "NameDoesntMatter",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "MYSCAN"
|
||||
},
|
||||
@@ -478,7 +478,7 @@ Use `mapped_to_column_data` to map a static value instead of reading from a colu
|
||||
```json
|
||||
{
|
||||
"column": "NameDoesntMatter",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "MYSCAN"
|
||||
},
|
||||
@@ -489,7 +489,7 @@ Use `mapped_to_column_data` to map a static value instead of reading from a colu
|
||||
}
|
||||
```
|
||||
|
||||
This always sets `cur_ScanMethod` to `"MYSCAN"` regardless of column data.
|
||||
This always sets `scanSourcePlugin` to `"MYSCAN"` regardless of column data.
|
||||
|
||||
---
|
||||
|
||||
@@ -546,7 +546,7 @@ When viewing a device detail page, the `txtMacFilter` field is populated with th
|
||||
"database_column_definitions": [
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_mac",
|
||||
@@ -556,7 +556,7 @@ When viewing a device detail page, the `txtMacFilter` field is populated with th
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
|
||||
@@ -105,7 +105,7 @@ a[target="_blank"] {
|
||||
background-color: black !important;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: .85em;
|
||||
cursor: pointer;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
.logs-row textarea
|
||||
{
|
||||
|
||||
@@ -419,7 +419,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -435,7 +435,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -451,7 +451,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -467,7 +467,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -483,7 +483,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"mapped_to_column": "scanType",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -514,7 +514,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "Example Plugin"
|
||||
},
|
||||
|
||||
@@ -51,8 +51,8 @@ def main():
|
||||
# "database_column_definitions": [
|
||||
# {
|
||||
# "column": "Object_PrimaryID", <--------- the value I save into primaryId
|
||||
# "mapped_to_column": "cur_MAC", <--------- gets inserted into the CurrentScan DB
|
||||
# table column cur_MAC
|
||||
# "mapped_to_column": "scanMac", <--------- gets inserted into the CurrentScan DB
|
||||
# table column scanMac
|
||||
#
|
||||
for device in device_data:
|
||||
plugin_objects.add_object(
|
||||
|
||||
@@ -392,7 +392,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -408,7 +408,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -424,7 +424,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -440,7 +440,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"mapped_to_column": "scanType",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -486,7 +486,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "Example Plugin"
|
||||
},
|
||||
|
||||
@@ -500,7 +500,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -516,7 +516,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -532,7 +532,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -556,7 +556,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "ARPSCAN"
|
||||
},
|
||||
|
||||
@@ -451,7 +451,7 @@
|
||||
"localized": [
|
||||
"name"
|
||||
],
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
@@ -477,7 +477,7 @@
|
||||
"localized": [
|
||||
"name"
|
||||
],
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
@@ -503,7 +503,7 @@
|
||||
"localized": [
|
||||
"name"
|
||||
],
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
@@ -524,7 +524,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": [
|
||||
@@ -550,7 +550,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "ASUSWRT"
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_mac",
|
||||
@@ -127,7 +127,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -174,7 +174,7 @@
|
||||
},
|
||||
{
|
||||
"column": "DateTimeChanged",
|
||||
"mapped_to_column": "cur_DateTime",
|
||||
"mapped_to_column": "scanLastConnection",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -221,7 +221,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -337,7 +337,7 @@
|
||||
},
|
||||
{
|
||||
"column": "ScanMethod",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "DHCPLSS"
|
||||
},
|
||||
|
||||
@@ -391,7 +391,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -409,7 +409,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -427,7 +427,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -445,7 +445,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -463,7 +463,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"mapped_to_column": "scanType",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -498,7 +498,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "Freebox"
|
||||
},
|
||||
|
||||
@@ -382,7 +382,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -400,7 +400,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -418,7 +418,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -487,7 +487,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "ICMP"
|
||||
},
|
||||
|
||||
@@ -494,7 +494,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -518,7 +518,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -591,7 +591,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value4",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"mapped_to_column": "scanType",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": false,
|
||||
"type": "label",
|
||||
@@ -607,7 +607,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "INTRNT"
|
||||
},
|
||||
@@ -657,7 +657,7 @@
|
||||
},
|
||||
{
|
||||
"column": "DateTimeChanged",
|
||||
"mapped_to_column": "cur_DateTime",
|
||||
"mapped_to_column": "scanLastConnection",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
|
||||
@@ -287,7 +287,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -305,7 +305,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -323,7 +323,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -341,7 +341,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -359,7 +359,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"mapped_to_column": "scanType",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -394,7 +394,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "IPNEIGH"
|
||||
},
|
||||
|
||||
@@ -470,7 +470,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -490,7 +490,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -549,7 +549,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "LUCIRPC"
|
||||
},
|
||||
|
||||
@@ -351,7 +351,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -382,7 +382,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -413,7 +413,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -474,7 +474,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "MTSCAN"
|
||||
},
|
||||
|
||||
@@ -538,7 +538,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -556,7 +556,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -574,7 +574,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -592,7 +592,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -618,7 +618,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_LastQuery",
|
||||
"mapped_to_column": "scanLastQuery",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -640,7 +640,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "NMAPDEV"
|
||||
},
|
||||
|
||||
@@ -554,7 +554,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -578,7 +578,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -602,7 +602,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -618,7 +618,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_NetworkNodeMAC",
|
||||
"mapped_to_column": "scanParentMAC",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -634,7 +634,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_PORT",
|
||||
"mapped_to_column": "scanParentPort",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -650,7 +650,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value4",
|
||||
"mapped_to_column": "cur_SSID",
|
||||
"mapped_to_column": "scanSSID",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -666,7 +666,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Extra",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"mapped_to_column": "scanType",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": false,
|
||||
"type": "label",
|
||||
@@ -682,7 +682,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "OMDSDN"
|
||||
},
|
||||
|
||||
@@ -320,7 +320,7 @@ def main():
|
||||
# "database_column_definitions": [
|
||||
# {
|
||||
# "column": "Object_PrimaryID", <--------- the value I save into primaryId
|
||||
# "mapped_to_column": "cur_MAC", <--------- gets unserted into the CurrentScan DB table column cur_MAC
|
||||
# "mapped_to_column": "scanMac", <--------- gets unserted into the CurrentScan DB table column scanMac
|
||||
# watched1 = 'null' ,
|
||||
# figure a way to run my udpate script delayed
|
||||
|
||||
@@ -342,7 +342,7 @@ def main():
|
||||
watched3=myport, # PORT
|
||||
watched4=myssid, # SSID
|
||||
extra=device[TYPE],
|
||||
# omada_site, # SITENAME (cur_NetworkSite) or VENDOR (cur_Vendor) (PICK one and adjust config.json -> "column": "Extra")
|
||||
# omada_site, # SITENAME (scanSite) or VENDOR (scanVendor) (PICK one and adjust config.json -> "column": "Extra")
|
||||
foreignKey=device[MAC].lower().replace("-", ":"),
|
||||
) # usually MAC
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -544,7 +544,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -560,7 +560,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -576,7 +576,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_NetworkNodeMAC",
|
||||
"mapped_to_column": "scanParentMAC",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -592,7 +592,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_PORT",
|
||||
"mapped_to_column": "scanParentPort",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -608,7 +608,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value4",
|
||||
"mapped_to_column": "cur_SSID",
|
||||
"mapped_to_column": "scanSSID",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -624,7 +624,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Extra",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"mapped_to_column": "scanType",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": false,
|
||||
"type": "label",
|
||||
@@ -640,7 +640,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "OMDSDNOPENAPI"
|
||||
},
|
||||
@@ -704,7 +704,7 @@
|
||||
},
|
||||
{
|
||||
"column": "HelpVal2",
|
||||
"mapped_to_column": "cur_NetworkSite",
|
||||
"mapped_to_column": "scanSite",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
|
||||
@@ -428,7 +428,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -444,7 +444,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -460,7 +460,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -476,7 +476,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -522,7 +522,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "PIHOLEAPI"
|
||||
},
|
||||
|
||||
@@ -385,7 +385,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_mac",
|
||||
@@ -420,7 +420,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -440,7 +440,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_LastQuery",
|
||||
"mapped_to_column": "scanLastQuery",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -456,7 +456,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -472,7 +472,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value4",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -488,7 +488,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "PIHOLE"
|
||||
},
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_mac",
|
||||
@@ -120,7 +120,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -140,7 +140,7 @@
|
||||
},
|
||||
{
|
||||
"column": "DateTimeCreated",
|
||||
"mapped_to_column": "cur_DateTime",
|
||||
"mapped_to_column": "scanLastConnection",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -160,7 +160,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -275,7 +275,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "SNMPDSC"
|
||||
},
|
||||
|
||||
@@ -684,7 +684,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -710,7 +710,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -736,7 +736,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -754,7 +754,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -772,7 +772,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_SyncHubNodeName",
|
||||
"mapped_to_column": "scanSyncHubNode",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -807,7 +807,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "sync"
|
||||
},
|
||||
|
||||
@@ -587,7 +587,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-3",
|
||||
"show": true,
|
||||
"type": "device_name_mac",
|
||||
@@ -605,7 +605,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -623,7 +623,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -641,7 +641,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"mapped_to_column": "scanType",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -676,7 +676,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value4",
|
||||
"mapped_to_column": "cur_NetworkNodeMAC",
|
||||
"mapped_to_column": "scanParentMAC",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_mac",
|
||||
@@ -694,7 +694,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "UNIFIAPI"
|
||||
},
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": ["name"],
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
@@ -147,7 +147,7 @@
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": ["name"],
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
@@ -194,7 +194,7 @@
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": ["name"],
|
||||
"mapped_to_column": "cur_DateTime",
|
||||
"mapped_to_column": "scanLastConnection",
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
@@ -218,7 +218,7 @@
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": ["name"],
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
@@ -239,7 +239,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": ["name"],
|
||||
@@ -263,7 +263,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"mapped_to_column": "scanType",
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": ["name"],
|
||||
@@ -336,7 +336,7 @@
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": ["name"],
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "UNFIMP"
|
||||
},
|
||||
@@ -383,7 +383,7 @@
|
||||
},
|
||||
{
|
||||
"column": "HelpVal1",
|
||||
"mapped_to_column": "cur_NetworkNodeMAC",
|
||||
"mapped_to_column": "scanParentMAC",
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": ["name"],
|
||||
@@ -399,7 +399,7 @@
|
||||
},
|
||||
{
|
||||
"column": "HelpVal2",
|
||||
"mapped_to_column": "cur_PORT",
|
||||
"mapped_to_column": "scanParentPort",
|
||||
"css_classes": "col-sm-2",
|
||||
"default_value": "",
|
||||
"localized": ["name"],
|
||||
|
||||
@@ -428,7 +428,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_PrimaryID",
|
||||
"mapped_to_column": "cur_MAC",
|
||||
"mapped_to_column": "scanMac",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_mac",
|
||||
@@ -452,7 +452,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Object_SecondaryID",
|
||||
"mapped_to_column": "cur_IP",
|
||||
"mapped_to_column": "scanLastIP",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "device_ip",
|
||||
@@ -499,7 +499,7 @@
|
||||
},
|
||||
{
|
||||
"column": "DateTimeChanged",
|
||||
"mapped_to_column": "cur_DateTime",
|
||||
"mapped_to_column": "scanLastConnection",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -523,7 +523,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column": "scanSourcePlugin",
|
||||
"mapped_to_column_data": {
|
||||
"value": "VNDRPDT"
|
||||
},
|
||||
@@ -550,7 +550,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value1",
|
||||
"mapped_to_column": "cur_Vendor",
|
||||
"mapped_to_column": "scanVendor",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -570,7 +570,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value2",
|
||||
"mapped_to_column": "cur_Name",
|
||||
"mapped_to_column": "scanName",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
|
||||
@@ -196,20 +196,20 @@ CREATE TABLE Plugins_Language_Strings(
|
||||
PRIMARY KEY("Index" AUTOINCREMENT)
|
||||
);
|
||||
CREATE TABLE CurrentScan (
|
||||
cur_MAC STRING(50) NOT NULL COLLATE NOCASE,
|
||||
cur_IP STRING(50) NOT NULL COLLATE NOCASE,
|
||||
cur_Vendor STRING(250),
|
||||
cur_ScanMethod STRING(10),
|
||||
cur_Name STRING(250),
|
||||
cur_LastQuery STRING(250),
|
||||
cur_DateTime STRING(250),
|
||||
cur_SyncHubNodeName STRING(50),
|
||||
cur_NetworkSite STRING(250),
|
||||
cur_SSID STRING(250),
|
||||
cur_NetworkNodeMAC STRING(250),
|
||||
cur_PORT STRING(250),
|
||||
cur_Type STRING(250),
|
||||
UNIQUE(cur_MAC)
|
||||
scanMac STRING(50) NOT NULL COLLATE NOCASE,
|
||||
scanLastIP STRING(50) NOT NULL COLLATE NOCASE,
|
||||
scanVendor STRING(250),
|
||||
scanSourcePlugin STRING(10),
|
||||
scanName STRING(250),
|
||||
scanLastQuery STRING(250),
|
||||
scanLastConnection STRING(250),
|
||||
scanSyncHubNode STRING(50),
|
||||
scanSite STRING(250),
|
||||
scanSSID STRING(250),
|
||||
scanParentMAC STRING(250),
|
||||
scanParentPort STRING(250),
|
||||
scanType STRING(250),
|
||||
UNIQUE(scanMac)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "AppEvents" (
|
||||
"Index" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -282,9 +282,9 @@ CREATE VIEW LatestEventsPerMAC AS
|
||||
c.*
|
||||
FROM RankedEvents AS e
|
||||
LEFT JOIN Devices AS d ON e.eve_MAC = d.devMac
|
||||
INNER JOIN CurrentScan AS c ON e.eve_MAC = c.cur_MAC
|
||||
INNER JOIN CurrentScan AS c ON e.eve_MAC = c.scanMac
|
||||
WHERE e.row_num = 1
|
||||
/* LatestEventsPerMAC(eve_MAC,eve_IP,eve_DateTime,eve_EventType,eve_AdditionalInfo,eve_PendingAlertEmail,eve_PairEventRowid,row_num,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps,cur_MAC,cur_IP,cur_Vendor,cur_ScanMethod,cur_Name,cur_LastQuery,cur_DateTime,cur_SyncHubNodeName,cur_NetworkSite,cur_SSID,cur_NetworkNodeMAC,cur_PORT,cur_Type) */;
|
||||
/* LatestEventsPerMAC(eve_MAC,eve_IP,eve_DateTime,eve_EventType,eve_AdditionalInfo,eve_PendingAlertEmail,eve_PairEventRowid,row_num,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps,scanMac,scanLastIP,scanVendor,scanSourcePlugin,scanName,scanLastQuery,scanLastConnection,scanSyncHubNode,scanSite,scanSSID,scanParentMAC,scanParentPort,scanType) */;
|
||||
CREATE VIEW Sessions_Devices AS SELECT * FROM Sessions LEFT JOIN "Devices" ON ses_MAC = devMac
|
||||
/* Sessions_Devices(ses_MAC,ses_IP,ses_EventTypeConnection,ses_DateTimeConnection,ses_EventTypeDisconnection,ses_DateTimeDisconnection,ses_StillConnected,ses_AdditionalInfo,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps) */;
|
||||
CREATE VIEW Convert_Events_to_Sessions AS SELECT EVE1.eve_MAC,
|
||||
|
||||
@@ -36,7 +36,7 @@ def check_and_clean_device():
|
||||
tables_checks = [
|
||||
f"SELECT 'Events' as source, * FROM Events WHERE eve_MAC='{mac}'",
|
||||
f"SELECT 'Devices' as source, * FROM Devices WHERE dev_MAC='{mac}'",
|
||||
f"SELECT 'CurrentScan' as source, * FROM CurrentScan WHERE cur_MAC='{mac}'",
|
||||
f"SELECT 'CurrentScan' as source, * FROM CurrentScan WHERE scanMac='{mac}'",
|
||||
f"SELECT 'Notifications' as source, * FROM Notifications WHERE JSON LIKE '%{mac}%'",
|
||||
f"SELECT 'AppEvents' as source, * FROM AppEvents WHERE ObjectPrimaryID LIKE '%{mac}%' OR ObjectSecondaryID LIKE '%{mac}%'",
|
||||
f"SELECT 'Plugins_Objects' as source, * FROM Plugins_Objects WHERE Object_PrimaryID LIKE '%{mac}%'"
|
||||
@@ -56,7 +56,7 @@ def check_and_clean_device():
|
||||
deletes = [
|
||||
f"DELETE FROM Events WHERE eve_MAC='{mac}'",
|
||||
f"DELETE FROM Devices WHERE dev_MAC='{mac}'",
|
||||
f"DELETE FROM CurrentScan WHERE cur_MAC='{mac}'",
|
||||
f"DELETE FROM CurrentScan WHERE scanMac='{mac}'",
|
||||
f"DELETE FROM Notifications WHERE JSON LIKE '%{mac}%'",
|
||||
f"DELETE FROM AppEvents WHERE ObjectPrimaryID LIKE '%{mac}%' OR ObjectSecondaryID LIKE '%{mac}%'",
|
||||
f"DELETE FROM Plugins_Objects WHERE Object_PrimaryID LIKE '%{mac}%'"
|
||||
@@ -75,7 +75,7 @@ def check_and_clean_device():
|
||||
tables_checks = [
|
||||
f"SELECT 'Events' as source, * FROM Events WHERE eve_IP='{ip}'",
|
||||
f"SELECT 'Devices' as source, * FROM Devices WHERE dev_LastIP='{ip}'",
|
||||
f"SELECT 'CurrentScan' as source, * FROM CurrentScan WHERE cur_IP='{ip}'",
|
||||
f"SELECT 'CurrentScan' as source, * FROM CurrentScan WHERE scanLastIP='{ip}'",
|
||||
f"SELECT 'Notifications' as source, * FROM Notifications WHERE JSON LIKE '%{ip}%'",
|
||||
f"SELECT 'AppEvents' as source, * FROM AppEvents WHERE ObjectSecondaryID LIKE '%{ip}%'",
|
||||
f"SELECT 'Plugins_Objects' as source, * FROM Plugins_Objects WHERE Object_SecondaryID LIKE '%{ip}%'"
|
||||
@@ -95,7 +95,7 @@ def check_and_clean_device():
|
||||
deletes = [
|
||||
f"DELETE FROM Events WHERE eve_IP='{ip}'",
|
||||
f"DELETE FROM Devices WHERE dev_LastIP='{ip}'",
|
||||
f"DELETE FROM CurrentScan WHERE cur_IP='{ip}'",
|
||||
f"DELETE FROM CurrentScan WHERE scanLastIP='{ip}'",
|
||||
f"DELETE FROM Notifications WHERE JSON LIKE '%{ip}%'",
|
||||
f"DELETE FROM AppEvents WHERE ObjectSecondaryID LIKE '%{ip}%'",
|
||||
f"DELETE FROM Plugins_Objects WHERE Object_SecondaryID LIKE '%{ip}%'"
|
||||
|
||||
@@ -70,7 +70,7 @@ CREATE TABLE IF NOT EXISTS "Parameters" (
|
||||
);
|
||||
CREATE TABLE Plugins_Objects(
|
||||
"Index" INTEGER,
|
||||
Plugin TEXT NOT NULL,
|
||||
Plugin TEXT NOT NULL,
|
||||
Object_PrimaryID TEXT NOT NULL,
|
||||
Object_SecondaryID TEXT NOT NULL,
|
||||
DateTimeCreated TEXT NOT NULL,
|
||||
@@ -143,21 +143,21 @@ CREATE TABLE Plugins_Language_Strings(
|
||||
Extra TEXT NOT NULL,
|
||||
PRIMARY KEY("Index" AUTOINCREMENT)
|
||||
);
|
||||
CREATE TABLE CurrentScan (
|
||||
cur_MAC STRING(50) NOT NULL COLLATE NOCASE,
|
||||
cur_IP STRING(50) NOT NULL COLLATE NOCASE,
|
||||
cur_Vendor STRING(250),
|
||||
cur_ScanMethod STRING(10),
|
||||
cur_Name STRING(250),
|
||||
cur_LastQuery STRING(250),
|
||||
cur_DateTime STRING(250),
|
||||
cur_SyncHubNodeName STRING(50),
|
||||
cur_NetworkSite STRING(250),
|
||||
cur_SSID STRING(250),
|
||||
cur_NetworkNodeMAC STRING(250),
|
||||
cur_PORT STRING(250),
|
||||
cur_Type STRING(250),
|
||||
UNIQUE(cur_MAC)
|
||||
CREATE TABLE CurrentScan (
|
||||
scanMac STRING(50) NOT NULL COLLATE NOCASE,
|
||||
scanLastIP STRING(50) NOT NULL COLLATE NOCASE,
|
||||
scanVendor STRING(250),
|
||||
scanSourcePlugin STRING(10),
|
||||
scanName STRING(250),
|
||||
scanLastQuery STRING(250),
|
||||
scanLastConnection STRING(250),
|
||||
scanSyncHubNode STRING(50),
|
||||
scanSite STRING(250),
|
||||
scanSSID STRING(250),
|
||||
scanParentMAC STRING(250),
|
||||
scanParentPort STRING(250),
|
||||
scanType STRING(250),
|
||||
UNIQUE(scanMac)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "AppEvents" (
|
||||
"Index" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -170,11 +170,11 @@ CREATE TABLE IF NOT EXISTS "AppEvents" (
|
||||
"ObjectPrimaryID" TEXT,
|
||||
"ObjectSecondaryID" TEXT,
|
||||
"ObjectForeignKey" TEXT,
|
||||
"ObjectIndex" TEXT,
|
||||
"ObjectIsNew" BOOLEAN,
|
||||
"ObjectIsArchived" BOOLEAN,
|
||||
"ObjectIndex" TEXT,
|
||||
"ObjectIsNew" BOOLEAN,
|
||||
"ObjectIsArchived" BOOLEAN,
|
||||
"ObjectStatusColumn" TEXT,
|
||||
"ObjectStatus" TEXT,
|
||||
"ObjectStatus" TEXT,
|
||||
"AppEventType" TEXT,
|
||||
"Helper1" TEXT,
|
||||
"Helper2" TEXT,
|
||||
@@ -212,27 +212,27 @@ CREATE INDEX IDX_dev_Favorite ON Devices (devFavorite);
|
||||
CREATE INDEX IDX_dev_LastIP ON Devices (devLastIP);
|
||||
CREATE INDEX IDX_dev_NewDevice ON Devices (devIsNew);
|
||||
CREATE INDEX IDX_dev_Archived ON Devices (devIsArchived);
|
||||
CREATE VIEW Events_Devices AS
|
||||
SELECT *
|
||||
FROM Events
|
||||
CREATE VIEW Events_Devices AS
|
||||
SELECT *
|
||||
FROM Events
|
||||
LEFT JOIN Devices ON eve_MAC = devMac
|
||||
/* Events_Devices(eve_MAC,eve_IP,eve_DateTime,eve_EventType,eve_AdditionalInfo,eve_PendingAlertEmail,eve_PairEventRowid,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps) */;
|
||||
CREATE VIEW LatestEventsPerMAC AS
|
||||
WITH RankedEvents AS (
|
||||
SELECT
|
||||
SELECT
|
||||
e.*,
|
||||
ROW_NUMBER() OVER (PARTITION BY e.eve_MAC ORDER BY e.eve_DateTime DESC) AS row_num
|
||||
FROM Events AS e
|
||||
)
|
||||
SELECT
|
||||
e.*,
|
||||
d.*,
|
||||
SELECT
|
||||
e.*,
|
||||
d.*,
|
||||
c.*
|
||||
FROM RankedEvents AS e
|
||||
LEFT JOIN Devices AS d ON e.eve_MAC = d.devMac
|
||||
INNER JOIN CurrentScan AS c ON e.eve_MAC = c.cur_MAC
|
||||
INNER JOIN CurrentScan AS c ON e.eve_MAC = c.scanMac
|
||||
WHERE e.row_num = 1
|
||||
/* LatestEventsPerMAC(eve_MAC,eve_IP,eve_DateTime,eve_EventType,eve_AdditionalInfo,eve_PendingAlertEmail,eve_PairEventRowid,row_num,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps,cur_MAC,cur_IP,cur_Vendor,cur_ScanMethod,cur_Name,cur_LastQuery,cur_DateTime,cur_SyncHubNodeName,cur_NetworkSite,cur_SSID,cur_NetworkNodeMAC,cur_PORT,cur_Type) */;
|
||||
/* LatestEventsPerMAC(eve_MAC,eve_IP,eve_DateTime,eve_EventType,eve_AdditionalInfo,eve_PendingAlertEmail,eve_PairEventRowid,row_num,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps,scanMac,scanLastIP,scanVendor,scanSourcePlugin,scanName,scanLastQuery,scanLastConnection,scanSyncHubNode,scanSite,scanSSID,scanParentMAC,scanParentPort,scanType) */;
|
||||
CREATE VIEW Sessions_Devices AS SELECT * FROM Sessions LEFT JOIN "Devices" ON ses_MAC = devMac
|
||||
/* Sessions_Devices(ses_MAC,ses_IP,ses_EventTypeConnection,ses_DateTimeConnection,ses_EventTypeDisconnection,ses_DateTimeDisconnection,ses_StillConnected,ses_AdditionalInfo,devMac,devName,devOwner,devType,devVendor,devFavorite,devGroup,devComments,devFirstConnection,devLastConnection,devLastIP,devStaticIP,devScan,devLogEvents,devAlertEvents,devAlertDown,devSkipRepeated,devLastNotification,devPresentLastScan,devIsNew,devLocation,devIsArchived,devParentMAC,devParentPort,devIcon,devGUID,devSite,devSSID,devSyncHubNode,devSourcePlugin,devCustomProps) */;
|
||||
CREATE VIEW Convert_Events_to_Sessions AS SELECT EVE1.eve_MAC,
|
||||
@@ -265,11 +265,11 @@ CREATE VIEW Convert_Events_to_Sessions AS SELECT EVE1.eve_MAC,
|
||||
CREATE TRIGGER "trg_insert_devices"
|
||||
AFTER INSERT ON "Devices"
|
||||
WHEN NOT EXISTS (
|
||||
SELECT 1 FROM AppEvents
|
||||
WHERE AppEventProcessed = 0
|
||||
SELECT 1 FROM AppEvents
|
||||
WHERE AppEventProcessed = 0
|
||||
AND ObjectType = 'Devices'
|
||||
AND ObjectGUID = NEW.devGUID
|
||||
AND ObjectStatus = CASE WHEN NEW.devPresentLastScan = 1 THEN 'online' ELSE 'offline' END
|
||||
AND ObjectStatus = CASE WHEN NEW.devPresentLastScan = 1 THEN 'online' ELSE 'offline' END
|
||||
AND AppEventType = 'insert'
|
||||
)
|
||||
BEGIN
|
||||
@@ -290,18 +290,18 @@ CREATE TRIGGER "trg_insert_devices"
|
||||
"AppEventType"
|
||||
)
|
||||
VALUES (
|
||||
|
||||
|
||||
lower(
|
||||
hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||
|
||||
substr(hex( randomblob(2)), 2) || '-' ||
|
||||
hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||
|
||||
substr(hex( randomblob(2)), 2) || '-' ||
|
||||
substr('AB89', 1 + (abs(random()) % 4) , 1) ||
|
||||
substr(hex(randomblob(2)), 2) || '-' ||
|
||||
substr(hex(randomblob(2)), 2) || '-' ||
|
||||
hex(randomblob(6))
|
||||
)
|
||||
,
|
||||
DATETIME('now'),
|
||||
FALSE,
|
||||
'Devices',
|
||||
,
|
||||
DATETIME('now'),
|
||||
FALSE,
|
||||
'Devices',
|
||||
NEW.devGUID, -- ObjectGUID
|
||||
NEW.devMac, -- ObjectPrimaryID
|
||||
NEW.devLastIP, -- ObjectSecondaryID
|
||||
@@ -317,11 +317,11 @@ CREATE TRIGGER "trg_insert_devices"
|
||||
CREATE TRIGGER "trg_update_devices"
|
||||
AFTER UPDATE ON "Devices"
|
||||
WHEN NOT EXISTS (
|
||||
SELECT 1 FROM AppEvents
|
||||
WHERE AppEventProcessed = 0
|
||||
SELECT 1 FROM AppEvents
|
||||
WHERE AppEventProcessed = 0
|
||||
AND ObjectType = 'Devices'
|
||||
AND ObjectGUID = NEW.devGUID
|
||||
AND ObjectStatus = CASE WHEN NEW.devPresentLastScan = 1 THEN 'online' ELSE 'offline' END
|
||||
AND ObjectStatus = CASE WHEN NEW.devPresentLastScan = 1 THEN 'online' ELSE 'offline' END
|
||||
AND AppEventType = 'update'
|
||||
)
|
||||
BEGIN
|
||||
@@ -342,18 +342,18 @@ CREATE TRIGGER "trg_update_devices"
|
||||
"AppEventType"
|
||||
)
|
||||
VALUES (
|
||||
|
||||
|
||||
lower(
|
||||
hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||
|
||||
substr(hex( randomblob(2)), 2) || '-' ||
|
||||
hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||
|
||||
substr(hex( randomblob(2)), 2) || '-' ||
|
||||
substr('AB89', 1 + (abs(random()) % 4) , 1) ||
|
||||
substr(hex(randomblob(2)), 2) || '-' ||
|
||||
substr(hex(randomblob(2)), 2) || '-' ||
|
||||
hex(randomblob(6))
|
||||
)
|
||||
,
|
||||
DATETIME('now'),
|
||||
FALSE,
|
||||
'Devices',
|
||||
,
|
||||
DATETIME('now'),
|
||||
FALSE,
|
||||
'Devices',
|
||||
NEW.devGUID, -- ObjectGUID
|
||||
NEW.devMac, -- ObjectPrimaryID
|
||||
NEW.devLastIP, -- ObjectSecondaryID
|
||||
@@ -369,11 +369,11 @@ CREATE TRIGGER "trg_update_devices"
|
||||
CREATE TRIGGER "trg_delete_devices"
|
||||
AFTER DELETE ON "Devices"
|
||||
WHEN NOT EXISTS (
|
||||
SELECT 1 FROM AppEvents
|
||||
WHERE AppEventProcessed = 0
|
||||
SELECT 1 FROM AppEvents
|
||||
WHERE AppEventProcessed = 0
|
||||
AND ObjectType = 'Devices'
|
||||
AND ObjectGUID = OLD.devGUID
|
||||
AND ObjectStatus = CASE WHEN OLD.devPresentLastScan = 1 THEN 'online' ELSE 'offline' END
|
||||
AND ObjectStatus = CASE WHEN OLD.devPresentLastScan = 1 THEN 'online' ELSE 'offline' END
|
||||
AND AppEventType = 'delete'
|
||||
)
|
||||
BEGIN
|
||||
@@ -394,18 +394,18 @@ CREATE TRIGGER "trg_delete_devices"
|
||||
"AppEventType"
|
||||
)
|
||||
VALUES (
|
||||
|
||||
|
||||
lower(
|
||||
hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||
|
||||
substr(hex( randomblob(2)), 2) || '-' ||
|
||||
hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||
|
||||
substr(hex( randomblob(2)), 2) || '-' ||
|
||||
substr('AB89', 1 + (abs(random()) % 4) , 1) ||
|
||||
substr(hex(randomblob(2)), 2) || '-' ||
|
||||
substr(hex(randomblob(2)), 2) || '-' ||
|
||||
hex(randomblob(6))
|
||||
)
|
||||
,
|
||||
DATETIME('now'),
|
||||
FALSE,
|
||||
'Devices',
|
||||
,
|
||||
DATETIME('now'),
|
||||
FALSE,
|
||||
'Devices',
|
||||
OLD.devGUID, -- ObjectGUID
|
||||
OLD.devMac, -- ObjectPrimaryID
|
||||
OLD.devLastIP, -- ObjectSecondaryID
|
||||
|
||||
@@ -133,7 +133,7 @@ def ensure_views(sql) -> bool:
|
||||
c.*
|
||||
FROM RankedEvents AS e
|
||||
LEFT JOIN Devices AS d ON e.eve_MAC = d.devMac
|
||||
INNER JOIN CurrentScan AS c ON e.eve_MAC = c.cur_MAC
|
||||
INNER JOIN CurrentScan AS c ON e.eve_MAC = c.scanMac
|
||||
WHERE e.row_num = 1;""")
|
||||
|
||||
sql.execute(""" DROP VIEW IF EXISTS Sessions_Devices;""")
|
||||
@@ -177,8 +177,8 @@ def ensure_views(sql) -> bool:
|
||||
SELECT
|
||||
c.*,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY c.cur_MAC, c.cur_ScanMethod
|
||||
ORDER BY c.cur_DateTime DESC
|
||||
PARTITION BY c.scanMac, c.scanSourcePlugin
|
||||
ORDER BY c.scanLastConnection DESC
|
||||
) AS rn
|
||||
FROM CurrentScan c
|
||||
)
|
||||
@@ -187,7 +187,7 @@ def ensure_views(sql) -> bool:
|
||||
r.* -- all CurrentScan fields (cur_*)
|
||||
FROM Devices d
|
||||
LEFT JOIN RankedScans r
|
||||
ON d.devMac = r.cur_MAC
|
||||
ON d.devMac = r.scanMac
|
||||
WHERE r.rn = 1;
|
||||
|
||||
""")
|
||||
@@ -282,20 +282,20 @@ def ensure_CurrentScan(sql) -> bool:
|
||||
# 🐛 CurrentScan DEBUG: comment out below when debugging to keep the CurrentScan table after restarts/scan finishes
|
||||
sql.execute("DROP TABLE IF EXISTS CurrentScan;")
|
||||
sql.execute(""" CREATE TABLE IF NOT EXISTS CurrentScan (
|
||||
cur_MAC STRING(50) NOT NULL COLLATE NOCASE,
|
||||
cur_IP STRING(50) NOT NULL COLLATE NOCASE,
|
||||
cur_Vendor STRING(250),
|
||||
cur_ScanMethod STRING(10),
|
||||
cur_Name STRING(250),
|
||||
cur_LastQuery STRING(250),
|
||||
cur_DateTime STRING(250),
|
||||
cur_SyncHubNodeName STRING(50),
|
||||
cur_NetworkSite STRING(250),
|
||||
cur_SSID STRING(250),
|
||||
cur_devVlan STRING(250),
|
||||
cur_NetworkNodeMAC STRING(250),
|
||||
cur_PORT STRING(250),
|
||||
cur_Type STRING(250)
|
||||
scanMac STRING(50) NOT NULL COLLATE NOCASE,
|
||||
scanLastIP STRING(50) NOT NULL COLLATE NOCASE,
|
||||
scanVendor STRING(250),
|
||||
scanSourcePlugin STRING(10),
|
||||
scanName STRING(250),
|
||||
scanLastQuery STRING(250),
|
||||
scanLastConnection STRING(250),
|
||||
scanSyncHubNode STRING(50),
|
||||
scanSite STRING(250),
|
||||
scanSSID STRING(250),
|
||||
scanVlan STRING(250),
|
||||
scanParentMAC STRING(250),
|
||||
scanParentPort STRING(250),
|
||||
scanType STRING(250)
|
||||
);
|
||||
""")
|
||||
|
||||
|
||||
@@ -56,10 +56,10 @@ def exclude_ignored_devices(db):
|
||||
sql = db.sql # Database interface for executing queries
|
||||
|
||||
mac_condition = list_to_where(
|
||||
"OR", "cur_MAC", "LIKE", get_setting_value("NEWDEV_ignored_MACs")
|
||||
"OR", "scanMac", "LIKE", get_setting_value("NEWDEV_ignored_MACs")
|
||||
)
|
||||
ip_condition = list_to_where(
|
||||
"OR", "cur_IP", "LIKE", get_setting_value("NEWDEV_ignored_IPs")
|
||||
"OR", "scanLastIP", "LIKE", get_setting_value("NEWDEV_ignored_IPs")
|
||||
)
|
||||
|
||||
# Only delete if either the MAC or IP matches an ignored condition
|
||||
@@ -93,7 +93,7 @@ FIELD_SPECS = {
|
||||
# DEVICE NAME
|
||||
# ==========================================================
|
||||
"devName": {
|
||||
"scan_col": "cur_Name",
|
||||
"scan_col": "scanName",
|
||||
"source_col": "devNameSource",
|
||||
"empty_values": ["", "null", "(unknown)", "(name not found)"],
|
||||
"default_value": "(unknown)",
|
||||
@@ -104,7 +104,7 @@ FIELD_SPECS = {
|
||||
# DEVICE FQDN
|
||||
# ==========================================================
|
||||
"devFQDN": {
|
||||
"scan_col": "cur_Name",
|
||||
"scan_col": "scanName",
|
||||
"source_col": "devNameSource",
|
||||
"empty_values": ["", "null", "(unknown)", "(name not found)"],
|
||||
"priority": ["NSLOOKUP", "AVAHISCAN", "NBTSCAN", "DIGSCAN", "ARPSCAN", "DHCPLSS", "NEWDEV", "N/A"],
|
||||
@@ -114,7 +114,7 @@ FIELD_SPECS = {
|
||||
# IP ADDRESS (last seen)
|
||||
# ==========================================================
|
||||
"devLastIP": {
|
||||
"scan_col": "cur_IP",
|
||||
"scan_col": "scanLastIP",
|
||||
"source_col": "devLastIPSource",
|
||||
"empty_values": ["", "null", "(unknown)", "(Unknown)"],
|
||||
"priority": ["ARPSCAN", "NEWDEV", "N/A"],
|
||||
@@ -125,7 +125,7 @@ FIELD_SPECS = {
|
||||
# VENDOR
|
||||
# ==========================================================
|
||||
"devVendor": {
|
||||
"scan_col": "cur_Vendor",
|
||||
"scan_col": "scanVendor",
|
||||
"source_col": "devVendorSource",
|
||||
"empty_values": ["", "null", "(unknown)", "(Unknown)"],
|
||||
"priority": ["VNDRPDT", "ARPSCAN", "NEWDEV", "N/A"],
|
||||
@@ -136,7 +136,7 @@ FIELD_SPECS = {
|
||||
# SYNC HUB NODE NAME
|
||||
# ==========================================================
|
||||
"devSyncHubNode": {
|
||||
"scan_col": "cur_SyncHubNodeName",
|
||||
"scan_col": "scanSyncHubNode",
|
||||
"source_col": None,
|
||||
"empty_values": ["", "null"],
|
||||
"priority": None,
|
||||
@@ -146,7 +146,7 @@ FIELD_SPECS = {
|
||||
# Network Site
|
||||
# ==========================================================
|
||||
"devSite": {
|
||||
"scan_col": "cur_NetworkSite",
|
||||
"scan_col": "scanSite",
|
||||
"source_col": None,
|
||||
"empty_values": ["", "null"],
|
||||
"priority": None,
|
||||
@@ -156,7 +156,7 @@ FIELD_SPECS = {
|
||||
# VLAN
|
||||
# ==========================================================
|
||||
"devVlan": {
|
||||
"scan_col": "cur_devVlan",
|
||||
"scan_col": "scanVlan",
|
||||
"source_col": "devVlanSource",
|
||||
"empty_values": ["", "null"],
|
||||
"priority": None,
|
||||
@@ -166,7 +166,7 @@ FIELD_SPECS = {
|
||||
# devType
|
||||
# ==========================================================
|
||||
"devType": {
|
||||
"scan_col": "cur_Type",
|
||||
"scan_col": "scanType",
|
||||
"source_col": None,
|
||||
"empty_values": ["", "null"],
|
||||
"priority": None,
|
||||
@@ -176,14 +176,14 @@ FIELD_SPECS = {
|
||||
# TOPOLOGY (PARENT NODE)
|
||||
# ==========================================================
|
||||
"devParentMAC": {
|
||||
"scan_col": "cur_NetworkNodeMAC",
|
||||
"scan_col": "scanParentMAC",
|
||||
"source_col": "devParentMACSource",
|
||||
"empty_values": ["", "null"],
|
||||
"priority": ["SNMPDSC", "UNIFIAPI", "UNFIMP", "NEWDEV", "N/A"],
|
||||
},
|
||||
|
||||
"devParentPort": {
|
||||
"scan_col": "cur_PORT",
|
||||
"scan_col": "scanParentPort",
|
||||
"source_col": None,
|
||||
"empty_values": ["", "null"],
|
||||
"priority": ["SNMPDSC", "UNIFIAPI", "UNFIMP", "NEWDEV", "N/A"],
|
||||
@@ -193,7 +193,7 @@ FIELD_SPECS = {
|
||||
# WIFI SSID
|
||||
# ==========================================================
|
||||
"devSSID": {
|
||||
"scan_col": "cur_SSID",
|
||||
"scan_col": "scanSSID",
|
||||
"source_col": None,
|
||||
"empty_values": ["", "null"],
|
||||
"priority": ["SNMPDSC", "UNIFIAPI", "UNFIMP", "NEWDEV", "N/A"],
|
||||
@@ -214,7 +214,7 @@ def update_presence_from_CurrentScan(db):
|
||||
SET devPresentLastScan = 1
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM CurrentScan
|
||||
WHERE devMac = cur_MAC
|
||||
WHERE devMac = scanMac
|
||||
)
|
||||
""")
|
||||
|
||||
@@ -224,7 +224,7 @@ def update_presence_from_CurrentScan(db):
|
||||
SET devPresentLastScan = 0
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM CurrentScan
|
||||
WHERE devMac = cur_MAC
|
||||
WHERE devMac = scanMac
|
||||
)
|
||||
""")
|
||||
|
||||
@@ -242,7 +242,7 @@ def update_devLastConnection_from_CurrentScan(db):
|
||||
SET devLastConnection = '{startTime}'
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM CurrentScan
|
||||
WHERE devMac = cur_MAC
|
||||
WHERE devMac = scanMac
|
||||
)
|
||||
""")
|
||||
|
||||
@@ -253,7 +253,7 @@ def update_devices_data_from_scan(db):
|
||||
# ----------------------------------------------------------------
|
||||
# 1️⃣ Get plugin scan methods
|
||||
# ----------------------------------------------------------------
|
||||
plugin_rows = sql.execute("SELECT DISTINCT cur_ScanMethod FROM CurrentScan").fetchall()
|
||||
plugin_rows = sql.execute("SELECT DISTINCT scanSourcePlugin FROM CurrentScan").fetchall()
|
||||
plugin_prefixes = [row[0] for row in plugin_rows if row[0]] or [None]
|
||||
|
||||
plugin_settings_cache = {}
|
||||
@@ -275,7 +275,7 @@ def update_devices_data_from_scan(db):
|
||||
sql_tmp = f"""
|
||||
SELECT *
|
||||
FROM LatestDeviceScan
|
||||
{"WHERE cur_ScanMethod = ?" if filter_by_scan_method else ""}
|
||||
{"WHERE scanSourcePlugin = ?" if filter_by_scan_method else ""}
|
||||
"""
|
||||
rows = sql.execute(sql_tmp, (source_prefix,) if filter_by_scan_method else ()).fetchall()
|
||||
col_names = [desc[0] for desc in sql.description]
|
||||
@@ -444,8 +444,8 @@ def update_vendors_from_mac(db):
|
||||
|
||||
# Build mapping: devMac -> vendor (skip unknown or invalid)
|
||||
vendor_map = {}
|
||||
for row in sql.execute("SELECT DISTINCT cur_MAC FROM CurrentScan"):
|
||||
mac = row["cur_MAC"]
|
||||
for row in sql.execute("SELECT DISTINCT scanMac FROM CurrentScan"):
|
||||
mac = row["scanMac"]
|
||||
vendor = query_MAC_vendor(mac)
|
||||
if vendor not in (-1, -2):
|
||||
vendor_map[mac] = vendor
|
||||
@@ -518,7 +518,7 @@ def save_scanned_devices(db):
|
||||
# Proceed if variable contains valid MAC
|
||||
if check_mac_or_internet(local_mac):
|
||||
sql.execute(
|
||||
f"""INSERT OR IGNORE INTO CurrentScan (cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) VALUES ( '{local_mac}', '{local_ip}', Null, 'local_MAC') """
|
||||
f"""INSERT OR IGNORE INTO CurrentScan (scanMac, scanLastIP, scanVendor, scanSourcePlugin) VALUES ( '{local_mac}', '{local_ip}', Null, 'local_MAC') """
|
||||
)
|
||||
|
||||
|
||||
@@ -529,23 +529,23 @@ def print_scan_stats(db):
|
||||
query = """
|
||||
SELECT
|
||||
(SELECT COUNT(*) FROM CurrentScan) AS devices_detected,
|
||||
(SELECT COUNT(*) FROM CurrentScan WHERE NOT EXISTS (SELECT 1 FROM Devices WHERE devMac = cur_MAC)) AS new_devices,
|
||||
(SELECT COUNT(*) FROM Devices WHERE devAlertDown != 0 AND NOT EXISTS (SELECT 1 FROM CurrentScan WHERE devMac = cur_MAC)) AS down_alerts,
|
||||
(SELECT COUNT(*) FROM Devices WHERE devAlertDown != 0 AND devPresentLastScan = 1 AND NOT EXISTS (SELECT 1 FROM CurrentScan WHERE devMac = cur_MAC)) AS new_down_alerts,
|
||||
(SELECT COUNT(*) FROM CurrentScan WHERE NOT EXISTS (SELECT 1 FROM Devices WHERE devMac = scanMac)) AS new_devices,
|
||||
(SELECT COUNT(*) FROM Devices WHERE devAlertDown != 0 AND NOT EXISTS (SELECT 1 FROM CurrentScan WHERE devMac = scanMac)) AS down_alerts,
|
||||
(SELECT COUNT(*) FROM Devices WHERE devAlertDown != 0 AND devPresentLastScan = 1 AND NOT EXISTS (SELECT 1 FROM CurrentScan WHERE devMac = scanMac)) AS new_down_alerts,
|
||||
(SELECT COUNT(*) FROM Devices WHERE devPresentLastScan = 0) AS new_connections,
|
||||
(SELECT COUNT(*) FROM Devices WHERE devPresentLastScan = 1 AND NOT EXISTS (SELECT 1 FROM CurrentScan WHERE devMac = cur_MAC)) AS disconnections,
|
||||
(SELECT COUNT(*) FROM Devices WHERE devPresentLastScan = 1 AND NOT EXISTS (SELECT 1 FROM CurrentScan WHERE devMac = scanMac)) AS disconnections,
|
||||
(SELECT COUNT(*) FROM Devices, CurrentScan
|
||||
WHERE devMac = cur_MAC
|
||||
AND cur_IP IS NOT NULL
|
||||
AND cur_IP NOT IN ('', 'null', '(unknown)', '(Unknown)')
|
||||
AND cur_IP <> COALESCE(devPrimaryIPv4, '')
|
||||
AND cur_IP <> COALESCE(devPrimaryIPv6, '')
|
||||
AND cur_IP <> COALESCE(devLastIP, '')
|
||||
WHERE devMac = scanMac
|
||||
AND scanLastIP IS NOT NULL
|
||||
AND scanLastIP NOT IN ('', 'null', '(unknown)', '(Unknown)')
|
||||
AND scanLastIP <> COALESCE(devPrimaryIPv4, '')
|
||||
AND scanLastIP <> COALESCE(devPrimaryIPv6, '')
|
||||
AND scanLastIP <> COALESCE(devLastIP, '')
|
||||
) AS ip_changes,
|
||||
cur_ScanMethod,
|
||||
scanSourcePlugin,
|
||||
COUNT(*) AS scan_method_count
|
||||
FROM CurrentScan
|
||||
GROUP BY cur_ScanMethod
|
||||
GROUP BY scanSourcePlugin
|
||||
"""
|
||||
|
||||
sql.execute(query)
|
||||
@@ -590,8 +590,8 @@ def print_scan_stats(db):
|
||||
|
||||
mylog("verbose", "[Scan Stats] Scan Method Statistics:")
|
||||
for row in stats:
|
||||
if row["cur_ScanMethod"] is not None:
|
||||
mylog("verbose", f" {row['cur_ScanMethod']}: {row['scan_method_count']}")
|
||||
if row["scanSourcePlugin"] is not None:
|
||||
mylog("verbose", f" {row['scanSourcePlugin']}: {row['scan_method_count']}")
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------
|
||||
@@ -608,11 +608,11 @@ def create_new_devices(db):
|
||||
eve_EventType, eve_AdditionalInfo,
|
||||
eve_PendingAlertEmail
|
||||
)
|
||||
SELECT DISTINCT cur_MAC, cur_IP, '{startTime}', 'New Device', cur_Vendor, 1
|
||||
SELECT DISTINCT scanMac, scanLastIP, '{startTime}', 'New Device', scanVendor, 1
|
||||
FROM CurrentScan
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM Devices
|
||||
WHERE devMac = cur_MAC
|
||||
WHERE devMac = scanMac
|
||||
)
|
||||
"""
|
||||
|
||||
@@ -627,15 +627,15 @@ def create_new_devices(db):
|
||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection,
|
||||
ses_StillConnected, ses_AdditionalInfo
|
||||
)
|
||||
SELECT cur_MAC, cur_IP, 'Connected', '{startTime}', NULL, NULL, 1, cur_Vendor
|
||||
SELECT scanMac, scanLastIP, 'Connected', '{startTime}', NULL, NULL, 1, scanVendor
|
||||
FROM CurrentScan
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM Devices
|
||||
WHERE devMac = cur_MAC
|
||||
WHERE devMac = scanMac
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM Sessions
|
||||
WHERE ses_MAC = cur_MAC AND ses_StillConnected = 1
|
||||
WHERE ses_MAC = scanMac AND ses_StillConnected = 1
|
||||
)
|
||||
""")
|
||||
|
||||
@@ -680,7 +680,7 @@ def create_new_devices(db):
|
||||
"""
|
||||
|
||||
# Fetch data from CurrentScan skipping ignored devices by IP and MAC
|
||||
query = """SELECT cur_MAC, cur_Name, cur_Vendor, cur_ScanMethod, cur_IP, cur_SyncHubNodeName, cur_NetworkNodeMAC, cur_PORT, cur_NetworkSite, cur_SSID, cur_Type
|
||||
query = """SELECT scanMac, scanName, scanVendor, scanSourcePlugin, scanLastIP, scanSyncHubNode, scanParentMAC, scanParentPort, scanSite, scanSSID, scanType
|
||||
FROM CurrentScan """
|
||||
|
||||
mylog("debug", f"[New Devices] Collecting New Devices Query: {query}")
|
||||
@@ -688,61 +688,61 @@ def create_new_devices(db):
|
||||
|
||||
for row in current_scan_data:
|
||||
(
|
||||
cur_MAC,
|
||||
cur_Name,
|
||||
cur_Vendor,
|
||||
cur_ScanMethod,
|
||||
cur_IP,
|
||||
cur_SyncHubNodeName,
|
||||
cur_NetworkNodeMAC,
|
||||
cur_PORT,
|
||||
cur_NetworkSite,
|
||||
cur_SSID,
|
||||
cur_Type,
|
||||
scanMac,
|
||||
scanName,
|
||||
scanVendor,
|
||||
scanSourcePlugin,
|
||||
scanLastIP,
|
||||
scanSyncHubNode,
|
||||
scanParentMAC,
|
||||
scanParentPort,
|
||||
scanSite,
|
||||
scanSSID,
|
||||
scanType,
|
||||
) = row
|
||||
|
||||
# Preserve raw values to determine source attribution
|
||||
raw_name = str(cur_Name).strip() if cur_Name else ""
|
||||
raw_vendor = str(cur_Vendor).strip() if cur_Vendor else ""
|
||||
raw_ip = str(cur_IP).strip() if cur_IP else ""
|
||||
raw_name = str(scanName).strip() if scanName else ""
|
||||
raw_vendor = str(scanVendor).strip() if scanVendor else ""
|
||||
raw_ip = str(scanLastIP).strip() if scanLastIP else ""
|
||||
if raw_ip.lower() in ("null", "(unknown)"):
|
||||
raw_ip = ""
|
||||
raw_ssid = str(cur_SSID).strip() if cur_SSID else ""
|
||||
raw_ssid = str(scanSSID).strip() if scanSSID else ""
|
||||
if raw_ssid.lower() in ("null", "(unknown)"):
|
||||
raw_ssid = ""
|
||||
raw_parent_mac = str(cur_NetworkNodeMAC).strip() if cur_NetworkNodeMAC else ""
|
||||
raw_parent_mac = str(scanParentMAC).strip() if scanParentMAC else ""
|
||||
if raw_parent_mac.lower() in ("null", "(unknown)"):
|
||||
raw_parent_mac = ""
|
||||
raw_parent_port = str(cur_PORT).strip() if cur_PORT else ""
|
||||
raw_parent_port = str(scanParentPort).strip() if scanParentPort else ""
|
||||
if raw_parent_port.lower() in ("null", "(unknown)"):
|
||||
raw_parent_port = ""
|
||||
|
||||
# Handle NoneType
|
||||
cur_Name = raw_name if raw_name else "(unknown)"
|
||||
cur_Type = (
|
||||
str(cur_Type).strip() if cur_Type else get_setting_value("NEWDEV_devType")
|
||||
scanName = raw_name if raw_name else "(unknown)"
|
||||
scanType = (
|
||||
str(scanType).strip() if scanType else get_setting_value("NEWDEV_devType")
|
||||
)
|
||||
cur_NetworkNodeMAC = raw_parent_mac
|
||||
cur_NetworkNodeMAC = (
|
||||
cur_NetworkNodeMAC
|
||||
if cur_NetworkNodeMAC and cur_MAC != "Internet"
|
||||
scanParentMAC = raw_parent_mac
|
||||
scanParentMAC = (
|
||||
scanParentMAC
|
||||
if scanParentMAC and scanMac != "Internet"
|
||||
else (
|
||||
get_setting_value("NEWDEV_devParentMAC")
|
||||
if cur_MAC != "Internet"
|
||||
if scanMac != "Internet"
|
||||
else "null"
|
||||
)
|
||||
)
|
||||
cur_SyncHubNodeName = (
|
||||
cur_SyncHubNodeName
|
||||
if cur_SyncHubNodeName and cur_SyncHubNodeName != "null"
|
||||
scanSyncHubNode = (
|
||||
scanSyncHubNode
|
||||
if scanSyncHubNode and scanSyncHubNode != "null"
|
||||
else (get_setting_value("SYNC_node_name"))
|
||||
)
|
||||
|
||||
# Derive primary IP family values
|
||||
cur_IP = raw_ip
|
||||
cur_SSID = raw_ssid
|
||||
cur_PORT = raw_parent_port
|
||||
cur_IP_normalized = check_IP_format(cur_IP) if ":" not in cur_IP else cur_IP
|
||||
scanLastIP = raw_ip
|
||||
scanSSID = raw_ssid
|
||||
scanParentPort = raw_parent_port
|
||||
cur_IP_normalized = check_IP_format(scanLastIP) if ":" not in scanLastIP else scanLastIP
|
||||
|
||||
# Validate IPv6 addresses using format_ip_long for consistency (do not store integer result)
|
||||
if cur_IP_normalized and ":" in cur_IP_normalized:
|
||||
@@ -753,10 +753,10 @@ def create_new_devices(db):
|
||||
primary_ipv4 = cur_IP_normalized if cur_IP_normalized and ":" not in cur_IP_normalized else ""
|
||||
primary_ipv6 = cur_IP_normalized if cur_IP_normalized and ":" in cur_IP_normalized else ""
|
||||
|
||||
plugin_prefix = str(cur_ScanMethod).strip() if cur_ScanMethod else "NEWDEV"
|
||||
plugin_prefix = str(scanSourcePlugin).strip() if scanSourcePlugin else "NEWDEV"
|
||||
|
||||
dev_mac_source = get_source_for_field_update_with_value(
|
||||
"devMac", plugin_prefix, cur_MAC, is_user_override=False
|
||||
"devMac", plugin_prefix, scanMac, is_user_override=False
|
||||
)
|
||||
dev_name_source = get_source_for_field_update_with_value(
|
||||
"devName", plugin_prefix, raw_name, is_user_override=False
|
||||
@@ -813,22 +813,22 @@ def create_new_devices(db):
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'{sanitize_SQL_input(cur_MAC)}',
|
||||
'{sanitize_SQL_input(cur_Name)}',
|
||||
'{sanitize_SQL_input(cur_Vendor)}',
|
||||
'{sanitize_SQL_input(scanMac)}',
|
||||
'{sanitize_SQL_input(scanName)}',
|
||||
'{sanitize_SQL_input(scanVendor)}',
|
||||
'{sanitize_SQL_input(cur_IP_normalized)}',
|
||||
'{sanitize_SQL_input(primary_ipv4)}',
|
||||
'{sanitize_SQL_input(primary_ipv6)}',
|
||||
?,
|
||||
?,
|
||||
'{sanitize_SQL_input(cur_SyncHubNodeName)}',
|
||||
'{sanitize_SQL_input(scanSyncHubNode)}',
|
||||
{sql_generateGuid},
|
||||
'{sanitize_SQL_input(cur_NetworkNodeMAC)}',
|
||||
'{sanitize_SQL_input(cur_PORT)}',
|
||||
'{sanitize_SQL_input(cur_NetworkSite)}',
|
||||
'{sanitize_SQL_input(cur_SSID)}',
|
||||
'{sanitize_SQL_input(cur_Type)}',
|
||||
'{sanitize_SQL_input(cur_ScanMethod)}',
|
||||
'{sanitize_SQL_input(scanParentMAC)}',
|
||||
'{sanitize_SQL_input(scanParentPort)}',
|
||||
'{sanitize_SQL_input(scanSite)}',
|
||||
'{sanitize_SQL_input(scanSSID)}',
|
||||
'{sanitize_SQL_input(scanType)}',
|
||||
'{sanitize_SQL_input(scanSourcePlugin)}',
|
||||
'{sanitize_SQL_input(dev_mac_source)}',
|
||||
'{sanitize_SQL_input(dev_name_source)}',
|
||||
'{sanitize_SQL_input(dev_fqdn_source)}',
|
||||
|
||||
@@ -174,7 +174,7 @@ def insert_events(db):
|
||||
WHERE devAlertDown != 0
|
||||
AND devPresentLastScan = 1
|
||||
AND NOT EXISTS (SELECT 1 FROM CurrentScan
|
||||
WHERE devMac = cur_MAC
|
||||
WHERE devMac = scanMac
|
||||
) """)
|
||||
|
||||
# Check new Connections or Down Reconnections
|
||||
@@ -182,7 +182,7 @@ def insert_events(db):
|
||||
sql.execute(f""" INSERT INTO Events (eve_MAC, eve_IP, eve_DateTime,
|
||||
eve_EventType, eve_AdditionalInfo,
|
||||
eve_PendingAlertEmail)
|
||||
SELECT DISTINCT c.cur_MAC, c.cur_IP, '{startTime}',
|
||||
SELECT DISTINCT c.scanMac, c.scanLastIP, '{startTime}',
|
||||
CASE
|
||||
WHEN last_event.eve_EventType = 'Device Down' and last_event.eve_PendingAlertEmail = 0 THEN 'Down Reconnected'
|
||||
ELSE 'Connected'
|
||||
@@ -190,7 +190,7 @@ def insert_events(db):
|
||||
'',
|
||||
1
|
||||
FROM CurrentScan AS c
|
||||
LEFT JOIN LatestEventsPerMAC AS last_event ON c.cur_MAC = last_event.eve_MAC
|
||||
LEFT JOIN LatestEventsPerMAC AS last_event ON c.scanMac = last_event.eve_MAC
|
||||
WHERE last_event.devPresentLastScan = 0 OR last_event.eve_MAC IS NULL
|
||||
""")
|
||||
|
||||
@@ -205,7 +205,7 @@ def insert_events(db):
|
||||
WHERE devAlertDown = 0
|
||||
AND devPresentLastScan = 1
|
||||
AND NOT EXISTS (SELECT 1 FROM CurrentScan
|
||||
WHERE devMac = cur_MAC
|
||||
WHERE devMac = scanMac
|
||||
) """)
|
||||
|
||||
# Check IP Changed
|
||||
@@ -213,15 +213,15 @@ def insert_events(db):
|
||||
sql.execute(f"""INSERT INTO Events (eve_MAC, eve_IP, eve_DateTime,
|
||||
eve_EventType, eve_AdditionalInfo,
|
||||
eve_PendingAlertEmail)
|
||||
SELECT cur_MAC, cur_IP, '{startTime}', 'IP Changed',
|
||||
SELECT scanMac, scanLastIP, '{startTime}', 'IP Changed',
|
||||
'Previous IP: '|| devLastIP, devAlertEvents
|
||||
FROM Devices, CurrentScan
|
||||
WHERE devMac = cur_MAC
|
||||
AND cur_IP IS NOT NULL
|
||||
AND cur_IP NOT IN ('', 'null', '(unknown)', '(Unknown)')
|
||||
AND cur_IP <> COALESCE(devPrimaryIPv4, '')
|
||||
AND cur_IP <> COALESCE(devPrimaryIPv6, '')
|
||||
AND cur_IP <> COALESCE(devLastIP, '') """)
|
||||
WHERE devMac = scanMac
|
||||
AND scanLastIP IS NOT NULL
|
||||
AND scanLastIP NOT IN ('', 'null', '(unknown)', '(Unknown)')
|
||||
AND scanLastIP <> COALESCE(devPrimaryIPv4, '')
|
||||
AND scanLastIP <> COALESCE(devPrimaryIPv6, '')
|
||||
AND scanLastIP <> COALESCE(devLastIP, '') """)
|
||||
mylog("debug", "[Events] - Events end")
|
||||
|
||||
|
||||
|
||||
@@ -66,19 +66,19 @@ def scan_db():
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE CurrentScan (
|
||||
cur_MAC TEXT,
|
||||
cur_IP TEXT,
|
||||
cur_Vendor TEXT,
|
||||
cur_ScanMethod TEXT,
|
||||
cur_Name TEXT,
|
||||
cur_LastQuery TEXT,
|
||||
cur_DateTime TEXT,
|
||||
cur_SyncHubNodeName TEXT,
|
||||
cur_NetworkSite TEXT,
|
||||
cur_SSID TEXT,
|
||||
cur_NetworkNodeMAC TEXT,
|
||||
cur_PORT TEXT,
|
||||
cur_Type TEXT
|
||||
scanMac TEXT,
|
||||
scanLastIP TEXT,
|
||||
scanVendor TEXT,
|
||||
scanSourcePlugin TEXT,
|
||||
scanName TEXT,
|
||||
scanLastQuery TEXT,
|
||||
scanLastConnection TEXT,
|
||||
scanSyncHubNode TEXT,
|
||||
scanSite TEXT,
|
||||
scanSSID TEXT,
|
||||
scanParentMAC TEXT,
|
||||
scanParentPort TEXT,
|
||||
scanType TEXT
|
||||
)
|
||||
"""
|
||||
)
|
||||
@@ -196,17 +196,17 @@ def scan_db_for_new_devices():
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE CurrentScan (
|
||||
cur_MAC TEXT,
|
||||
cur_Name TEXT,
|
||||
cur_Vendor TEXT,
|
||||
cur_ScanMethod TEXT,
|
||||
cur_IP TEXT,
|
||||
cur_SyncHubNodeName TEXT,
|
||||
cur_NetworkNodeMAC TEXT,
|
||||
cur_PORT TEXT,
|
||||
cur_NetworkSite TEXT,
|
||||
cur_SSID TEXT,
|
||||
cur_Type TEXT
|
||||
scanMac TEXT,
|
||||
scanName TEXT,
|
||||
scanVendor TEXT,
|
||||
scanSourcePlugin TEXT,
|
||||
scanLastIP TEXT,
|
||||
scanSyncHubNode TEXT,
|
||||
scanParentMAC TEXT,
|
||||
scanParentPort TEXT,
|
||||
scanSite TEXT,
|
||||
scanSSID TEXT,
|
||||
scanType TEXT
|
||||
)
|
||||
"""
|
||||
)
|
||||
@@ -250,9 +250,9 @@ def test_create_new_devices_sets_sources(scan_db_for_new_devices):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_Name, cur_Vendor, cur_ScanMethod, cur_IP,
|
||||
cur_SyncHubNodeName, cur_NetworkNodeMAC, cur_PORT,
|
||||
cur_NetworkSite, cur_SSID, cur_Type
|
||||
scanMac, scanName, scanVendor, scanSourcePlugin, scanLastIP,
|
||||
scanSyncHubNode, scanParentMAC, scanParentPort,
|
||||
scanSite, scanSSID, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -364,9 +364,9 @@ def test_scan_updates_newdev_device_name(scan_db, mock_device_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -439,9 +439,9 @@ def test_scan_does_not_update_user_field_name(scan_db, mock_device_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -514,9 +514,9 @@ def test_scan_does_not_update_locked_field(scan_db, mock_device_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -589,9 +589,9 @@ def test_scan_updates_empty_vendor_field(scan_db, mock_device_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -667,9 +667,9 @@ def test_scan_updates_ip_addresses(scan_db, mock_device_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -747,9 +747,9 @@ def test_scan_updates_ipv6_without_changing_ipv4(scan_db, mock_device_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -890,9 +890,9 @@ def test_scan_multiple_devices_mixed_sources(scan_db, mock_device_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(mac, ip, vendor, scan_method, name, "", "2025-01-01 01:00:00", "", "", "", "", "", ""),
|
||||
|
||||
@@ -51,19 +51,19 @@ def ip_test_db():
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE CurrentScan (
|
||||
cur_MAC TEXT,
|
||||
cur_IP TEXT,
|
||||
cur_Vendor TEXT,
|
||||
cur_ScanMethod TEXT,
|
||||
cur_Name TEXT,
|
||||
cur_LastQuery TEXT,
|
||||
cur_DateTime TEXT,
|
||||
cur_SyncHubNodeName TEXT,
|
||||
cur_NetworkSite TEXT,
|
||||
cur_SSID TEXT,
|
||||
cur_NetworkNodeMAC TEXT,
|
||||
cur_PORT TEXT,
|
||||
cur_Type TEXT
|
||||
scanMac TEXT,
|
||||
scanLastIP TEXT,
|
||||
scanVendor TEXT,
|
||||
scanSourcePlugin TEXT,
|
||||
scanName TEXT,
|
||||
scanLastQuery TEXT,
|
||||
scanLastConnection TEXT,
|
||||
scanSyncHubNode TEXT,
|
||||
scanSite TEXT,
|
||||
scanSSID TEXT,
|
||||
scanParentMAC TEXT,
|
||||
scanParentPort TEXT,
|
||||
scanType TEXT
|
||||
)
|
||||
"""
|
||||
)
|
||||
@@ -123,9 +123,9 @@ def test_valid_ipv4_format_accepted(ip_test_db, mock_ip_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -197,9 +197,9 @@ def test_valid_ipv6_format_accepted(ip_test_db, mock_ip_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -274,9 +274,9 @@ def test_invalid_ip_values_rejected(ip_test_db, mock_ip_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -348,9 +348,9 @@ def test_ipv4_ipv6_mixed_in_multiple_scans(ip_test_db, mock_ip_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -390,9 +390,9 @@ def test_ipv4_ipv6_mixed_in_multiple_scans(ip_test_db, mock_ip_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -455,9 +455,9 @@ def test_ipv4_address_format_variations(ip_test_db, mock_ip_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(mac, ipv4, "Vendor", "ARPSCAN", "", "", "2025-01-01 01:00:00", "", "", "", "", "", ""),
|
||||
@@ -509,9 +509,9 @@ def test_ipv6_address_format_variations(ip_test_db, mock_ip_handlers):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(mac, ipv6, "Vendor", "ARPSCAN", "", "", "2025-01-01 01:00:00", "", "", "", "", "", ""),
|
||||
|
||||
@@ -42,19 +42,19 @@ def in_memory_db():
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE CurrentScan (
|
||||
cur_MAC TEXT,
|
||||
cur_IP TEXT,
|
||||
cur_Vendor TEXT,
|
||||
cur_ScanMethod TEXT,
|
||||
cur_Name TEXT,
|
||||
cur_LastQuery TEXT,
|
||||
cur_DateTime TEXT,
|
||||
cur_SyncHubNodeName TEXT,
|
||||
cur_NetworkSite TEXT,
|
||||
cur_SSID TEXT,
|
||||
cur_NetworkNodeMAC TEXT,
|
||||
cur_PORT TEXT,
|
||||
cur_Type TEXT
|
||||
scanMac TEXT,
|
||||
scanLastIP TEXT,
|
||||
scanVendor TEXT,
|
||||
scanSourcePlugin TEXT,
|
||||
scanName TEXT,
|
||||
scanLastQuery TEXT,
|
||||
scanLastConnection TEXT,
|
||||
scanSyncHubNode TEXT,
|
||||
scanSite TEXT,
|
||||
scanSSID TEXT,
|
||||
scanParentMAC TEXT,
|
||||
scanParentPort TEXT,
|
||||
scanType TEXT
|
||||
)
|
||||
"""
|
||||
)
|
||||
@@ -118,9 +118,9 @@ def test_primary_ipv6_is_set_and_ipv4_preserved(in_memory_db, mock_device_handli
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -145,7 +145,7 @@ def test_primary_ipv6_is_set_and_ipv4_preserved(in_memory_db, mock_device_handli
|
||||
db = Mock()
|
||||
db.sql_connection = in_memory_db
|
||||
db.sql = cur
|
||||
|
||||
|
||||
device_handling.update_devices_data_from_scan(db)
|
||||
|
||||
row = cur.execute(
|
||||
@@ -193,9 +193,9 @@ def test_primary_ipv4_is_set_and_ipv6_preserved(in_memory_db, mock_device_handli
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO CurrentScan (
|
||||
cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod, cur_Name,
|
||||
cur_LastQuery, cur_DateTime, cur_SyncHubNodeName,
|
||||
cur_NetworkSite, cur_SSID, cur_NetworkNodeMAC, cur_PORT, cur_Type
|
||||
scanMac, scanLastIP, scanVendor, scanSourcePlugin, scanName,
|
||||
scanLastQuery, scanLastConnection, scanSyncHubNode,
|
||||
scanSite, scanSSID, scanParentMAC, scanParentPort, scanType
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -220,7 +220,7 @@ def test_primary_ipv4_is_set_and_ipv6_preserved(in_memory_db, mock_device_handli
|
||||
db = Mock()
|
||||
db.sql_connection = in_memory_db
|
||||
db.sql = cur
|
||||
|
||||
|
||||
device_handling.update_devices_data_from_scan(db)
|
||||
|
||||
row = cur.execute(
|
||||
|
||||
Reference in New Issue
Block a user