Rename work 🏗

This commit is contained in:
jokob-sk
2024-04-12 19:44:29 +10:00
parent b003df323d
commit 5cb7553ed5
151 changed files with 2070 additions and 1735 deletions

View File

@@ -74,7 +74,7 @@ Example use cases for plugins could be:
* Creating a script to create FAKE devices based on user input via custom settings
* ...at this point the limitation is mostly the creativity rather than the capability (there might be edge cases and a need to support more form controls for user input off custom settings, but you probably get the idea)
If you wish to develop a plugin, please check the existing plugin structure. Once the settings are saved by the user they need to be removed from the `pialert.conf` file manually if you want to re-initialize them from the `config.json` of the plugin.
If you wish to develop a plugin, please check the existing plugin structure. Once the settings are saved by the user they need to be removed from the `app.conf` file manually if you want to re-initialize them from the `config.json` of the plugin.
Again, please read the below carefully if you'd like to contribute with a plugin yourself. This documentation file might be outdated, so double-check the sample plugins as well.
@@ -141,16 +141,16 @@ Currently, these data sources are supported (valid `data_source` value).
| Name | `data_source` value | Needs to return a "table"* | Overview (more details on this page below) |
|----------------------|----------------------|----------------------|----------------------|
| Script | `script` | no | Executes any linux command in the `CMD` setting. |
| NetAlertX DB query | `pialert-db-query` | yes | Executes a SQL query on the NetAlertX database in the `CMD` setting. |
| NetAlertX DB query | `app-db-query` | yes | Executes a SQL query on the NetAlertX database in the `CMD` setting. |
| Template | `template` | no | Used to generate internal settings, such as default values. |
| External SQLite DB query | `sqlite-db-query` | yes | Executes a SQL query from the `CMD` setting on an external SQLite database mapped in the `DB_PATH` setting. |
| Plugin type | `plugin_type` | no | Specifies the type of the plugin and in which section the Plugin settings are displayed ( one of `general/system/scanner/other/publisher` ). |
> * "Needs to return a "table" means that the application expects a `last_result.log` file with some results. It's not a blocker, however warnings in the `pialert.log` might be logged.
> * "Needs to return a "table" means that the application expects a `last_result.log` file with some results. It's not a blocker, however warnings in the `app.log` might be logged.
> 🔎Example
>```json
>"data_source": "pialert-db-query"
>"data_source": "app-db-query"
>```
If you want to display plugin objects or import devices into the app, data sources have to return a "table" of the exact structure as outlined above.
@@ -202,11 +202,11 @@ https://www.google.com|null|2023-01-02 15:56:30|200|0.7898|
```
### "data_source": "pialert-db-query"
### "data_source": "app-db-query"
If the `data_source` 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 `data_source` is set to `app-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.
This SQL query is executed on the `app.db` SQLite database file.
> 🔎Example
>
@@ -281,7 +281,7 @@ For example for `PIHOLE` (`"unique_prefix": "PIHOLE"`) it is `EXTERNAL_PIHOLE.`.
> ...
>```
The actual SQL query you want to execute is then stored as a `CMD` setting, similar to a Plugin of the `pialert-db-query` plugin type. The format has to adhere to the format outlined in the "Column order and values" section above.
The actual SQL query you want to execute is then stored as a `CMD` setting, similar to a Plugin of the `app-db-query` plugin type. The format has to adhere to the format outlined in the "Column order and values" section above.
> 🔎Example
>
@@ -448,7 +448,7 @@ The `params` array in the `config.json` is used to enable the user to change the
> Passing user-defined settings to a command. Let's say, you want to have a script, that is called with a user-defined parameter called `urls`:
>
> ```bash
> root@server# python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls=https://google.com,https://duck.com
> root@server# python3 /app/front/plugins/website_monitor/script.py urls=https://google.com,https://duck.com
> ```
* You can allow the user to add URLs to a setting with the `function` property set to a custom name, such as `urls_to_check` (this is not a reserved name from the section "Supported settings `function` values" below).
@@ -469,7 +469,7 @@ The `params` array in the `config.json` is used to enable the user to change the
{
"function": "CMD",
"type": "text",
"default_value":"python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls={urls}",
"default_value":"python3 /app/front/plugins/website_monitor/script.py urls={urls}",
"options": [],
"localized": ["name", "description"],
"name" : [{
@@ -483,7 +483,7 @@ The `params` array in the `config.json` is used to enable the user to change the
}
```
During script execution, the app will take the command `"python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls={urls}"`, take the `{urls}` wildcard and replace it with the value from the `WEBMON_urls_to_check` setting. This is because:
During script execution, the app will take the command `"python3 /app/front/plugins/website_monitor/script.py urls={urls}"`, take the `{urls}` wildcard and replace it with the value from the `WEBMON_urls_to_check` setting. This is because:
1. The app checks the `params` entries
2. It finds `"name" : "urls"`
@@ -495,9 +495,9 @@ During script execution, the app will take the command `"python3 /home/pi/pialer
- let's say the setting with the code name `WEBMON_urls_to_check` contains 2 values entered by the user:
- `WEBMON_urls_to_check=['https://google.com','https://duck.com']`
6. The app takes the value from `WEBMON_urls_to_check` and replaces the `{urls}` wildcard in the setting where `"function":"CMD"`, so you go from:
- `python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls={urls}`
- `python3 /app/front/plugins/website_monitor/script.py urls={urls}`
- to
- `python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls=https://google.com,https://duck.com`
- `python3 /app/front/plugins/website_monitor/script.py urls=https://google.com,https://duck.com`
Below are some general additional notes, when defining `params`:
@@ -586,7 +586,7 @@ You can have any `"function": "my_custom_name"` custom name, however, the ones l
| | - "always_after_scan" - run always after a scan is finished |
| | - "before_name_updates" - run before device names are updated (for name discovery plugins) |
| | - "on_new_device" - run when a new device is detected |
| | - "before_config_save" - run before the config is marked as saved. Useful if your plugin needs to modify the `pialert.conf` file. |
| | - "before_config_save" - run before the config is marked as saved. Useful if your plugin needs to modify the `app.conf` file. |
| `RUN_SCHD` | (required if you include "schedule" in the above `RUN` function) Cron-like scheduling is used if the `RUN` setting is set to `schedule`. |
| `CMD` | (required) Specifies the command that should be executed. |
| `API_SQL` | (not implemented) Generates a `table_` + `code_name` + `.json` file as per [API docs](https://github.com/jokob-sk/NetAlertX/blob/main/docs/API.md). |

View File

@@ -9,7 +9,8 @@ import sys
from datetime import datetime
# Register NetAlertX directories
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
import conf
from const import confFileName

View File

@@ -287,7 +287,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value":"python3 /home/pi/pialert/front/plugins/_publisher_apprise/apprise.py",
"default_value":"python3 /app/front/plugins/_publisher_apprise/apprise.py",
"options": [],
"localized": ["name", "description"],
"name" : [{

View File

@@ -354,7 +354,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/_publisher_email/email_smtp.py",
"default_value": "python3 /app/front/plugins/_publisher_email/email_smtp.py",
"options": [],
"localized": [
"name",

View File

@@ -15,7 +15,9 @@ import smtplib
import socket
import ssl
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
# NetAlertX modules
import conf
@@ -93,7 +95,7 @@ def send(pHTML, pText):
mylog('debug', [f'[{pluginName}] SMTP_REPORT_TO: {hide_email(str(get_setting_value("SMTP_REPORT_TO")))} SMTP_USER: {hide_email(str(get_setting_value("SMTP_USER")))}'])
subject, from_email, to_email, message_html, message_text = sanitize_email_content('NetAlertX Report', get_setting_value("SMTP_REPORT_FROM"), get_setting_value("SMTP_REPORT_TO"), pHTML, pText)
subject, from_email, to_email, message_html, message_text = sanitize_email_content('Net AlertX Report', get_setting_value("SMTP_REPORT_FROM"), get_setting_value("SMTP_REPORT_TO"), pHTML, pText)
# Compose email
msg = MIMEMultipart('alternative')

View File

@@ -278,7 +278,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value":"python3 /home/pi/pialert/front/plugins/_publisher_mqtt/mqtt.py devices={devices}",
"default_value":"python3 /app/front/plugins/_publisher_mqtt/mqtt.py devices={devices}",
"options": [],
"localized": ["name", "description"],
"name" : [{

View File

@@ -16,7 +16,8 @@ import hashlib
# Register NetAlertX directories
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
# NetAlertX modules
import conf
@@ -172,8 +173,8 @@ def publish_mqtt(mqtt_client, topic, message):
#-------------------------------------------------------------------------------
def create_generic_device(mqtt_client):
deviceName = 'PiAlert'
deviceId = 'pialert'
deviceName = 'NetAlertX'
deviceId = 'netalertx'
create_sensor(mqtt_client, deviceId, deviceName, 'sensor', 'online', 'wifi-check')
create_sensor(mqtt_client, deviceId, deviceName, 'sensor', 'down', 'wifi-cancel')
@@ -214,7 +215,7 @@ def publish_sensor(mqtt_client, sensorConfig):
"device":
{
"identifiers" : [sensorConfig.deviceId+"_sensor"],
"manufacturer" : "PiAlert",
"manufacturer" : "NetAlertX",
"name" : sensorConfig.deviceName
},
"icon": icon
@@ -288,7 +289,7 @@ def mqtt_start(db):
row = get_device_stats(db)
# Publish (wrap into {} and remove last ',' from above)
publish_mqtt(mqtt_client, "system-sensors/sensor/pialert/state",
publish_mqtt(mqtt_client, "system-sensors/sensor/netalertx/state",
{
"online": row[0],
"down": row[1],

View File

@@ -247,7 +247,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value":"python3 /home/pi/pialert/front/plugins/_publisher_ntfy/ntfy.py",
"default_value":"python3 /app/front/plugins/_publisher_ntfy/ntfy.py",
"options": [],
"localized": ["name", "description"],
"name" : [{

View File

@@ -12,7 +12,8 @@ from datetime import datetime
from base64 import b64encode
# Register NetAlertX directories
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
import conf
from const import confFileName

View File

@@ -304,7 +304,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/_publisher_pushover/pushover.py",
"default_value": "python3 /app/front/plugins/_publisher_pushover/pushover.py",
"options": [],
"localized": [
"name",

View File

@@ -6,7 +6,8 @@ import json
import requests
# Register NetAlertX directories
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Objects, handleEmpty # noqa: E402
from logger import mylog # noqa: E402

View File

@@ -247,7 +247,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value":"python3 /home/pi/pialert/front/plugins/_publisher_pushsafer/pushsafer.py",
"default_value":"python3 /app/front/plugins/_publisher_pushsafer/pushsafer.py",
"options": [],
"localized": ["name", "description"],
"name" : [{

View File

@@ -12,7 +12,8 @@ from datetime import datetime
from base64 import b64encode
# Register NetAlertX directories
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
import conf
from const import confFileName

View File

@@ -247,7 +247,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value":"python3 /home/pi/pialert/front/plugins/_publisher_webhook/webhook.py",
"default_value":"python3 /app/front/plugins/_publisher_webhook/webhook.py",
"options": [],
"localized": ["name", "description"],
"name" : [{

View File

@@ -14,7 +14,8 @@ import hashlib
import hmac
# Register NetAlertX directories
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
import conf

View File

@@ -121,7 +121,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/arp_scan/script.py userSubnets={subnets}",
"default_value": "python3 /app/front/plugins/arp_scan/script.py userSubnets={subnets}",
"options": [],
"localized": [
"name",

View File

@@ -9,10 +9,10 @@ import base64
import subprocess
from time import strftime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
# Register NetAlertX modules NetAlertX directories
from database import DB
from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty
from logger import mylog, append_line_to_file

View File

@@ -89,7 +89,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/csv_backup/script.py overwrite={overwrite} location={location}",
"default_value": "python3 /app/front/plugins/csv_backup/script.py overwrite={overwrite} location={location}",
"options": [],
"localized": ["name", "description"],
"name": [
@@ -221,7 +221,7 @@
{
"function": "location",
"type": "text",
"default_value":"/home/pi/pialert/config",
"default_value":"/app/config",
"options": [],
"localized": ["name", "description"],
"name" : [{
@@ -238,15 +238,15 @@
}],
"description": [{
"language_code":"en_us",
"string" : "Where the <code>devices.csv</code> file should be saved. For example <code>/home/pi/pialert/config</code>."
"string" : "Where the <code>devices.csv</code> file should be saved. For example <code>/app/config</code>."
},
{
"language_code":"es_es",
"string" : "Donde se debe guardar el archivo <code>devices.csv</code>. Por ejemplo <code>/home/pi/pialert/config</code>."
"string" : "Donde se debe guardar el archivo <code>devices.csv</code>. Por ejemplo <code>/app/config</code>."
},
{
"language_code":"de_de",
"string" : "Wo die Datei <code>devices.csv</code> gespeichert werden soll. Zum Beispiel <code>/home/pi/pialert/config</code>."
"string" : "Wo die Datei <code>devices.csv</code> gespeichert werden soll. Zum Beispiel <code>/app/config</code>."
}]
}
],

View File

@@ -10,8 +10,9 @@ import sqlite3
from io import StringIO
from datetime import datetime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, append_line_to_file

View File

@@ -75,7 +75,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/db_cleanup/script.py pluginskeephistory={pluginskeephistory} hourstokeepnewdevice={hourstokeepnewdevice} daystokeepevents={daystokeepevents} pholuskeepdays={pholuskeepdays}",
"default_value": "python3 /app/front/plugins/db_cleanup/script.py pluginskeephistory={pluginskeephistory} hourstokeepnewdevice={hourstokeepnewdevice} daystokeepevents={daystokeepevents} pholuskeepdays={pholuskeepdays}",
"options": [],
"localized": ["name", "description"],
"name": [

View File

@@ -10,8 +10,9 @@ import sqlite3
from io import StringIO
from datetime import datetime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, append_line_to_file

View File

@@ -122,7 +122,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/ddns_update/script.py prev_ip={prev_ip} DDNS_UPDATE_URL={DDNS_UPDATE_URL} DDNS_USER={DDNS_USER} DDNS_PASSWORD={DDNS_PASSWORD} DDNS_DOMAIN={DDNS_DOMAIN} ",
"default_value": "python3 /app/front/plugins/ddns_update/script.py prev_ip={prev_ip} DDNS_UPDATE_URL={DDNS_UPDATE_URL} DDNS_USER={DDNS_USER} DDNS_PASSWORD={DDNS_PASSWORD} DDNS_DOMAIN={DDNS_DOMAIN} ",
"options": [],
"localized": [
"name",

View File

@@ -13,8 +13,9 @@ import sqlite3
from io import StringIO
from datetime import datetime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, append_line_to_file

View File

@@ -493,7 +493,7 @@
{
"function": "CMD",
"type": "text",
"default_value": "python3 /home/pi/pialert/front/plugins/dhcp_leases/script.py paths={paths}",
"default_value": "python3 /app/front/plugins/dhcp_leases/script.py paths={paths}",
"options": [],
"localized": [
"name",

View File

@@ -8,8 +8,9 @@ import os
import sys
import chardet
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty, is_mac
from logger import mylog

View File

@@ -300,7 +300,7 @@
{
"function": "CMD",
"type": "text",
"default_value":"python3 /home/pi/pialert/front/plugins/dhcp_servers/script.py",
"default_value":"python3 /app/front/plugins/dhcp_servers/script.py",
"options": [],
"localized": ["name", "description"],
"name" : [{

View File

@@ -6,8 +6,9 @@ from datetime import datetime
import sys
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Objects, Plugin_Object
from logger import mylog

View File

@@ -109,7 +109,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/internet_ip/script.py prev_ip={prev_ip} INTRNT_DIG_GET_IP_ARG={INTRNT_DIG_GET_IP_ARG}",
"default_value": "python3 /app/front/plugins/internet_ip/script.py prev_ip={prev_ip} INTRNT_DIG_GET_IP_ARG={INTRNT_DIG_GET_IP_ARG}",
"options": [],
"localized": [
"name",

View File

@@ -13,8 +13,9 @@ import sqlite3
from io import StringIO
from datetime import datetime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, append_line_to_file

View File

@@ -449,7 +449,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/internet_speedtest/script.py",
"default_value": "python3 /app/front/plugins/internet_speedtest/script.py",
"options": [],
"localized": [
"name",

View File

@@ -8,7 +8,8 @@ from datetime import datetime
import speedtest
# Register NetAlertX directories
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Objects
from logger import mylog, append_line_to_file

View File

@@ -2,7 +2,7 @@
A plugin responsible for general maintenance tasks. These currently include:
- pialert.log cleanup
- app.log cleanup
### Usage

View File

@@ -54,7 +54,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/maintenance/maintenance.py",
"default_value": "python3 /app/front/plugins/maintenance/maintenance.py",
"options": [],
"localized": ["name", "description"],
"name": [
@@ -164,7 +164,7 @@
}],
"description": [{
"language_code":"en_us",
"string" : "How many last <code>pialert.log</code> lines to keep. If <code>LOG_LEVEL</code> is set to <code>debug</code> the app generates about 10000 lines per hour, so when debugging an issue the recommended setting should cover the bug occurence timeframe. For example for a bug with a 3 day periodical appearence the value <code>1000000</code> should be sufficient. Setting this value to <code>1000000</code> generates approximatelly a 50MB <code>pialert.log</code> file. Set to <code>0</code> to disable log purging."
"string" : "How many last <code>app.log</code> lines to keep. If <code>LOG_LEVEL</code> is set to <code>debug</code> the app generates about 10000 lines per hour, so when debugging an issue the recommended setting should cover the bug occurence timeframe. For example for a bug with a 3 day periodical appearence the value <code>1000000</code> should be sufficient. Setting this value to <code>1000000</code> generates approximatelly a 50MB <code>app.log</code> file. Set to <code>0</code> to disable log purging."
}]
}
],

View File

@@ -11,9 +11,10 @@ from io import StringIO
from datetime import datetime
from collections import deque
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
# Register NetAlertX modules NetAlertX directories
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, append_line_to_file
from helper import timeNowTZ, get_setting_value
@@ -37,7 +38,7 @@ def main():
mylog('verbose', [f'[{pluginName}] Cleaning file'])
logFile = logPath + "/pialert.log"
logFile = logPath + "/app.log"
# Using a deque to efficiently keep the last N lines
lines_to_keep = deque(maxlen=MAINT_LOG_LENGTH)

View File

@@ -345,7 +345,7 @@
{
"function": "CMD",
"type": "text",
"default_value":"python3 /home/pi/pialert/front/plugins/nmap_scan/script.py ips={ips} macs={macs} timeout={timeout} args={args}",
"default_value":"python3 /app/front/plugins/nmap_scan/script.py ips={ips} macs={macs} timeout={timeout} args={args}",
"options": [],
"localized": ["name", "description"],
"name" : [{

View File

@@ -9,8 +9,9 @@ import base64
import subprocess
from time import strftime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, append_line_to_file
@@ -133,7 +134,7 @@ def performNmapScan(deviceIPs, deviceMACs, timeoutSec, args):
# regular logging
for line in newLines:
append_line_to_file (logPath + '/pialert_nmap.log', line +'\n')
append_line_to_file (logPath + '/app_nmap.log', line +'\n')
index = 0

View File

@@ -60,7 +60,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/nslookup_scan/nslookup.py",
"default_value": "python3 /app/front/plugins/nslookup_scan/nslookup.py",
"options": [],
"localized": ["name", "description"],
"name": [

View File

@@ -14,8 +14,9 @@ import re
from io import StringIO
from datetime import datetime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, append_line_to_file

View File

@@ -106,7 +106,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/pholus_scan/script.py userSubnets={subnets} timeoutSec={timeout}",
"default_value": "python3 /app/front/plugins/pholus_scan/script.py userSubnets={subnets} timeoutSec={timeout}",
"options": [],
"localized": [
"name",
@@ -219,7 +219,7 @@
},
{
"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 <a href=\"/maintenance.php#tab_Logging\">pialert_pholus.log</a> no se modifica. Introduzca <code>0</code> para desactivar."
"string": "Cuántos días de entradas de escaneo de Pholus deben conservarse (globalmente, ¡no específico del dispositivo!). Introduzca <code>0</code> para desactivar."
}
]
},

View File

@@ -18,7 +18,7 @@ from scapy.utils import PcapWriter
sys.setrecursionlimit(30000)
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)#supress Scapy warnings`
logPath = '/home/pi/pialert/front/log'
logPath = '/app/front/log'
# DEBUG
isDebug = False
@@ -43,13 +43,13 @@ def write_file (pPath, pText):
file.close()
# Empty the last run log file
write_file(logPath + "/pialert_pholus_lastrun.log", "")
write_file(logPath + "/pholus_lastrun.log", "")
def file_print(*args):
result = ''
file = open(logPath + "/pialert_pholus_lastrun.log", "a")
file = open(logPath + "/pholus_lastrun.log", "a")
for arg in args:
result += str(arg)
print(result)
@@ -57,7 +57,7 @@ def file_print(*args):
file.close()
# Empty the last run log file
write_file(logPath + "/pialert_pholus_subp_pr.log", "")
write_file(logPath + "/pholus_subp_pr.log", "")
# For separate logging of the multiprocess subprocess
def file_print_pr(*args):
@@ -66,7 +66,7 @@ def file_print_pr(*args):
result = ''
file = open(logPath + "/pialert_pholus_subp_pr.log", "a")
file = open(logPath + "/pholus_subp_pr.log", "a")
for arg in args:
result += str(arg)
print(result)

View File

@@ -10,8 +10,9 @@ import subprocess
from time import strftime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from logger import mylog
from plugin_helper import Plugin_Object, Plugin_Objects
@@ -135,7 +136,7 @@ def execute_pholus_on_interface(interface, timeoutSec, mask):
# the scan always lasts 2x as long, so the desired user time from settings needs to be halved
adjustedTimeout = str(round(int(timeoutSec) / 2, 0))
# python3 -m trace --trace /home/pi/pialert/pholus/pholus3.py eth1 -rdns_scanning 192.168.1.0/24 -stimeout 600
# python3 -m trace --trace /app/pholus/pholus3.py eth1 -rdns_scanning 192.168.1.0/24 -stimeout 600
pholus_args = ['python3', fullPholusPath, interface, "-rdns_scanning", mask, "-stimeout", adjustedTimeout]
# Execute command
@@ -157,7 +158,7 @@ def execute_pholus_on_interface(interface, timeoutSec, mask):
mylog('verbose', [f'[{pluginName}] Scan: Pholus SUCCESS'])
# check the last run output
f = open(logPath + '/pialert_pholus_lastrun.log', 'r+')
f = open(logPath + '/pholus_lastrun.log', 'r+')
newLines = f.read().split('\n')
f.close()

View File

@@ -5,8 +5,10 @@ import re
import base64
from datetime import datetime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
INSTALL_PATH = "/app"
sys.path.append(f"{INSTALL_PATH}/front/plugins")
sys.path.append(f'{INSTALL_PATH}/server')
from logger import mylog
from const import confFileName
@@ -18,7 +20,7 @@ def read_config_file():
config_dir[key]
"""
filename = '/home/pi/pialert/config/' + confFileName
filename = f'{INSTALL_PATH}/config/' + confFileName
print('[plugin_helper] reading config file')
@@ -31,8 +33,8 @@ def read_config_file():
return confDict
pialertConfigFile = read_config_file()
timeZoneSetting = pialertConfigFile['TIMEZONE']
configFile = read_config_file()
timeZoneSetting = configFile['TIMEZONE']
timeZone = pytz.timezone(timeZoneSetting)
# -------------------------------------------------------------------

View File

@@ -8,8 +8,8 @@ A simple script-based plugin for setting the password.
### Notes
- The plugin is executed on the `RUN` type `before_config_save` so it's possible to update the `pialert.conf` file before the data is loaded into the app.
- The executed command is stored in the `CMD` setting: `/home/pi/pialert/back/pialert-cli set_password {password}`
- The plugin is executed on the `RUN` type `before_config_save` so it's possible to update the `app.conf` file before the data is loaded into the app.
- The executed command is stored in the `CMD` setting: `/app/back/pialert-cli set_password {password}`
- The `{password}` parameter is replaced via the parameter and setting below:
```json
@@ -39,7 +39,7 @@ A simple script-based plugin for setting the password.
"description": [
{
"language_code": "en_us",
"string": "The default password is <code>123456</code>. To change the password run <code>/home/pi/pialert/back/pialert-cli set_password {password}</code> in the container"
"string": "The default password is <code>123456</code>. To change the password run <code>/app/back/pialert-cli set_password {password}</code> in the container"
}
]
}

View File

@@ -68,7 +68,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value":"/home/pi/pialert/back/pialert-cli set_password {password}",
"default_value":"/app/back/pialert-cli set_password {password}",
"options": [],
"localized": ["name", "description"],
"name" : [{
@@ -108,11 +108,11 @@
"description": [
{
"language_code": "en_us",
"string": "The default password is <code>123456</code>. To change it, you can either use this plugin (follow the instructions in the <code>SETPWD_RUN</code> setting) or run <code>/home/pi/pialert/back/pialert-cli set_password {password}</code> in the container."
"string": "The default password is <code>123456</code>. To change it, you can either use this plugin (follow the instructions in the <code>SETPWD_RUN</code> setting) or run <code>/app/back/pialert-cli set_password {password}</code> in the container."
},
{
"language_code": "es_es",
"string": "La contraseña predeterminada es <code>123456</code>. Para cambiar la contraseña, ejecute <code>/home/pi/pialert/back/pialert-cli set_password {password}</code> en el contenedor"
"string": "La contraseña predeterminada es <code>123456</code>. Para cambiar la contraseña, ejecute <code>/app/back/pialert-cli set_password {password}</code> en el contenedor"
}
]
}

View File

@@ -332,7 +332,7 @@
{
"function": "CMD",
"type": "text",
"default_value":"python3 /home/pi/pialert/front/plugins/snmp_discovery/script.py routers={s-quote}{routers}{s-quote}",
"default_value":"python3 /app/front/plugins/snmp_discovery/script.py routers={s-quote}{routers}{s-quote}",
"options": [],
"localized": ["name", "description"],
"name" : [{

View File

@@ -1,8 +1,5 @@
#!/usr/bin/env python
# Example call
# python3 /home/pi/pialert/front/plugins/snmp_discovery/script.py routers='snmpwalk -v 2c -c public -OXsq 192.168.1.1 .1.3.6.1.2.1.3.1.1.2'
from __future__ import unicode_literals
import pathlib
import subprocess
@@ -10,8 +7,9 @@ import argparse
import os
import sys
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmpty
from logger import mylog

View File

@@ -110,7 +110,7 @@
{
"function": "CMD",
"type": "text",
"default_value": "python3 /home/pi/pialert/front/plugins/undiscoverables/script.py devices={devices}",
"default_value": "python3 /app/front/plugins/undiscoverables/script.py devices={devices}",
"options": [],
"localized": [
"name",

View File

@@ -7,8 +7,9 @@ import argparse
import sys
import hashlib
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, append_line_to_file

View File

@@ -521,7 +521,7 @@
"type": "text.select"
},
{
"default_value": "python3 /home/pi/pialert/front/plugins/unifi_import/script.py username={username} password={password} host={host} sites={sites} port={port} verifyssl={verifyssl} version={version} fullimport={fullimport}",
"default_value": "python3 /app/front/plugins/unifi_import/script.py username={username} password={password} host={host} sites={sites} port={port} verifyssl={verifyssl} version={version} fullimport={fullimport}",
"description": [
{
"language_code": "en_us",

View File

@@ -1,10 +1,6 @@
#!/usr/bin/env python
# Inspired by https://github.com/stevehoek/Pi.Alert
# Example call
# python3 /home/pi/pialert/front/plugins/unifi_import/script.py username=pialert password=passw0rd host=192.168.1.1 site=default protocol=https port=443 verifyssl=false version='UDMP-unifiOS'
# python3 /home/pi/pialert/front/plugins/unifi_import/script.py username=pialert password=passw0rd host=192.168.1.1 sites=sdefault port=8443 verifyssl=false version=v5
from __future__ import unicode_literals
from time import strftime
import argparse
@@ -18,9 +14,9 @@ from requests import Request, Session, packages
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from pyunifi.controller import Controller
# Add your paths here
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects
from logger import mylog

View File

@@ -87,7 +87,7 @@
{
"function": "CMD",
"type": "readonly",
"default_value": "python3 /home/pi/pialert/front/plugins/vendor_update/script.py",
"default_value": "python3 /app/front/plugins/vendor_update/script.py",
"options": [],
"localized": [
"name",

View File

@@ -11,8 +11,9 @@ import sqlite3
from io import StringIO
from datetime import datetime
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/netalertx')
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmpty
from logger import mylog, append_line_to_file

View File

@@ -335,7 +335,7 @@
{
"function": "CMD",
"type": "text",
"default_value":"python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls={urls}",
"default_value":"python3 /app/front/plugins/website_monitor/script.py urls={urls}",
"options": [],
"localized": ["name", "description"],
"name" : [{

View File

@@ -1,8 +1,6 @@
#!/usr/bin/env python
# Based on the work of https://github.com/leiweibau/Pi.Alert
# Example call
# python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls=http://google.com,http://bing.com
import argparse
import requests
import pathlib
@@ -10,7 +8,9 @@ import sys
import os
from requests.packages.urllib3.exceptions import InsecureRequestWarning
sys.path.extend(["/home/pi/pialert/front/plugins", "/home/pi/pialert/netalertx"])
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Objects
from datetime import datetime