diff --git a/Dockerfile b/Dockerfile index 8f766005..255f3294 100755 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ ENV USER=pi USER_ID=1000 USER_GID=1000 PORT=20211 RUN apt-get update \ && apt-get install --no-install-recommends tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools python3 iproute2 nmap python3-pip zip systemctl usbutils traceroute -y \ - && pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi \ + && pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi speedtest-cli \ && update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \ && apt-get clean autoclean \ && apt-get autoremove \ diff --git a/README.md b/README.md index 3d263faa..7197f33f 100755 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ _PiAlert combines several network and other scanning tools 🔍 with notificatio Setup a _kill switch ☠_ for your network via a smart plug with the available [Home Assistant](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/HOME_ASSISTANT.md) integration. Implement custom automations with the [CSV device Exports 📤](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins/csv_backup), [Webhooks](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/WEBHOOK_N8N.md), or [API endpoints](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md) features. -Extend the app if you want to create your own scanner and handle the results and notifications in PiAlert. Check available [Plugins & Instructions](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins). Looking forward to your contributions if you decide to share your work with the community ❤. +Extend the app if you want to create your own scanner and handle the results and notifications in PiAlert. Check available [Plugins & Instructions](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins). + +Looking forward to your contributions if you decide to share your work with the community ❤. | ![Main screen][main] | ![Screen 1][screen1] | ![Screen 5][screen5] | |----------------------|----------------------| ----------------------| diff --git a/front/plugins/README.md b/front/plugins/README.md index a0367fe8..31e05756 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -19,24 +19,25 @@ | | Yes | ARPSCAN | Script | 📚[arp_scan](/front/plugins/arp_scan/) | | | | CSVBCKP | Script | 📚[csv_backup](/front/plugins/csv_backup/) | | Yes* | | DBCLNP | Script | 📚[db_cleanup](/front/plugins/db_cleanup/) | -| | | DDNS | Script | 📚[ddns_update](/front/plugins/ddns_update/) | +| | | DDNS | Script | 📚[ddns_update](/front/plugins/ddns_update/) | | | Yes | DHCPLSS | Script | 📚[dhcp_leases](/front/plugins/dhcp_leases/) | | | | DHCPSRVS | Script | 📚[dhcp_servers](/front/plugins/dhcp_servers/) | | | Yes | INTRNT | Script | 📚[internet_ip](/front/plugins/internet_ip/) | | Yes | | NEWDEV | Template | 📚[newdev_template](/front/plugins/newdev_template/) | +| | | PHOLUS | Script | 📚[pholus_scan](/front/plugins/pholus_scan/) | | | | NMAP | Script | 📚[nmap_scan](/front/plugins/nmap_scan/) | | | Yes | PIHOLE | External SQLite DB | 📚[pihole_scan](/front/plugins/pihole_scan/) | | | | SETPWD | Script | 📚[set_password](/front/plugins/set_password/) | | | | SNMPDSC | Script | 📚[snmp_discovery](/front/plugins/snmp_discovery/) | -| | Yes* | UNDIS | Script | 📚[undiscoverables](/front/plugins/undiscoverables/) | +| | Yes** | UNDIS | Script | 📚[undiscoverables](/front/plugins/undiscoverables/) | | | Yes | UNFIMP | Script | 📚[unifi_import](/front/plugins/unifi_import/) | | | | VNDRPDT | Script | 📚[vendor_update](/front/plugins/vendor_update/) | | | | WEBMON | Script | 📚[website_monitor](/front/plugins/website_monitor/) | | N/A | | N/A | SQL query | N/A, but the External SQLite DB plugins work similar | -> \* The Undiscoverables plugin (`UNDIS`) inserts only user-specified dummy devices. -> + > \* The database cleanup plugin (`DBCLNP`) is not _required_ but the app will become unusable after a while if not executed. +> \** The Undiscoverables plugin (`UNDIS`) inserts only user-specified dummy devices. > [!NOTE] > You soft-disable plugins via Settings or completely ignore plugins by placing a `ignore_plugin` file into the plugin directory. The difference is that ignored plugins don't show up anywhere in the UI (Settings, Device details, Plugins pages). The app skips ignored plugins completely. Device-detecting plugins insert values into the `CurrentScan` database table. The plugins that are not required are safe to ignore, however it makes sense to have a least some device-detecting plugins (that insert entries into the `CurrentScan` table) enabled, such as ARPSCAN or PIHOLE. diff --git a/front/plugins/arp_scan/config.json b/front/plugins/arp_scan/config.json index eb70b30d..7f632ede 100755 --- a/front/plugins/arp_scan/config.json +++ b/front/plugins/arp_scan/config.json @@ -138,7 +138,7 @@ { "function": "RUN_SCHD", "type": "text", - "default_value":"*/3 * * * *", + "default_value":"*/5 * * * *", "options": [], "localized": ["name", "description"], "name" : [{ diff --git a/front/plugins/ddns_update/config.json b/front/plugins/ddns_update/config.json index 4c839ebf..958fe2bd 100755 --- a/front/plugins/ddns_update/config.json +++ b/front/plugins/ddns_update/config.json @@ -68,7 +68,7 @@ "function": "RUN", "events": ["run"], "type": "text.select", - "default_value": "schedule", + "default_value": "disabled", "options": [ "disabled", "once", diff --git a/front/plugins/internet_ip/config.json b/front/plugins/internet_ip/config.json index d78a44ba..1169ac09 100755 --- a/front/plugins/internet_ip/config.json +++ b/front/plugins/internet_ip/config.json @@ -151,7 +151,7 @@ "description": [ { "language_code": "en_us", - "string": "Only enabled if you select schedule in the INTRNT_RUN setting. Make sure you enter the schedule in the correct cron-like format (e.g. validate at crontab.guru). For example entering 0 4 * * * will run the scan after 4 am in the TIMEZONE you set above. Will be run NEXT time the time passes." + "string": "Only enabled if you select schedule in the INTRNT_RUN setting. Make sure you enter the schedule in the correct cron-like format (e.g. validate at crontab.guru). For example entering 0 4 * * * will run the scan after 4 am in the TIMEZONE you set above. Will be run NEXT time the time passes. It's recommended to use the same schedule interval for all plugins responsible for discovering new devices." }, { "language_code": "es_es", diff --git a/front/plugins/internet_speedtest/README.md b/front/plugins/internet_speedtest/README.md new file mode 100755 index 00000000..4aa78555 --- /dev/null +++ b/front/plugins/internet_speedtest/README.md @@ -0,0 +1,11 @@ +## Overview + +A simple plugin allowing for executing regular internet speed tests. + +### Usage + +- N/A + +### Notes + +- N/A \ No newline at end of file diff --git a/front/plugins/internet_speedtest/config.json b/front/plugins/internet_speedtest/config.json new file mode 100755 index 00000000..67c5d1d6 --- /dev/null +++ b/front/plugins/internet_speedtest/config.json @@ -0,0 +1,421 @@ +{ + "code_name": "internet_speedtest", + "unique_prefix": "INTRSPD", + "enabled": true, + "data_source": "script", + "show_ui": true, + "localized": ["display_name", "description", "icon"], + "display_name" : [{ + "language_code": "en_us", + "string" : "Internet speedtest" + }], + "icon":[{ + "language_code": "en_us", + "string" : "" + }], + "description": [{ + "language_code": "en_us", + "string" : "A plugin to perform a scheduled internet speedtest." + }], + "params" : [], + "database_column_definitions": + [ + { + "column": "Index", + "css_classes": "col-sm-2", + "show": false, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "N/A" + }, + { + "language_code": "es_es", + "string" : "N/A" + }] + }, + { + "column": "Plugin", + "css_classes": "col-sm-2", + "show": false, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "N/A" + }, + { + "language_code": "es_es", + "string" : "N/A" + }] + }, + { + "column": "Object_PrimaryID", + "css_classes": "col-sm-2", + "show": false, + "type": "url", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "N/A" + }] + }, + { + "column": "Object_SecondaryID", + "css_classes": "col-sm-2", + "show": false, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "N/A" + }, + { + "language_code": "es_es", + "string" : "N/A" + }] + }, + { + "column": "DateTimeCreated", + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "Test run on" + }] + }, + { + "column": "DateTimeChanged", + "css_classes": "col-sm-2", + "show": false, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "Changed" + }, + { + "language_code": "es_es", + "string" : "Cambiado" + }] + }, + { + "column": "Watched_Value1", + "css_classes": "col-sm-2", + "show": true, + "type": "threshold", + "default_value":"", + "options": [ + { + "maximum": 1, + "hexColor": "#D33115" + }, + { + "maximum": 5, + "hexColor": "#792D86" + }, + { + "maximum": 10, + "hexColor": "#7D862D" + }, + { + "maximum": 100, + "hexColor": "#05483C" + } + ], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "Download" + }] + }, + { + "column": "Watched_Value2", + "css_classes": "col-sm-2", + "show": true, + "type": "threshold", + "default_value":"", + "options": [ + { + "maximum": 1, + "hexColor": "#D33115" + }, + { + "maximum": 5, + "hexColor": "#792D86" + }, + { + "maximum": 10, + "hexColor": "#7D862D" + }, + { + "maximum": 100, + "hexColor": "#05483C" + } + ], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "Upload" + }] + }, + { + "column": "Watched_Value3", + "css_classes": "col-sm-2", + "show": false, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "N/A" + }, + { + "language_code": "es_es", + "string" : "N/A" + }] + }, + { + "column": "Watched_Value4", + "css_classes": "col-sm-2", + "show": false, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "N/A" + }, + { + "language_code": "es_es", + "string" : "N/A" + }] + }, + { + "column": "UserData", + "css_classes": "col-sm-2", + "show": false, + "type": "textbox_save", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "Comments" + }, + { + "language_code": "es_es", + "string" : "Comentarios" + }] + }, + { + "column": "Status", + "css_classes": "col-sm-1", + "show": false, + "type": "replace", + "default_value":"", + "options": [ + { + "equals": "watched-not-changed", + "replacement": "
" + }, + { + "equals": "watched-changed", + "replacement": "
" + }, + { + "equals": "new", + "replacement": "
" + }, + { + "equals": "missing-in-last-scan", + "replacement": "
" + } + ], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "Status" + }, + { + "language_code": "es_es", + "string" : "Estado" + }] + }, + { + "column": "Extra", + "css_classes": "col-sm-3", + "show": false, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code": "en_us", + "string" : "Extra" + }, + { + "language_code": "es_es", + "string" : "Extra" + }] + } + ], + "settings":[ + { + "function": "RUN", + "events": ["run"], + "type": "text.select", + "default_value":"disabled", + "options": ["disabled", "once", "schedule", "always_after_scan" ], + "localized": ["name", "description"], + "name" :[{ + "language_code": "en_us", + "string" : "When to run" + }, + { + "language_code": "es_es", + "string" : "Cuando ejecuta" + }], + "description": [{ + "language_code": "en_us", + "string" : "Enable a regular scan of your services. If you select schedule the scheduling settings from below are applied. If you select once the scan is run only once on start of the application (container) for the time specified in INTRSPD_RUN_TIMEOUT setting." + }, + { + "language_code": "es_es", + "string" : "Habilite un escaneo regular de sus servicios. Si selecciona schedule, se aplican las configuraciones de programación de abajo. Si selecciona once, el escaneo se ejecuta solo una vez al iniciar la aplicación (contenedor) durante el tiempo especificado en INTRSPD_RUN_TIMEOUT configuración." + }] + }, + { + "function": "CMD", + "type": "readonly", + "default_value":"python3 /home/pi/pialert/front/plugins/internet_speedtest/script.py", + "options": [], + "localized": ["name", "description"], + "name" : [{ + "language_code": "en_us", + "string" : "Command" + }, + { + "language_code": "es_es", + "string" : "Comando" + }], + "description": [{ + "language_code": "en_us", + "string" : "Command to run" + }, + { + "language_code": "es_es", + "string" : "Comando a ejecutar" + }] + }, + { + "function": "RUN_SCHD", + "type": "text", + "default_value":"*/30 * * * *", + "options": [], + "localized": ["name", "description"], + "name" : [{ + "language_code": "en_us", + "string" : "Schedule" + }, + { + "language_code": "es_es", + "string" : "Schedule" + }], + "description": [{ + "language_code": "en_us", + "string" : "Only enabled if you select schedule in the INTRSPD_RUN setting. Make sure you enter the schedule in the correct cron-like format (e.g. validate at crontab.guru). For example entering 0 4 * * * will run the scan after 4 am in the TIMEZONE you set above. Will be run NEXT time the time passes." + }, + { + "language_code": "es_es", + "string": "Solo habilitado si selecciona schedule en la configuración INTRSPD_RUN. Asegúrese de ingresar el schedule en el formato similar a cron correcto (por ejemplo, valide en crontab.guru). Por ejemplo, ingrese 0 4 * * * ejecutará el escaneo después de las 4 am en el TIMEZONE que configuró arriba . Se ejecutará la PRÓXIMA vez que pase el tiempo." + }] + }, + { + "function": "RUN_TIMEOUT", + "type": "integer", + "default_value":60, + "options": [], + "localized": ["name", "description"], + "name" : [{ + "language_code": "en_us", + "string" : "Run timeout" + }, + { + "language_code": "es_es", + "string" : "Tiempo de espera de ejecución" + }, + { + "language_code": "de_de", + "string" : "Wartezeit" + }], + "description": [{ + "language_code": "en_us", + "string" : "Maximum time in seconds to wait for the script to finish. If this time is exceeded the script is aborted." + }, + { + "language_code": "es_es", + "string" : "Tiempo máximo en segundos para esperar a que finalice el script. Si se supera este tiempo, el script se cancela." + }] + }, + { + "function": "WATCH", + "type": "text.multiselect", + "default_value":[], + "options": ["Watched_Value1","Watched_Value2","Watched_Value3","Watched_Value4"], + "localized": ["name", "description"], + "name" :[{ + "language_code": "en_us", + "string" : "Watched" + }, + { + "language_code": "es_es", + "string" : "Visto" + }], + "description":[{ + "language_code": "en_us", + "string" : "Send a notification if selected values change. Use CTRL + Click to select/deselect. " + }] + }, + { + "function": "REPORT_ON", + "type": "text.multiselect", + "default_value":[], + "options": ["new","watched-changed","watched-not-changed", "missing-in-last-scan"], + "localized": ["name", "description"], + "name" :[{ + "language_code": "en_us", + "string" : "Report on" + }, + { + "language_code": "es_es", + "string" : "Informar sobre" + }] , + "description":[{ + "language_code": "en_us", + "string" : "Send a notification only on these statuses. new means a new unique (unique combination of PrimaryId and SecondaryId) object was discovered. watched-changed means that selected Watched_ValueN columns changed." + }, + { + "language_code": "es_es", + "string" : "Envíe una notificación solo en estos estados. new significa que se descubrió un nuevo objeto único (combinación única de PrimaryId y SecondaryId). watched-changed significa que seleccionó Watched_ValueN Las columnas cambiaron." + }] + } + ] +} diff --git a/front/plugins/internet_speedtest/script.py b/front/plugins/internet_speedtest/script.py new file mode 100755 index 00000000..9df63aa2 --- /dev/null +++ b/front/plugins/internet_speedtest/script.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# Based on the work of https://github.com/leiweibau/Pi.Alert + +import argparse +import os +import pathlib +import sys +from datetime import datetime +import speedtest + +# Replace these paths with the actual paths to your Pi.Alert directories +sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/pialert"]) + +from plugin_helper import Plugin_Objects +from logger import mylog, append_line_to_file +from helper import timeNowTZ + +CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) +RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') + +def main(): + + mylog('verbose', ['[INTRSPD] In script']) + + parser = argparse.ArgumentParser(description='Speedtest Plugin for Pi.Alert') + values = parser.parse_args() + + plugin_objects = Plugin_Objects(RESULT_FILE) + speedtest_result = run_speedtest() + plugin_objects.add_object( + primaryId = 'Speedtest', + secondaryId = timeNowTZ(), + watched1 = speedtest_result['download_speed'], + watched2 = speedtest_result['upload_speed'], + watched3 = 'null', + watched4 = 'null', + extra = 'null', + foreignKey = 'null' + ) + plugin_objects.write_result_file() + +def run_speedtest(): + try: + st = speedtest.Speedtest() + st.get_best_server() + download_speed = round(st.download() / 10**6, 2) # Convert to Mbps + upload_speed = round(st.upload() / 10**6, 2) # Convert to Mbps + + return { + 'download_speed': download_speed, + 'upload_speed': upload_speed, + } + except Exception as e: + print(f"Error running speedtest: {str(e)}") + return { + 'download_speed': -1, + 'upload_speed': -1, + } + +if __name__ == '__main__': + sys.exit(main()) diff --git a/front/plugins/pholus_scan/config.json b/front/plugins/pholus_scan/config.json index 19fdc520..c839a86d 100755 --- a/front/plugins/pholus_scan/config.json +++ b/front/plugins/pholus_scan/config.json @@ -3,19 +3,22 @@ "unique_prefix": "PHOLUS", "enabled": true, "data_source": "script", - "mapped_to_table": "Pholus_Scan", + "mapped_to_table": "Pholus_Scan", "data_filters": [ { - "compare_column" : "Object_PrimaryID", - "compare_operator" : "==", - "compare_field_id": "txtMacFilter", - "compare_js_template": "'{value}'.toString()", - "compare_use_quotes": true + "compare_column": "Object_PrimaryID", + "compare_operator": "==", + "compare_field_id": "txtMacFilter", + "compare_js_template": "'{value}'.toString()", + "compare_use_quotes": true } ], "show_ui": true, - "localized": ["display_name", "description", "icon"], - + "localized": [ + "display_name", + "description", + "icon" + ], "display_name": [ { "language_code": "en_us", @@ -34,7 +37,7 @@ { "language_code": "es_es", "string": "" - } + } ], "description": [ { @@ -44,56 +47,70 @@ { "language_code": "es_es", "string": "Este plugin sirve para ejecutar un escaneo Pholus (descubrimiento de nombres) en la red local" - } + } ], - "params" : [ + "params": [ { - "name" : "subnets", - "type" : "setting", - "value" : "SCAN_SUBNETS", - "base64": true + "name": "subnets", + "type": "setting", + "value": "SCAN_SUBNETS", + "base64": true }, { - "name" : "timeout", - "type" : "setting", - "value" : "PHOLUS_RUN_TIMEOUT" - } - ], - + "name": "timeout", + "type": "setting", + "value": "PHOLUS_RUN_TIMEOUT" + } + ], "settings": [ { - "function": "RUN", - "type": "text.select", - "default_value":"schedule", - "options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"], - "localized": ["name", "description"], - "events": ["run"], - "name" :[ - { - "language_code":"en_us", - "string" : "When to run" - }, - { - "language_code":"es_es", - "string" : "Cuando ejecutar" - }], + "function": "RUN", + "type": "text.select", + "default_value": "on_new_device", + "options": [ + "disabled", + "once", + "schedule", + "always_after_scan", + "on_new_device" + ], + "localized": [ + "name", + "description" + ], + "events": [ + "run" + ], + "name": [ + { + "language_code": "en_us", + "string": "When to run" + }, + { + "language_code": "es_es", + "string": "Cuando ejecutar" + } + ], "description": [ { - "language_code":"en_us", - "string" : "Pholus is a sniffing tool to discover additional information about the devices on the network, including the device name. If enabled this will execute the scan before every network scan cycle until there are no (unknown) or (name not found) devices. Please be aware it can spam the network with unnecessary traffic. Depends on the SCAN_SUBNETS setting. For a scheduled or one-off scan, check the PHOLUS_RUN setting.Specify when your Name-discovery scan will run. Typical setting would be on_new_device or schedule and then you specify a cron-like schedule in the PHOLUS_RUN_SCHDsetting." - }, + "language_code": "en_us", + "string": "Pholus is a sniffing tool to discover additional information about the devices on the network, including the device name. If enabled this will execute the scan before every network scan cycle until there are no (unknown) or (name not found) devices. Please be aware it can spam the network with unnecessary traffic. Depends on the SCAN_SUBNETS setting. For a scheduled or one-off scan, check the PHOLUS_RUN setting.Specify when your Name-discovery scan will run. Typical setting would be on_new_device or schedule and then you specify a cron-like schedule in the PHOLUS_RUN_SCHDsetting." + }, { - "language_code":"es_es", - "string" : "Pholus es una herramienta de rastreo para descubrir información adicional sobre los dispositivos en la red, incluido el nombre del dispositivo. Si está habilitado, ejecutará el escaneo antes de cada ciclo de escaneo de red hasta que no haya dispositivos (unknown) o (name not found). Tenga en cuenta que puede enviar spam a la red con tráfico innecesario. Depende de la configuración de SCAN_SUBNETS. Para un análisis programado o único, verifique la configuración de PHOLUS_RUN." - } - ] - }, + "language_code": "es_es", + "string": "Pholus es una herramienta de rastreo para descubrir información adicional sobre los dispositivos en la red, incluido el nombre del dispositivo. Si está habilitado, ejecutará el escaneo antes de cada ciclo de escaneo de red hasta que no haya dispositivos (unknown) o (name not found). Tenga en cuenta que puede enviar spam a la red con tráfico innecesario. Depende de la configuración de SCAN_SUBNETS. Para un análisis programado o único, verifique la configuración de PHOLUS_RUN." + } + ] + }, { "function": "CMD", "type": "readonly", "default_value": "python3 /home/pi/pialert/front/plugins/pholus_scan/script.py userSubnets={subnets} timeoutSec={timeout}", "options": [], - "localized": ["name", "description"], + "localized": [ + "name", + "description" + ], "name": [ { "language_code": "en_us", @@ -102,7 +119,7 @@ { "language_code": "es_es", "string": "Comando" - } + } ], "description": [ { @@ -112,16 +129,18 @@ { "language_code": "es_es", "string": "Comando para ejecutar. Esto no debe ser cambiado" - } + } ] }, - { "function": "RUN_TIMEOUT", "type": "integer", "default_value": 300, "options": [], - "localized": ["name", "description"], + "localized": [ + "name", + "description" + ], "name": [ { "language_code": "en_us", @@ -130,7 +149,7 @@ { "language_code": "es_es", "string": "Tiempo límite de ejecución" - } + } ], "description": [ { @@ -140,95 +159,132 @@ { "language_code": "es_es", "string": "Tiempo de escaneo de red en segundos. El escaneo de Pholus siempre durará este tiempo. Cuanto más tiempo se ejecute, más nombres de dispositivos se podrán resolver. Se dividirá por el número de subredes." - } - ] - }, - { - "function": "RUN_SCHD", - "type": "text", - "default_value":"30 3 * * *", - "options": [], - "localized": ["name", "description"], - "name" : [{ - "language_code":"en_us", - "string" : "Schedule" - }, - { - "language_code":"es_es", - "string" : "Schedule" - }], - "description": [{ - "language_code":"en_us", - "string" : "Only enabled if you select schedule in the PHOLUS_RUN setting. Make sure you enter the schedule in the correct cron-like format (e.g. validate at crontab.guru). For example entering 30 3 * * * will run the scan at 3:30 am. Will be run NEXT time the time passes.
" - }, - { - "language_code":"es_es", - "string" : "Solo está habilitado si selecciona schedule en la configuración PHOLUS_RUN. Asegúrese de ingresar la programación en el formato cron correcto (por ejemplo, validar en crontab.guru). Por ejemplo, al ingresar 30 3 * * * se ejecutará el escaneo a las 3:30 am. Se ejecutará la PRÓXIMA vez que pase el tiempo.
" - }] - }, - { - "function": "DAYS_DATA", - "type": "integer", - "default_value":30, - "options": [], - "localized": ["name", "description"], - "name" : [{ - "language_code":"en_us", - "string" : "Schedule" - }, - { - "language_code":"es_es", - "string" : "Retención de datos" - }], - "description": [ - { - "language_code":"en_us", - "string" : "How many days of Pholus scan entries should be kept (globally, not device specific!) Enter 0 to disable." - }, - { - "language_code":"es_es", - "string" : "Cuántos días de entradas de escaneo de Pholus deben conservarse (globalmente, ¡no específico del dispositivo!). El archivo pialert_pholus.log no se modifica. Introduzca 0 para desactivar." } ] }, { - "function": "WATCH", - "type": "text.multiselect", - "default_value":["Watched_Value1", "Watched_Value2"], - "options": ["Watched_Value1","Watched_Value2","Watched_Value3","Watched_Value4"], - "localized": ["name", "description"], - "name" :[{ - "language_code":"en_us", - "string" : "Watched" + "function": "RUN_SCHD", + "type": "text", + "default_value": "30 3 * * *", + "options": [], + "localized": [ + "name", + "description" + ], + "name": [ + { + "language_code": "en_us", + "string": "Schedule" }, - { - "language_code":"es_es", - "string" : "Watched" - }] , - "description":[{ - "language_code":"en_us", - "string" : "Send a notification if selected values change. Use CTRL + Click to select/deselect. " + { + "language_code": "es_es", + "string": "Schedule" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Only enabled if you select schedule in the PHOLUS_RUN setting. Make sure you enter the schedule in the correct cron-like format (e.g. validate at crontab.guru). For example entering 30 3 * * * will run the scan at 3:30 am. Will be run NEXT time the time passes.
" }, - { - "language_code":"es_es", - "string" : "Enviar una notificación si los valores seleccionados cambian. Utilice CTRL + Clic para seleccionar/deseleccionar. " - }] + { + "language_code": "es_es", + "string": "Solo está habilitado si selecciona schedule en la configuración PHOLUS_RUN. Asegúrese de ingresar la programación en el formato cron correcto (por ejemplo, validar en crontab.guru). Por ejemplo, al ingresar 30 3 * * * se ejecutará el escaneo a las 3:30 am. Se ejecutará la PRÓXIMA vez que pase el tiempo.
" + } + ] + }, + { + "function": "DAYS_DATA", + "type": "integer", + "default_value": 30, + "options": [], + "localized": [ + "name", + "description" + ], + "name": [ + { + "language_code": "en_us", + "string": "Schedule" + }, + { + "language_code": "es_es", + "string": "Retención de datos" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "How many days of Pholus scan entries should be kept (globally, not device specific!) Enter 0 to disable." + }, + { + "language_code": "es_es", + "string": "Cuántos días de entradas de escaneo de Pholus deben conservarse (globalmente, ¡no específico del dispositivo!). El archivo pialert_pholus.log no se modifica. Introduzca 0 para desactivar." + } + ] + }, + { + "function": "WATCH", + "type": "text.multiselect", + "default_value": [ + "Watched_Value1", + "Watched_Value2" + ], + "options": [ + "Watched_Value1", + "Watched_Value2", + "Watched_Value3", + "Watched_Value4" + ], + "localized": [ + "name", + "description" + ], + "name": [ + { + "language_code": "en_us", + "string": "Watched" + }, + { + "language_code": "es_es", + "string": "Watched" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Send a notification if selected values change. Use CTRL + Click to select/deselect. " + }, + { + "language_code": "es_es", + "string": "Enviar una notificación si los valores seleccionados cambian. Utilice CTRL + Clic para seleccionar/deseleccionar. " + } + ] }, { "function": "REPORT_ON", "type": "text.multiselect", - "default_value": ["new"], - "options": ["new", "watched-changed", "watched-not-changed", "missing-in-last-scan"], - "localized": ["name", "description"], + "default_value": [ + "new" + ], + "options": [ + "new", + "watched-changed", + "watched-not-changed", + "missing-in-last-scan" + ], + "localized": [ + "name", + "description" + ], "name": [ { "language_code": "en_us", "string": "Report on" }, - { + { "language_code": "es_es", "string": "Informar sobre" - } + } ], "description": [ { @@ -238,173 +294,201 @@ { "language_code": "es_es", "string": "Cuándo debe enviarse una notificación." - } + } ] } ], - - "database_column_definitions": - [ + "database_column_definitions": [ { "column": "Object_PrimaryID", - "mapped_to_column": "MAC", + "mapped_to_column": "MAC", "css_classes": "col-sm-2", "show": true, - "type": "device_name_mac", - "default_value":"", + "type": "device_name_mac", + "default_value": "", "options": [], - "localized": ["name"], - "name":[{ - "language_code":"en_us", - "string" : "MAC" - }, - { - "language_code":"es_es", - "string" : "MAC" - }] - }, - { - "column": "Object_SecondaryID", - "mapped_to_column": "IP_v4_or_v6", - "css_classes": "col-sm-2", - "show": true, - "type": "label", - "default_value":"", - "options": [], - "localized": ["name"], - "name":[{ - "language_code":"en_us", - "string" : "IP" - }, - { - "language_code":"es_es", - "string" : "IP" - }] + "localized": [ + "name" + ], + "name": [ + { + "language_code": "en_us", + "string": "MAC" + }, + { + "language_code": "es_es", + "string": "MAC" + } + ] }, { - "column": "Watched_Value1", - "mapped_to_column": "Info", - "css_classes": "col-sm-2", - "show": true, - "type": "label", - "default_value":"", - "options": [], - "localized": ["name"], - "name":[{ - "language_code":"en_us", - "string" : "Info" - }, - { - "language_code":"es_es", - "string" : "Info" - }] - } , + "column": "Object_SecondaryID", + "mapped_to_column": "IP_v4_or_v6", + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value": "", + "options": [], + "localized": [ + "name" + ], + "name": [ + { + "language_code": "en_us", + "string": "IP" + }, + { + "language_code": "es_es", + "string": "IP" + } + ] + }, { - "column": "Watched_Value2", - "mapped_to_column": "Record_Type", - "css_classes": "col-sm-2", - "show": true, - "type": "label", - "default_value":"", - "options": [], - "localized": ["name"], - "name":[{ - "language_code":"en_us", - "string" : "Type" - }, - { - "language_code":"es_es", - "string" : "Tipo" - }] - } , + "column": "Watched_Value1", + "mapped_to_column": "Info", + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value": "", + "options": [], + "localized": [ + "name" + ], + "name": [ + { + "language_code": "en_us", + "string": "Info" + }, + { + "language_code": "es_es", + "string": "Info" + } + ] + }, { - "column": "Watched_Value3", - "mapped_to_column": "Value", - "css_classes": "col-sm-2", - "show": true, - "type": "label", - "default_value":"", - "options": [], - "localized": ["name"], - "name":[{ - "language_code":"en_us", - "string" : "Info" - }, - { - "language_code":"es_es", - "string" : "Info" - }] + "column": "Watched_Value2", + "mapped_to_column": "Record_Type", + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value": "", + "options": [], + "localized": [ + "name" + ], + "name": [ + { + "language_code": "en_us", + "string": "Type" + }, + { + "language_code": "es_es", + "string": "Tipo" + } + ] + }, + { + "column": "Watched_Value3", + "mapped_to_column": "Value", + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value": "", + "options": [], + "localized": [ + "name" + ], + "name": [ + { + "language_code": "en_us", + "string": "Info" + }, + { + "language_code": "es_es", + "string": "Info" + } + ] }, { "column": "DateTimeCreated", - "mapped_to_column": "Time", + "mapped_to_column": "Time", "css_classes": "col-sm-2", "show": true, - "type": "label", - "default_value":"", + "type": "label", + "default_value": "", "options": [], - "localized": ["name"], - "name":[{ - "language_code":"en_us", - "string" : "Created" - }, - { - "language_code":"es_es", - "string" : "Creado" - }] - }, + "localized": [ + "name" + ], + "name": [ + { + "language_code": "en_us", + "string": "Created" + }, + { + "language_code": "es_es", + "string": "Creado" + } + ] + }, { - "column": "DateTimeChanged", - "css_classes": "col-sm-2", - "show": true, - "type": "label", - "default_value":"", - "options": [], - "localized": ["name"], - "name":[ - { - "language_code":"en_us", - "string" : "Changed" - }, - { - "language_code":"es_es", - "string" : "Cambiado" - } - ] - }, + "column": "DateTimeChanged", + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value": "", + "options": [], + "localized": [ + "name" + ], + "name": [ + { + "language_code": "en_us", + "string": "Changed" + }, + { + "language_code": "es_es", + "string": "Cambiado" + } + ] + }, { - "column": "Status", - "css_classes": "col-sm-1", - "show": true, - "type": "replace", - "default_value":"", - "options": [ - { - "equals": "watched-not-changed", - "replacement": "
" - }, - { - "equals": "watched-changed", - "replacement": "
" - }, - { - "equals": "new", - "replacement": "
" - }, - { - "equals": "missing-in-last-scan", - "replacement": "
" - } - ], - "localized": ["name"], - "name":[{ - "language_code":"en_us", - "string" : "Status" - }, - { - "language_code":"es_es", - "string" : "Estado" - }] - } + "column": "Status", + "css_classes": "col-sm-1", + "show": true, + "type": "replace", + "default_value": "", + "options": [ + { + "equals": "watched-not-changed", + "replacement": "
" + }, + { + "equals": "watched-changed", + "replacement": "
" + }, + { + "equals": "new", + "replacement": "
" + }, + { + "equals": "missing-in-last-scan", + "replacement": "
" + } + ], + "localized": [ + "name" + ], + "name": [ + { + "language_code": "en_us", + "string": "Status" + }, + { + "language_code": "es_es", + "string": "Estado" + } + ] + } ] -} +} \ No newline at end of file diff --git a/front/pluginsCore.php b/front/pluginsCore.php index bb3b8cb6..e30f986f 100755 --- a/front/pluginsCore.php +++ b/front/pluginsCore.php @@ -131,7 +131,7 @@ function processColumnValue(dbColumnDef, value, index, type) { valueTmp = '' $.each(dbColumnDef.options, function(index, obj) { - if(Number(value) < obj.maximum && valueTmp == '') + if(Number(value) < Number(obj.maximum) && valueTmp == '') { valueTmp = `
${value}
` // return; diff --git a/install/install.sh b/install/install.sh index 4f88dd75..de590fb5 100755 --- a/install/install.sh +++ b/install/install.sh @@ -41,7 +41,7 @@ curl -sSL https://bootstrap.pypa.io/get-pip.py | python3 # --------------------------------------------------------------- # Install Python packages -pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi +pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi speedtest-cli # Update alternatives for Python update-alternatives --install /usr/bin/python python /usr/bin/python3 10 diff --git a/pialert/plugin_utils.py b/pialert/plugin_utils.py index 6ac61b24..2f050c8b 100755 --- a/pialert/plugin_utils.py +++ b/pialert/plugin_utils.py @@ -1,6 +1,7 @@ import os import json +import conf from logger import mylog from const import pluginsPath, logPath from helper import timeNowTZ, updateState, get_file_content, write_file, get_setting, get_setting_value @@ -215,9 +216,7 @@ def check_and_run_user_event(db, pluginsState): sql.execute ("UPDATE Parameters SET par_Value='finished' WHERE par_ID='Front_Event'") # commit to DB - db.commitDB() - - mylog('debug', [f'[MAIN] processScan3: {pluginsState.processScan}']) + db.commitDB() return pluginsState