diff --git a/db/pialert.db b/db/pialert.db new file mode 100755 index 00000000..ff4e2731 Binary files /dev/null and b/db/pialert.db differ 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. 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/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/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', 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/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" }] }, { diff --git a/front/plugins/undiscoverables/plugin_helper.py b/front/plugins/plugin_helper.py old mode 100644 new mode 100755 similarity index 100% rename from front/plugins/undiscoverables/plugin_helper.py rename to front/plugins/plugin_helper.py 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/script.py b/front/plugins/undiscoverables/script.py old mode 100644 new mode 100755 index 7f17554d..ecfece0c --- 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 diff --git a/pialert/pialert.py b/pialert/pialert.py index f6a80896..dc2215a2 100755 --- a/pialert/pialert.py +++ b/pialert/pialert.py @@ -192,6 +192,7 @@ def importConfigs (db): 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']) @@ -597,9 +598,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 @@ -627,6 +627,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 #------------------------------------------------------------------------------- @@ -647,6 +652,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 #------------------------------------------------------------------------------- @@ -2367,7 +2377,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: