From e9af2efbd15af3750b40620e7e46466d18d9c6f5 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sat, 20 May 2023 10:56:01 +1000 Subject: [PATCH 1/8] DOnt Awesome Pro docs --- docs/ICONS.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/ICONS.md b/docs/ICONS.md index 67b4cc0d..61ea561b 100755 --- a/docs/ICONS.md +++ b/docs/ICONS.md @@ -18,3 +18,13 @@ You can assign icons individually on each device in the Details tab. - If you want to mass-apply an icon to all devices of the same device type (Field marked (4) in the above screenshot), you can click the copy button (Marked (1) in the above screenshot). A confirmation prompt is displayed. If you proceed, icons of all devices set to the same device type as the current device, will be overwritten with the current device's icon. - The dropdown (3) contains all icons already used in the app for device icons. You need to navigate away or refresh the page once you add a new icon. + +## 🌟 Pro Font Awesome icons + +If you own the premium package of Font Awesome icons you can mount it in your Docker container the following way: + +```yaml +/font-awesome:/home/pi/pialert/front/lib/AdminLTE/bower_components/font-awesome:ro +``` + +You can use the full range of Font Awesome icons afterwards. From 298b5ac03e998282bad180278638076adde98d36 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sat, 20 May 2023 11:08:24 +1000 Subject: [PATCH 2/8] Attempt at fixing #228 --- back/pialert.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/back/pialert.py b/back/pialert.py index 0cc997b1..502cb62d 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -772,9 +772,8 @@ def check_internet_IP (): dns_IP = get_dynamic_DNS_IP() # Check Dynamic DNS IP - if dns_IP == "" : - mylog('info', [' Error retrieving Dynamic DNS IP']) - mylog('info', [' Exiting...']) + if dns_IP == "" or dns_IP == "0.0.0.0" : + mylog('info', [' Error retrieving Dynamic DNS IP']) mylog('info', [' ', dns_IP]) # Check DNS Change @@ -802,6 +801,11 @@ def get_internet_IP (): # Check result is an IP IP = check_IP_format (cmd_output) + + # Handle invalid response + if IP == '': + IP = '0.0.0.0' + return IP #------------------------------------------------------------------------------- @@ -822,6 +826,11 @@ def get_dynamic_DNS_IP (): # Check result is an IP IP = check_IP_format (dig_output) + + # Handle invalid response + if IP == '': + IP = '0.0.0.0' + return IP #------------------------------------------------------------------------------- From 13ff08641253a57dbdea0cce90b19eeb18357fdc Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sat, 20 May 2023 12:42:30 +1000 Subject: [PATCH 3/8] Setting select presence statuses #221 --- back/pialert.py | 1 + front/php/templates/graph.php | 44 +++++++++++++++++++++----- front/php/templates/language/en_us.php | 4 ++- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/back/pialert.py b/back/pialert.py index 502cb62d..904266ba 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -371,6 +371,7 @@ def importConfigs (): REPORT_DASHBOARD_URL = ccd('REPORT_DASHBOARD_URL', 'http://pi.alert/' , c_d, 'PiAlert URL', 'text', '', 'General') DIG_GET_IP_ARG = ccd('DIG_GET_IP_ARG', '-4 myip.opendns.com @resolver1.opendns.com' , c_d, 'DIG arguments', 'text', '', 'General') UI_LANG = ccd('UI_LANG', 'English' , c_d, 'Language Interface', 'selecttext', "['English', 'German', 'Spanish']", 'General') + UI_PRESENCE = ccd('UI_PRESENCE', ['online', 'offline', 'archived'] , c_d, 'Include in presence', 'multiselect', "['online', 'offline', 'archived']", 'General') # Email REPORT_MAIL = ccd('REPORT_MAIL', False , c_d, 'Enable email', 'boolean', '', 'Email', ['test']) diff --git a/front/php/templates/graph.php b/front/php/templates/graph.php index 5a87078b..55f5f1d4 100755 --- a/front/php/templates/graph.php +++ b/front/php/templates/graph.php @@ -8,15 +8,43 @@ $Pia_Graph_Device_Online = array(); $Pia_Graph_Device_Down = array(); $Pia_Graph_Device_Arch = array(); +$statusesToShow = "'online', 'offline', 'archived'"; + +$statQuery = $db->query("SELECT * FROM Settings WHERE Code_Name = 'UI_PRESENCE'"); + +while($r = $statQuery->fetchArray(SQLITE3_ASSOC)) +{ + $statusesToShow = $r['Value']; +} + $results = $db->query('SELECT * FROM Online_History ORDER BY Scan_Date DESC LIMIT 144'); -while ($row = $results->fetchArray()) { - $time_raw = explode(' ', $row['Scan_Date']); - $time = explode(':', $time_raw[1]); - array_push($Pia_Graph_Device_Time, $time[0].':'.$time[1]); - array_push($Pia_Graph_Device_Down, $row['Down_Devices']); - array_push($Pia_Graph_Device_All, $row['All_Devices']); - array_push($Pia_Graph_Device_Online, $row['Online_Devices']); - array_push($Pia_Graph_Device_Arch, $row['Archived_Devices']); + +while ($row = $results->fetchArray()) +{ + $time_raw = explode(' ', $row['Scan_Date']); + $time = explode(':', $time_raw[1]); + array_push($Pia_Graph_Device_Time, $time[0].':'.$time[1]); + + // Offline + if(strpos($statusesToShow, 'offline') !== false) + { + array_push($Pia_Graph_Device_Down, $row['Down_Devices']); + } + + // All + array_push($Pia_Graph_Device_All, $row['All_Devices']); + + // Online + if(strpos($statusesToShow, 'online') !== false) + { + array_push($Pia_Graph_Device_Online, $row['Online_Devices']); + } + + // Archived + if(strpos($statusesToShow, 'archived') !== false) + { + array_push($Pia_Graph_Device_Arch, $row['Archived_Devices']); + } } function pia_graph_devices_data($Pia_Graph_Array) { $Pia_Graph_Array_rev = array_reverse($Pia_Graph_Array); diff --git a/front/php/templates/language/en_us.php b/front/php/templates/language/en_us.php index eaad4a10..4228fa50 100755 --- a/front/php/templates/language/en_us.php +++ b/front/php/templates/language/en_us.php @@ -528,7 +528,7 @@ The arp-scan time itself depends on the number of IP addresses to check so set t 'PIALERT_WEB_PASSWORD_name' => 'Login password', 'PIALERT_WEB_PASSWORD_description' => 'The default password is 123456. To change the password run /home/pi/pialert/back/pialert-cli in the container', 'INCLUDED_SECTIONS_name' => 'Notify on', -'INCLUDED_SECTIONS_description' => 'Specifies which events trigger notifications. Remove the event type(s) you don\'t want to get notified on. This setting overrides device-specific settings in the UI. (CTRL + Click to select / deselect).', +'INCLUDED_SECTIONS_description' => 'Specifies which events trigger notifications. Remove the event type(s) you don\'t want to get notified on. This setting overrides device-specific settings in the UI. (CTRL + Click to select/deselect).', 'SCAN_CYCLE_MINUTES_name' => 'Scan cycle delay', 'SCAN_CYCLE_MINUTES_description' => 'The delay between scans in minutes. If using arp-scan, the scan time itself depends on the number of IP addresses to check. This is influenced by the network mask set in the SCAN_SUBNETS setting at the top. Every IP takes a couple seconds to scan.', 'DAYS_TO_KEEP_EVENTS_name' => 'Delete events older than', @@ -539,6 +539,8 @@ The arp-scan time itself depends on the number of IP addresses to check so set t 'DIG_GET_IP_ARG_description' => 'Change the dig utility arguments if you have issues resolving your Internet IP. Arguments are added at the end of the following command: dig +short .', 'UI_LANG_name' => 'UI Language', 'UI_LANG_description' => 'Select the preferred UI language.', +'UI_PRESENCE_name' => 'Show in presence chart', +'UI_PRESENCE_description' => 'Select what statuses should be shown in the Device presence over time chart in the Devices page. (CTRL + Click to select/deselect)', //Email 'Email_display_name' => 'Email', From 422997be9b3d656468d7edd94c081148a8d02984 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sat, 20 May 2023 13:33:45 +1000 Subject: [PATCH 4/8] php errors log --- front/maintenance.php | 21 +++++++++++++++++++-- front/plugins/nmap_services/config.json | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/front/maintenance.php b/front/maintenance.php index 7babe5d8..4b8105f4 100755 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -367,7 +367,24 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) { - + +
+
+ +
+
+
+
pialert.php_errors.log
+ +
+
+ +
+
+
+
+
@@ -705,7 +722,7 @@ function performLogManage() { // -------------------------------------------------------- function scrollDown() { - var areaIDs = ['pialert_log', 'pialert_front_log', 'IP_changes_log', 'stdout_log', 'stderr_log', 'pialert_pholus_log', 'pialert_pholus_lastrun_log']; + var areaIDs = ['pialert_log', 'pialert_front_log', 'IP_changes_log', 'stdout_log', 'stderr_log', 'pialert_pholus_log', 'pialert_pholus_lastrun_log', 'pialert_php_log']; for (let i = 0; i < areaIDs.length; i++) { diff --git a/front/plugins/nmap_services/config.json b/front/plugins/nmap_services/config.json index 725e3108..a31a1bf3 100755 --- a/front/plugins/nmap_services/config.json +++ b/front/plugins/nmap_services/config.json @@ -55,7 +55,7 @@ "localized": ["name"], "name":[{ "language_code":"en_us", - "string" : "Device name" + "string" : "Device MAC" }] }, { From c9eb866acd6188e97ccb39bbc41a3c3fbe5b4348 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sun, 21 May 2023 10:56:40 +1000 Subject: [PATCH 5/8] add DB --- .gitignore | 2 +- db/pialert.db | Bin 0 -> 180224 bytes docs/README.md | 2 +- front/plugins/undiscoverables/README.md | 0 front/plugins/undiscoverables/config.json | 0 front/plugins/undiscoverables/plugin_helper.py | 0 front/plugins/undiscoverables/script.py | 0 7 files changed, 2 insertions(+), 2 deletions(-) create mode 100755 db/pialert.db mode change 100644 => 100755 front/plugins/undiscoverables/README.md mode change 100644 => 100755 front/plugins/undiscoverables/config.json mode change 100644 => 100755 front/plugins/undiscoverables/plugin_helper.py mode change 100644 => 100755 front/plugins/undiscoverables/script.py diff --git a/.gitignore b/.gitignore index f908738e..76e8bc53 100755 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .vscode .DS_Store config/pialert.conf -db/* +# db/* front/log/* front/plugins/**/*.log **/%40eaDir/ diff --git a/db/pialert.db b/db/pialert.db new file mode 100755 index 0000000000000000000000000000000000000000..ff4e27315457b56f048e1ce792b7f6e37591bc93 GIT binary patch literal 180224 zcmeI5?{gc+dB<@g34qiO%Ce=ijL=$YCQlg+RaFnkE z?-<;XH0!3yN%17@w9`zco#{+F(;x5Bm+jlMFEZ0kr?2}LG7k}~)sHHrJFTv|(`t0u zdU3DQQ%mZO)=|xK#kF#wStgZQseFeFNRfJtxRN9rYOmaTDJjoqq>sbut+u6gDywdr zv+>$pp+V(tg|hWxO1_qnY&oR7&{O*s*IY7ob=SsAu{I*I1EwPN%GQ}Ui#N2sX%!7! zS38zw2#YVqT8zjJSd7#wTQ9^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MzVfO zW&9h*{x~IPGSUz3TI~;dsw?BZq+E^7!u4u7+zEsHG=eD&HvFsy4}Vc3a=jja^-t=1uCm zy4v^JEK+MRqMlXWhWDVkx8)n74SC&dRqq1ycO;xu{(k$O;x;C}GX%!7!S38zw z=%hq}H7hF&8mGv`s_lbHRaQN_EHFY%Y%m&D+tNC;h3K#V8|+b#g4e*O!2N4<+In%X z(^F~sHOouoH7`clyzhkD7vn*B$H5@Xawos@rv15;eC?X_-G@#xn&0fvV3^i+S2J3c zy1CWbuXrw$tV7ynCy0}UEPZRYR_5G8Cn*ERJmUfdfpiL#x``Ah@vP3YG<9Bf4Dmf)J1_^whrP#wJ?K5tQh88M3#bZLO(WYTHt~ zEcBjwny)p(($=*OO);9+0d=c=)uiEP-C}7Itg5NI+)l8tY7FY&BOjBRQ108WB;_j^ z>0xMW^i*+$<{PoYqbD^mLV7hy(>@V?tFH3tSmj(~Kr=5^?%6LV<@t>Cama0v zL9SvsRXQmm1P>_AT<^-3a<{M#6lk+ae@`C_cei0pvLNIf%oCB|gr z>~Kw_I(_k|@;24)+zW7ok>z0P61j?d)GAS=z9OjU(pq2OEXY6tNM9T5&zH>$J ztNeGfu3voa;+K1#Jn`&hi}w6>ySMGnDA>$F`Pe?5k_%IkeaT~Fs%EQ1N5rPKsrr}p zhH9F0Bs4D!5Q~>*1VtN?jhCV4`9w;dq1OEfF-dxT6HQ-@HODT11NvEEBtZ74J)V-6 zsDXTJ_ez@C@g^_ALU(m~kR;{DfLIe~)V;;_e61n+tQhp3-pd52`oZN=&o4>V~ED zdahwQk8!7^yspsgYHSA6?p5@4!=vMz`weT)U2d`K`}^B!e{WS= zHhOBSrdqp3f8(`K?4z=}uEToQBpKP~S2i`UQU{(p`>{txh;9J2rb literal 0 HcmV?d00001 diff --git a/docs/README.md b/docs/README.md index 40c6db2a..db845a9e 100755 --- a/docs/README.md +++ b/docs/README.md @@ -77,7 +77,7 @@ If you submit a PR please: 4. New features code should ideally be re-usable for different purposes, not be for a very narrow use-case. 5. New functionality should ideally be implemented via the Plugins system, if possible. -Soem additional context: +Some additional context: * Permanent settings/config is stored in the `pialert.conf` file * Currently temporary (session?) settings are stored in the `Parameters` DB table as key - value pairs. This table is wiped during a container rebuild/restart and it's values re-initialized from cookies / session data from the browser. diff --git a/front/plugins/undiscoverables/README.md b/front/plugins/undiscoverables/README.md old mode 100644 new mode 100755 diff --git a/front/plugins/undiscoverables/config.json b/front/plugins/undiscoverables/config.json old mode 100644 new mode 100755 diff --git a/front/plugins/undiscoverables/plugin_helper.py b/front/plugins/undiscoverables/plugin_helper.py old mode 100644 new mode 100755 diff --git a/front/plugins/undiscoverables/script.py b/front/plugins/undiscoverables/script.py old mode 100644 new mode 100755 From 3756e1a32712987d29ceda80e99965efaa317fb5 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sun, 21 May 2023 10:58:12 +1000 Subject: [PATCH 6/8] re-add DB dir to gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 76e8bc53..f908738e 100755 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .vscode .DS_Store config/pialert.conf -# db/* +db/* front/log/* front/plugins/**/*.log **/%40eaDir/ From 3831b5a50a387dc0575fa81d362e46256fecce0f Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sun, 21 May 2023 11:04:03 +1000 Subject: [PATCH 7/8] SUpport for unauthenticated SMTP #234 --- back/pialert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/pialert.py b/back/pialert.py index 904266ba..6dbee834 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -2552,7 +2552,7 @@ class noti_struc: def check_config(service): if service == 'email': - if SMTP_PASS == '' or SMTP_SERVER == '' or SMTP_USER == '' or REPORT_FROM == '' or REPORT_TO == '': + if SMTP_SERVER == '' or REPORT_FROM == '' or REPORT_TO == '': mylog('none', [' Error: Email service not set up correctly. Check your pialert.conf SMTP_*, REPORT_FROM and REPORT_TO variables.']) return False else: From 8a1e472fede96e96dbf60b155bbf0a14fa4da9a1 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sun, 21 May 2023 11:37:00 +1000 Subject: [PATCH 8/8] Established plugin_helper.py as best practice --- front/plugins/README.md | 11 +++++++++-- front/plugins/{undiscoverables => }/plugin_helper.py | 0 front/plugins/undiscoverables/script.py | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) rename front/plugins/{undiscoverables => }/plugin_helper.py (100%) diff --git a/front/plugins/README.md b/front/plugins/README.md index 6ebab224..a221d3ca 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -95,7 +95,11 @@ Any of the above datasources have to return a "table" of the exact structure as - You can find which "columns" need to be present, and if the value is required or optional, in the "Column order and values" section. - The order of these "columns" can't be changed. -#### Examples +### 👍 Python script.py tips + +The [Undicoverables plugins `script.py` file](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/undiscoverables/script.py) is a good and simple example to start with if you are considering creating a custom plugin. It uses the [`plugin_helper.py` library](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/plugin_helper.py) that significantly simplifies the creation of your custom script. + +#### last_result.log examples Valid CSV: @@ -122,7 +126,9 @@ https://www.google.com|null|2023-01-02 15:56:30|200|0.7898| ### "data_source": "pialert-db-query" -If the datasource is set to `pialert-db-query` the `CMD` setting needs to contain a SQL query rendering the columns as defined in the "Column order and values" section above. The order of columns is important. +If the datasource is set to `pialert-db-query` the `CMD` setting needs to contain a SQL query rendering the columns as defined in the "Column order and values" section above. The order of columns is important. + +This SQL query is executed on the `pialert.db` SQLite database file. #### Examples @@ -443,6 +449,7 @@ The UI will adjust how columns are displayed in the UI based on the definition o - [dhcp_leases (DHCPLSS) config.json](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/dhcp_leases/config.json) - [unifi_import (UNFIMP) config.json](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/unifi_import/config.json) - [snmp_discovery (SNMPDSC) config.json](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/snmp_discovery/config.json) +- [undiscoverables (UNDIS) config.json](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/undiscoverables/config.json) ### SQL query based plugins - [nmap_services (NMAPSERV) config.json](https://github.com/jokob-sk/Pi.Alert/blob/main/front/plugins/nmap_services/config.json) diff --git a/front/plugins/undiscoverables/plugin_helper.py b/front/plugins/plugin_helper.py similarity index 100% rename from front/plugins/undiscoverables/plugin_helper.py rename to front/plugins/plugin_helper.py diff --git a/front/plugins/undiscoverables/script.py b/front/plugins/undiscoverables/script.py index 7f17554d..ecfece0c 100755 --- a/front/plugins/undiscoverables/script.py +++ b/front/plugins/undiscoverables/script.py @@ -4,6 +4,9 @@ import os import pathlib import argparse +import sys + +sys.path.append("/home/pi/pialert/front/plugins") from plugin_helper import Plugin_Objects