diff --git a/README.md b/README.md
index ec595aad..1e20908a 100755
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ Get visibility of what's going on on your WIFI/LAN network. Schedule scans for d
|-------------|-------------|
| π₯π³ | [Docker instructions](https://github.com/jokob-sk/NetAlertX/blob/main/dockerfiles/README.md)
| π₯π» | [HW install (experimental π§ͺ)](https://github.com/jokob-sk/NetAlertX/blob/main/docs/HW_INSTALL.md) |
-| π₯π§ | [Unraid App π§ͺ)](https://unraid.net/community/apps) |
+| π₯π§ | [Unraid App](https://unraid.net/community/apps) |
| π | [All Documentation](https://github.com/jokob-sk/NetAlertX/blob/main/docs/README.md) (App Usage and Configuration) |
> Other Alternatives
diff --git a/front/js/common.js b/front/js/common.js
index 72352422..85b0aeb7 100755
--- a/front/js/common.js
+++ b/front/js/common.js
@@ -254,13 +254,13 @@ function getString (key) {
case 'Norwegian':
lang_code = 'nb_no';
break;
- case 'Polish':
+ case 'Polish (pl_pl)':
lang_code = 'pl_pl';
break;
- case 'Portuguese (Brazil)':
+ case 'Portuguese (pt_br)':
lang_code = 'pt_br';
break;
- case 'Italian':
+ case 'Italian (it_it)':
lang_code = 'it_it';
break;
case 'Russian':
diff --git a/front/php/templates/language/lang.php b/front/php/templates/language/lang.php
index 08ae740a..e67b31ff 100755
--- a/front/php/templates/language/lang.php
+++ b/front/php/templates/language/lang.php
@@ -10,13 +10,13 @@ $allLanguages = ["en_us","es_es","de_de", "nb_no", "pl_pl", "pt_br", "ru_ru", "f
global $db;
$result = $db->querySingle("SELECT Value FROM Settings WHERE Code_Name = 'UI_LANG'");
-switch($result){
+switch($result){
case 'Spanish': $pia_lang_selected = 'es_es'; break;
case 'German': $pia_lang_selected = 'de_de'; break;
case 'Norwegian': $pia_lang_selected = 'nb_no'; break;
- case 'Polish': $pia_lang_selected = 'pl_pl'; break;
- case 'Portuguese (Brazil)': $pia_lang_selected = 'pt_br'; break;
- case 'Italian': $pia_lang_selected = 'it_it'; break;
+ case 'Polish (pl_pl)': $pia_lang_selected = 'pl_pl'; break;
+ case 'Portuguese (pt_br)': $pia_lang_selected = 'pt_br'; break;
+ case 'Italian (it_it)': $pia_lang_selected = 'it_it'; break;
case 'Russian': $pia_lang_selected = 'ru_ru'; break;
case 'French': $pia_lang_selected = 'fr_fr'; break;
case 'Chinese (zh_cn)': $pia_lang_selected = 'zh_cn'; break;
diff --git a/front/plugins/maintenance/config.json b/front/plugins/maintenance/config.json
index c7ed7cec..e0189ca4 100755
--- a/front/plugins/maintenance/config.json
+++ b/front/plugins/maintenance/config.json
@@ -89,7 +89,7 @@
{
"function": "RUN_SCHD",
"type": "text",
- "default_value":"0 2 * * 3",
+ "default_value":"0 2 * * *",
"options": [],
"localized": ["name", "description"],
"name" : [{
diff --git a/front/report_templates/report_template.html b/front/report_templates/report_template.html
index e7d75fc1..09fe10b3 100755
--- a/front/report_templates/report_template.html
+++ b/front/report_templates/report_template.html
@@ -61,14 +61,14 @@
diff --git a/front/report_templates/report_template_new_version.html b/front/report_templates/report_template_new_version.html
index 5d4c60c2..d655ed30 100755
--- a/front/report_templates/report_template_new_version.html
+++ b/front/report_templates/report_template_new_version.html
@@ -67,8 +67,8 @@
NetAlertX
()
- ©2020 Puche (2022+
- jokob-sk) | Built on: | Version: |
+ ©2022
+ jokob-sk | Built on: | Version: |
Docs
diff --git a/front/report_templates/webhook_json_sample.json b/front/report_templates/webhook_json_sample.json
index c996cd06..39113b79 100755
--- a/front/report_templates/webhook_json_sample.json
+++ b/front/report_templates/webhook_json_sample.json
@@ -18,7 +18,7 @@
"title_link": "",
"text": {
"new_devices_meta": {
- "title": "New devices",
+ "title": "πNew devices",
"columnNames": [
"MAC",
"Datetime",
@@ -62,6 +62,27 @@
"Comments"
]
},
+ "down_reconnected": [
+ {
+ "dev_Name": "Phone - Pixel",
+ "eve_MAC": "74:ac:74:ac:74:ac",
+ "dev_Vendor": "Google",
+ "eve_IP": "192.168.1.167",
+ "DownTime": "2024-05-26 09:06:56+10:00",
+ "ConnectedTime": "2024-05-26 09:13:24+10:00"
+ }
+ ],
+ "down_reconnected_meta": {
+ "title": "π Reconnected down devices",
+ "columnNames": [
+ "dev_Name",
+ "eve_MAC",
+ "dev_Vendor",
+ "eve_IP",
+ "DownTime",
+ "ConnectedTime"
+ ]
+ },
"events": [
{
"MAC": "74:ac:74:ac:74:ac",
diff --git a/server/__main__.py b/server/__main__.py
index d1454f37..8a3e9be4 100755
--- a/server/__main__.py
+++ b/server/__main__.py
@@ -168,7 +168,8 @@ def main ():
notificationObj = notification.create(final_json, "")
# run all enabled publisher gateways
- if notificationObj.HasNotifications:
+ if notificationObj.HasNotifications:
+
pluginsState = run_plugin_scripts(db, all_plugins, 'on_notification', pluginsState)
notification.setAllProcessed()
notification.clearPendingEmailFlag()
diff --git a/server/database.py b/server/database.py
index 2f98f7c0..69e0a5b5 100755
--- a/server/database.py
+++ b/server/database.py
@@ -381,10 +381,12 @@ class DB():
self.commitDB()
+
+
# -------------------------------------------------------------------------
# CurrentScan table setup
# -------------------------------------------------------------------------
-
+
# indicates, if CurrentScan table is available
self.sql.execute("DROP TABLE IF EXISTS CurrentScan;")
self.sql.execute(""" CREATE TABLE CurrentScan (
@@ -398,6 +400,33 @@ class DB():
);
""")
+ self.commitDB()
+
+ # -------------------------------------------------------------------------
+ # Create the LatestEventsPerMAC view
+ # -------------------------------------------------------------------------
+
+ # Dynamically generated language strings
+ self.sql.execute(""" CREATE VIEW IF NOT EXISTS LatestEventsPerMAC AS
+ WITH RankedEvents AS (
+ 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.*,
+ c.*
+ FROM RankedEvents AS e
+ LEFT JOIN Devices AS d ON e.eve_MAC = d.dev_MAC
+ INNER JOIN CurrentScan AS c ON e.eve_MAC = c.cur_MAC
+ WHERE e.row_num = 1;
+ """)
+
+ self.commitDB()
+
+
# Init the AppEvent database table
AppEvent_obj(self)
diff --git a/server/initialise.py b/server/initialise.py
index 08da788e..aaca54e3 100755
--- a/server/initialise.py
+++ b/server/initialise.py
@@ -137,7 +137,7 @@ def importConfigs (db, all_plugins):
conf.TIMEZONE = ccd('TIMEZONE', 'Europe/Berlin' , c_d, 'Time zone', 'text', '', 'General')
conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 250 , c_d, 'Keep history entries', 'integer', '', 'General')
conf.REPORT_DASHBOARD_URL = ccd('REPORT_DASHBOARD_URL', 'http://netalertx/' , c_d, 'NetAlertX URL', 'text', '', 'General')
- conf.UI_LANG = ccd('UI_LANG', 'English' , c_d, 'Language Interface', 'text.select', "['English', 'French', 'German', 'Norwegian', 'Russian', 'Spanish', 'Italian', 'Portuguese (Brazil)', 'Polish', 'Chinese (zh_cn)' ]", 'General')
+ conf.UI_LANG = ccd('UI_LANG', 'English' , c_d, 'Language Interface', 'text.select', "['English', 'French', 'German', 'Norwegian', 'Russian', 'Spanish', 'Italian (it_it)', 'Portuguese (pt_br)', 'Polish (pl_pl)', 'Chinese (zh_cn)' ]", 'General')
conf.UI_PRESENCE = ccd('UI_PRESENCE', ['online', 'offline', 'archived'] , c_d, 'Include in presence', 'text.multiselect', "['online', 'offline', 'archived']", 'General')
conf.UI_DEV_SECTIONS = ccd('UI_DEV_SECTIONS', [] , c_d, 'Show sections', 'text.multiselect', "['Tile Cards', 'Device Presence']", 'General')
conf.UI_MY_DEVICES = ccd('UI_MY_DEVICES', ['online', 'offline', 'archived', 'new', 'down'] , c_d, 'Include in My Devices', 'text.multiselect', "['online', 'offline', 'archived', 'new', 'down']", 'General')
diff --git a/server/networkscan.py b/server/networkscan.py
index 1c012ae8..fa51890f 100755
--- a/server/networkscan.py
+++ b/server/networkscan.py
@@ -75,7 +75,7 @@ def void_ghost_disconnections (db):
sql.execute("""UPDATE Events SET eve_PairEventRowid = Null,
eve_EventType ='VOIDED - ' || eve_EventType
WHERE eve_MAC != 'Internet'
- AND eve_EventType = 'Connected'
+ AND eve_EventType in ('Connected', 'Down Reconnected')
AND eve_DateTime = ?
AND eve_MAC IN (
SELECT Events.eve_MAC
@@ -131,12 +131,12 @@ def pair_sessions_events (db):
SET eve_PairEventRowid =
(SELECT ROWID
FROM Events AS EVE2
- WHERE EVE2.eve_EventType IN ('New Device', 'Connected',
+ WHERE EVE2.eve_EventType IN ('New Device', 'Connected', 'Down Reconnected',
'Device Down', 'Disconnected')
AND EVE2.eve_MAC = Events.eve_MAC
AND EVE2.eve_Datetime > Events.eve_DateTime
ORDER BY EVE2.eve_DateTime ASC LIMIT 1)
- WHERE eve_EventType IN ('New Device', 'Connected')
+ WHERE eve_EventType IN ('New Device', 'Connected', 'Down Reconnected')
AND eve_PairEventRowid IS NULL
""" )
@@ -189,15 +189,23 @@ def insert_events (db):
WHERE dev_MAC = cur_MAC
) """)
- # Check new connections
+ # Check new Connections or Down Reconnections
mylog('debug','[Events] - 2 - New Connections')
- sql.execute (f"""INSERT INTO Events (eve_MAC, eve_IP, eve_DateTime,
- eve_EventType, eve_AdditionalInfo,
- eve_PendingAlertEmail)
- SELECT cur_MAC, cur_IP, '{startTime}', 'Connected', '', dev_AlertEvents
- FROM Devices, CurrentScan
- WHERE dev_MAC = cur_MAC
- AND dev_PresentLastScan = 0 """)
+ 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}',
+ CASE
+ WHEN last_event.eve_EventType = 'Device Down' and last_event.eve_PendingAlertEmail = 0 THEN 'Down Reconnected'
+ ELSE 'Connected'
+ END,
+ '',
+ d.dev_AlertEvents
+ FROM LatestEventsPerMAC AS d
+ JOIN CurrentScan AS c ON d.dev_MAC = c.cur_MAC
+ LEFT JOIN LatestEventsPerMAC AS last_event ON d.dev_MAC = last_event.eve_MAC
+ WHERE d.dev_PresentLastScan = 0
+ """)
# Check disconnections
mylog('debug','[Events] - 3 - Disconnections')
diff --git a/server/notification.py b/server/notification.py
index 49c0c388..289fc406 100755
--- a/server/notification.py
+++ b/server/notification.py
@@ -255,20 +255,6 @@ class Notification_obj:
AND eve_DateTime < datetime('now', '-{get_setting_value('NTFPRCS_alert_down_time')} minutes', '{get_timezone_offset()}')
""")
- # Clear the pending email flag for reconnected devices
- self.db.sql.execute(f"""UPDATE Events_Devices
- SET eve_PendingAlertEmail = 0
- WHERE eve_MAC IN (
- SELECT down_events.eve_MAC
- FROM Events_Devices AS down_events
- INNER JOIN Events AS connected_events
- ON connected_events.eve_MAC = down_events.eve_MAC
- WHERE down_events.eve_EventType = 'Device Down'
- AND connected_events.eve_EventType = 'Connected'
- AND connected_events.eve_DateTime > down_events.eve_DateTime
- )
- AND eve_EventType = 'Device Down'
- """)
# clear plugin events
self.db.sql.execute ("DELETE FROM Plugins_Events")
diff --git a/server/reporting.py b/server/reporting.py
index c02be0cd..5b98eb7a 100755
--- a/server/reporting.py
+++ b/server/reporting.py
@@ -112,16 +112,11 @@ def get_notifications (db):
# Compose Reconnected Down Section
# - select only Devices, that were previously down and now are Connected
sqlQuery = f"""
- SELECT down_events.dev_Name, down_events.eve_MAC, down_events.dev_Vendor, down_events.eve_IP,
- down_events.eve_DateTime AS DownTime, connected_events.eve_DateTime AS ConnectedTime
- FROM Events_Devices AS down_events
- INNER JOIN Events AS connected_events
- ON connected_events.eve_MAC = down_events.eve_MAC
- WHERE down_events.eve_EventType = 'Device Down'
- AND connected_events.eve_EventType = 'Connected'
- AND connected_events.eve_DateTime > down_events.eve_DateTime
- AND down_events.eve_PendingAlertEmail = 1
- ORDER BY down_events.eve_DateTime;
+ SELECT dev_Name, eve_MAC, dev_Vendor, eve_IP, eve_DateTime, eve_EventType
+ FROM Events_Devices AS reconnected_devices
+ WHERE reconnected_devices.eve_EventType = 'Down Reconnected'
+ AND reconnected_devices.eve_PendingAlertEmail = 1
+ ORDER BY reconnected_devices.eve_DateTime;
"""
# Get the events as JSON
@@ -137,8 +132,7 @@ def get_notifications (db):
# Compose Events Section
sqlQuery = f"""SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
WHERE eve_PendingAlertEmail = 1
- AND eve_EventType IN ('Connected','Disconnected',
- 'IP Changed')
+ AND eve_EventType IN ('Connected', 'Down Reconnected', 'Disconnected','IP Changed')
{get_setting_value('NTFPRCS_event_condition').replace('{s-quote}',"'")}
ORDER BY eve_DateTime"""
|