NTFPRCS work + docs
This commit is contained in:
@@ -21,7 +21,6 @@ SCAN_SUBNETS=['192.168.1.0/24 --interface=eth1']
|
|||||||
TIMEZONE='Europe/Berlin'
|
TIMEZONE='Europe/Berlin'
|
||||||
PIALERT_WEB_PROTECTION=False
|
PIALERT_WEB_PROTECTION=False
|
||||||
PIALERT_WEB_PASSWORD='8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92'
|
PIALERT_WEB_PASSWORD='8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92'
|
||||||
INCLUDED_SECTIONS=['internet','new_devices','down_devices','events']
|
|
||||||
DAYS_TO_KEEP_EVENTS=90
|
DAYS_TO_KEEP_EVENTS=90
|
||||||
# Used for generating links in emails. Make sure not to add a trailing slash!
|
# Used for generating links in emails. Make sure not to add a trailing slash!
|
||||||
REPORT_DASHBOARD_URL='http://pi.alert'
|
REPORT_DASHBOARD_URL='http://pi.alert'
|
||||||
|
|||||||
@@ -559,8 +559,6 @@
|
|||||||
"PIALERT_WEB_PROTECTION_description": "Ein Loginfenster wird angezeigt wenn aktiviert. Untere Beschreibung genau durchlesen falls Sie sich aus Ihrer Instanz aussperren.",
|
"PIALERT_WEB_PROTECTION_description": "Ein Loginfenster wird angezeigt wenn aktiviert. Untere Beschreibung genau durchlesen falls Sie sich aus Ihrer Instanz aussperren.",
|
||||||
"PIALERT_WEB_PASSWORD_name": "Login-Passwort",
|
"PIALERT_WEB_PASSWORD_name": "Login-Passwort",
|
||||||
"PIALERT_WEB_PASSWORD_description": "Das Standardpasswort ist <code>123456</code>. Um das Passwort zu ändern, entweder <code>/home/pi/pialert/back/pialert-cli</code> im Container starten oder <a onclick=\"toggleAllSettings()\" href=\"#SETPWD_RUN\"><code>SETPWD_RUN</code> Set password plugin</a> nutzen.",
|
"PIALERT_WEB_PASSWORD_description": "Das Standardpasswort ist <code>123456</code>. Um das Passwort zu ändern, entweder <code>/home/pi/pialert/back/pialert-cli</code> im Container starten oder <a onclick=\"toggleAllSettings()\" href=\"#SETPWD_RUN\"><code>SETPWD_RUN</code> Set password plugin</a> nutzen.",
|
||||||
"INCLUDED_SECTIONS_name": "Benachrichtigungen",
|
|
||||||
"INCLUDED_SECTIONS_description": "Spezifiziert, bei welchen Events Benachrichtigungen versendet werden. Entfernen Sie die Eventtypen, bei welchen Sie nicht benachrichtigt werden wollen. Diese Einstellung überschreibt gerätespezifische Einstellungen im UI. (<code>STRG + klicken</code> zum aus-/abwählen).",
|
|
||||||
"DAYS_TO_KEEP_EVENTS_name": "Lösche Events älter als",
|
"DAYS_TO_KEEP_EVENTS_name": "Lösche Events älter als",
|
||||||
"DAYS_TO_KEEP_EVENTS_description": "Dies ist eine Wartungseinstellung. Spezifiziert wie viele Tage Events gespeichert bleiben. Alle älteren Events werden periodisch gelöscht. Wird auch auf die Plugins History angewendet.",
|
"DAYS_TO_KEEP_EVENTS_description": "Dies ist eine Wartungseinstellung. Spezifiziert wie viele Tage Events gespeichert bleiben. Alle älteren Events werden periodisch gelöscht. Wird auch auf die Plugins History angewendet.",
|
||||||
"HRS_TO_KEEP_NEWDEV_name": "Neue Geräte speichern für",
|
"HRS_TO_KEEP_NEWDEV_name": "Neue Geräte speichern für",
|
||||||
|
|||||||
@@ -505,8 +505,6 @@
|
|||||||
"PIALERT_WEB_PROTECTION_description" : "When enabled a login dialog is displayed. Read below carefully if you get locked out of your instance.",
|
"PIALERT_WEB_PROTECTION_description" : "When enabled a login dialog is displayed. Read below carefully if you get locked out of your instance.",
|
||||||
"PIALERT_WEB_PASSWORD_name" : "Login password",
|
"PIALERT_WEB_PASSWORD_name" : "Login password",
|
||||||
"PIALERT_WEB_PASSWORD_description" : "The default password is <code>123456</code>. To change the password run <code>/home/pi/pialert/back/pialert-cli</code> in the container or use the <a onclick=\"toggleAllSettings()\" href=\"#SETPWD_RUN\"><code>SETPWD_RUN</code> Set password plugin</a>.",
|
"PIALERT_WEB_PASSWORD_description" : "The default password is <code>123456</code>. To change the password run <code>/home/pi/pialert/back/pialert-cli</code> in the container or use the <a onclick=\"toggleAllSettings()\" href=\"#SETPWD_RUN\"><code>SETPWD_RUN</code> Set password plugin</a>.",
|
||||||
"INCLUDED_SECTIONS_name" : "Notify on",
|
|
||||||
"INCLUDED_SECTIONS_description" : "Specifies which events trigger notifications. Remove the event type(s) you do not want to get notified on. This setting overrides device-specific settings in the UI. (<code>CTRL + Click</code> to select/deselect).",
|
|
||||||
"DAYS_TO_KEEP_EVENTS_name" : "Delete events older than",
|
"DAYS_TO_KEEP_EVENTS_name" : "Delete events older than",
|
||||||
"DAYS_TO_KEEP_EVENTS_description" : "This is a maintenance setting. This specifies the number of days worth of event entries that will be kept. All older events will be deleted periodically. Also applies on Plugin Events History.",
|
"DAYS_TO_KEEP_EVENTS_description" : "This is a maintenance setting. This specifies the number of days worth of event entries that will be kept. All older events will be deleted periodically. Also applies on Plugin Events History.",
|
||||||
"HRS_TO_KEEP_NEWDEV_name" : "Keep new devices for",
|
"HRS_TO_KEEP_NEWDEV_name" : "Keep new devices for",
|
||||||
|
|||||||
@@ -471,8 +471,6 @@
|
|||||||
"PIALERT_WEB_PROTECTION_description" : "Cuando está habilitado, se muestra un cuadro de diálogo de inicio de sesión. Lea detenidamente a continuación si se le bloquea el acceso a su instancia.",
|
"PIALERT_WEB_PROTECTION_description" : "Cuando está habilitado, se muestra un cuadro de diálogo de inicio de sesión. Lea detenidamente a continuación si se le bloquea el acceso a su instancia.",
|
||||||
"PIALERT_WEB_PASSWORD_name" : "Contraseña de inicio de sesión",
|
"PIALERT_WEB_PASSWORD_name" : "Contraseña de inicio de sesión",
|
||||||
"PIALERT_WEB_PASSWORD_description" : "La contraseña predeterminada es <code>123456</code>. Para cambiar la contraseña, ejecute <code>/home/pi/pialert/back/pialert-cli</code> en el contenedor",
|
"PIALERT_WEB_PASSWORD_description" : "La contraseña predeterminada es <code>123456</code>. Para cambiar la contraseña, ejecute <code>/home/pi/pialert/back/pialert-cli</code> en el contenedor",
|
||||||
"INCLUDED_SECTIONS_name" : "Notificar en",
|
|
||||||
"INCLUDED_SECTIONS_description" : "Especifica que eventos envían notificaciones. Elimina los tipos de eventos de los que no quieras recibir notificaciones. Este ajuste sobreescribe los ajustes específicos de los dispositivos en la interfaz. (<code>CTRL + Clic</code> para seleccionar / deseleccionar).",
|
|
||||||
"DAYS_TO_KEEP_EVENTS_name" : "Eliminar eventos anteriores a",
|
"DAYS_TO_KEEP_EVENTS_name" : "Eliminar eventos anteriores a",
|
||||||
"DAYS_TO_KEEP_EVENTS_description" : "Esta es una configuración de mantenimiento. Esto especifica el número de días de entradas de eventos que se guardarán. Todos los eventos anteriores se eliminarán periódicamente.",
|
"DAYS_TO_KEEP_EVENTS_description" : "Esta es una configuración de mantenimiento. Esto especifica el número de días de entradas de eventos que se guardarán. Todos los eventos anteriores se eliminarán periódicamente.",
|
||||||
"HRS_TO_KEEP_NEWDEV_name": "Guardar nuevos dispositivos para",
|
"HRS_TO_KEEP_NEWDEV_name": "Guardar nuevos dispositivos para",
|
||||||
|
|||||||
@@ -14,34 +14,35 @@
|
|||||||
|
|
||||||
### 🔌 Plugins & 📚 Docs
|
### 🔌 Plugins & 📚 Docs
|
||||||
|
|
||||||
| Required | CurrentScan | Unique Prefix | Data source | Type | Link + Docs |
|
| Required | CurrentScan | Unique Prefix | Data source | Type | Link + Docs |
|
||||||
|----------|-------------|---------------|--------------------|----------------|------------------------------------------------------------------|
|
|----------|-------------|---------------|--------------------|----------------|---------------------------------------------------------------------|
|
||||||
| | | APPRISE | Script | 💬 publisher | 📚[_publisher_apprise](/front/plugins/_publisher_apprise/) |
|
| | | APPRISE | Script | 💬 publisher | 📚[_publisher_apprise](/front/plugins/_publisher_apprise/) |
|
||||||
| | Yes | ARPSCAN | Script | 🔍dev scanner | 📚[arp_scan](/front/plugins/arp_scan/) |
|
| | Yes | ARPSCAN | Script | 🔍dev scanner | 📚[arp_scan](/front/plugins/arp_scan/) |
|
||||||
| | | CSVBCKP | Script | ⚙ system | 📚[csv_backup](/front/plugins/csv_backup/) |
|
| | | CSVBCKP | Script | ⚙ system | 📚[csv_backup](/front/plugins/csv_backup/) |
|
||||||
| Yes* | | DBCLNP | Script | ⚙ system | 📚[db_cleanup](/front/plugins/db_cleanup/) |
|
| Yes* | | DBCLNP | Script | ⚙ system | 📚[db_cleanup](/front/plugins/db_cleanup/) |
|
||||||
| | | DDNS | Script | ⚙ system | 📚[ddns_update](/front/plugins/ddns_update/) |
|
| | | DDNS | Script | ⚙ system | 📚[ddns_update](/front/plugins/ddns_update/) |
|
||||||
| | Yes | DHCPLSS | Script | 🔍dev scanner | 📚[dhcp_leases](/front/plugins/dhcp_leases/) |
|
| | Yes | DHCPLSS | Script | 🔍dev scanner | 📚[dhcp_leases](/front/plugins/dhcp_leases/) |
|
||||||
| | | DHCPSRVS | Script | ♻ other | 📚[dhcp_servers](/front/plugins/dhcp_servers/) |
|
| | | DHCPSRVS | Script | ♻ other | 📚[dhcp_servers](/front/plugins/dhcp_servers/) |
|
||||||
| | Yes | INTRNT | Script | 🔍dev scanner | 📚[internet_ip](/front/plugins/internet_ip/) |
|
| | Yes | INTRNT | Script | 🔍dev scanner | 📚[internet_ip](/front/plugins/internet_ip/) |
|
||||||
| | | INTRSPD | Script | ♻ other | 📚[internet_speedtest](/front/plugins/internet_speedtest/) |
|
| | | INTRSPD | Script | ♻ other | 📚[internet_speedtest](/front/plugins/internet_speedtest/) |
|
||||||
| | | MAINT | Script | ⚙ system | 📚[maintenance](/front/plugins/maintenance/) |
|
| | | MAINT | Script | ⚙ system | 📚[maintenance](/front/plugins/maintenance/) |
|
||||||
| | | MQTT | Script | 💬 publisher | 📚[_publisher_mqtt](/front/plugins/_publisher_mqtt/) |
|
| | | MQTT | Script | 💬 publisher | 📚[_publisher_mqtt](/front/plugins/_publisher_mqtt/) |
|
||||||
| Yes | | NEWDEV | Template | ⚙ system | 📚[newdev_template](/front/plugins/newdev_template/) |
|
| Yes | | NEWDEV | Template | ⚙ system | 📚[newdev_template](/front/plugins/newdev_template/) |
|
||||||
| | | NMAP | Script | ♻ other | 📚[nmap_scan](/front/plugins/nmap_scan/) |
|
| | | NMAP | Script | ♻ other | 📚[nmap_scan](/front/plugins/nmap_scan/) |
|
||||||
| | | NTFY | Script | 💬 publisher | 📚[_publisher_ntfy](/front/plugins/_publisher_ntfy/) |
|
| | Yes | NTFPRCS | Template | ⚙ system | 📚[notification_processing](/front/plugins/notification_processing/)|
|
||||||
| | | PHOLUS | Script | ♻ other | 📚[pholus_scan](/front/plugins/pholus_scan/) |
|
| | | NTFY | Script | 💬 publisher | 📚[_publisher_ntfy](/front/plugins/_publisher_ntfy/) |
|
||||||
| | Yes | PIHOLE | External SQLite DB | 🔍dev scanner | 📚[pihole_scan](/front/plugins/pihole_scan/) |
|
| | | PHOLUS | Script | ♻ other | 📚[pholus_scan](/front/plugins/pholus_scan/) |
|
||||||
| | | PUSHSAFER | Script | 💬 publisher | 📚[_publisher_pushsafer](/front/plugins/_publisher_pushsafer/) |
|
| | Yes | PIHOLE | External SQLite DB | 🔍dev scanner | 📚[pihole_scan](/front/plugins/pihole_scan/) |
|
||||||
| | | SETPWD | Script | ⚙ system | 📚[set_password](/front/plugins/set_password/) |
|
| | | PUSHSAFER | Script | 💬 publisher | 📚[_publisher_pushsafer](/front/plugins/_publisher_pushsafer/) |
|
||||||
| | | SMTP | Script | 💬 publisher | 📚[_publisher_email](/front/plugins/_publisher_email/) |
|
| | | SETPWD | Script | ⚙ system | 📚[set_password](/front/plugins/set_password/) |
|
||||||
| | Yes | SNMPDSC | Script | 🔍dev scanner | 📚[snmp_discovery](/front/plugins/snmp_discovery/) |
|
| | | SMTP | Script | 💬 publisher | 📚[_publisher_email](/front/plugins/_publisher_email/) |
|
||||||
| | Yes** | UNDIS | Script | ♻ other | 📚[undiscoverables](/front/plugins/undiscoverables/) |
|
| | Yes | SNMPDSC | Script | 🔍dev scanner | 📚[snmp_discovery](/front/plugins/snmp_discovery/) |
|
||||||
| | Yes | UNFIMP | Script | 🔍dev scanner | 📚[unifi_import](/front/plugins/unifi_import/) |
|
| | Yes** | UNDIS | Script | ♻ other | 📚[undiscoverables](/front/plugins/undiscoverables/) |
|
||||||
| | | VNDRPDT | Script | ⚙ system | 📚[vendor_update](/front/plugins/vendor_update/) |
|
| | Yes | UNFIMP | Script | 🔍dev scanner | 📚[unifi_import](/front/plugins/unifi_import/) |
|
||||||
| | | WEBHOOK | Script | 💬 publisher | 📚[_publisher_webhook](/front/plugins/_publisher_webhook/) |
|
| | | VNDRPDT | Script | ⚙ system | 📚[vendor_update](/front/plugins/vendor_update/) |
|
||||||
| | | WEBMON | Script | ♻ other | 📚[website_monitor](/front/plugins/website_monitor/) |
|
| | | WEBHOOK | Script | 💬 publisher | 📚[_publisher_webhook](/front/plugins/_publisher_webhook/) |
|
||||||
| N/A | | N/A | SQL query | | N/A, but the External SQLite DB plugins work similar |
|
| | | WEBMON | Script | ♻ other | 📚[website_monitor](/front/plugins/website_monitor/) |
|
||||||
|
| N/A | | N/A | SQL query | | N/A, but the External SQLite DB plugins work similarly |
|
||||||
|
|
||||||
|
|
||||||
> \* The database cleanup plugin (`DBCLNP`) is not _required_ but the app will become unusable after a while if not executed.
|
> \* The database cleanup plugin (`DBCLNP`) is not _required_ but the app will become unusable after a while if not executed.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Plugin to run regular database cleanup tasks. It is strongly recommended to have an hourly or at least daily schedule running.
|
Plugin supplying settings for Notification Processing.
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,41 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"settings": [
|
"settings": [
|
||||||
|
{
|
||||||
|
"function": "INCLUDED_SECTIONS",
|
||||||
|
"type": "text.multiselect",
|
||||||
|
"default_value": ["new_devices", "down_devices", "events"],
|
||||||
|
"options": ["new_devices", "down_devices", "events", "plugins"],
|
||||||
|
"localized": ["name", "description"],
|
||||||
|
"name": [
|
||||||
|
{
|
||||||
|
"language_code": "en_us",
|
||||||
|
"string": "Notify on"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language_code": "de_de",
|
||||||
|
"string": "Benachrichtigungen"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language_code": "es_es",
|
||||||
|
"string": "Notificar en"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": [
|
||||||
|
{
|
||||||
|
"language_code": "en_us",
|
||||||
|
"string": "Specifies which events trigger notifications. Remove the event type(s) you do not want to get notified on. This setting overrides device-specific settings in the UI. (<code>CTRL + Click</code> to select/deselect)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language_code": "de_de",
|
||||||
|
"string": "Spezifiziert, bei welchen Events Benachrichtigungen versendet werden. Entfernen Sie die Eventtypen, bei welchen Sie nicht benachrichtigt werden wollen. Diese Einstellung überschreibt gerätespezifische Einstellungen im UI. (<code>STRG + klicken</code> zum aus-/abwählen)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language_code": "es_es",
|
||||||
|
"string": "Especifica que eventos envían notificaciones. Elimina los tipos de eventos de los que no quieras recibir notificaciones. Este ajuste sobreescribe los ajustes específicos de los dispositivos en la interfaz. (<code>CTRL + Clic</code> para seleccionar / deseleccionar)."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"function": "alert_down_time",
|
"function": "alert_down_time",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import os
|
|
||||||
import pathlib
|
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import hashlib
|
|
||||||
import csv
|
|
||||||
import sqlite3
|
|
||||||
from io import StringIO
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
sys.path.append("/home/pi/pialert/front/plugins")
|
|
||||||
sys.path.append('/home/pi/pialert/pialert')
|
|
||||||
|
|
||||||
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
|
|
||||||
from logger import mylog, append_line_to_file
|
|
||||||
from helper import timeNowTZ, get_setting_value
|
|
||||||
from const import logPath, pialertPath, fullDbPath
|
|
||||||
|
|
||||||
|
|
||||||
CUR_PATH = str(pathlib.Path(__file__).parent.resolve())
|
|
||||||
LOG_FILE = os.path.join(CUR_PATH, 'script.log')
|
|
||||||
RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log')
|
|
||||||
|
|
||||||
pluginName = 'NTFPRCS'
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
mylog('verbose', [f'[{pluginName}] In script'])
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
# process_notifications(fullDbPath)
|
|
||||||
|
|
||||||
mylog('verbose', [f'[{pluginName}] Script finished'])
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Cleanup / upkeep database
|
|
||||||
#===============================================================================
|
|
||||||
def process_notifications (dbPath):
|
|
||||||
|
|
||||||
# Connect to the PiAlert SQLite database
|
|
||||||
conn = sqlite3.connect(dbPath)
|
|
||||||
cursor = conn.cursor()
|
|
||||||
|
|
||||||
# Cleanup Events
|
|
||||||
# mylog('verbose', [f'[DBCLNP] Events: Delete all older than {str(DAYS_TO_KEEP_EVENTS)} days (DAYS_TO_KEEP_EVENTS setting)'])
|
|
||||||
|
|
||||||
# cursor.execute (f"""DELETE FROM Events
|
|
||||||
# WHERE eve_DateTime <= date('now', '-{str(DAYS_TO_KEEP_EVENTS)} day')""")
|
|
||||||
|
|
||||||
|
|
||||||
conn.commit()
|
|
||||||
|
|
||||||
# Close the database connection
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# BEGIN
|
|
||||||
#===============================================================================
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
@@ -37,7 +37,6 @@ UI_LANG = 'English'
|
|||||||
UI_PRESENCE = ['online', 'offline', 'archived']
|
UI_PRESENCE = ['online', 'offline', 'archived']
|
||||||
PIALERT_WEB_PROTECTION = False
|
PIALERT_WEB_PROTECTION = False
|
||||||
PIALERT_WEB_PASSWORD = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92'
|
PIALERT_WEB_PASSWORD = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92'
|
||||||
INCLUDED_SECTIONS = ['new_devices', 'down_devices', 'events']
|
|
||||||
DAYS_TO_KEEP_EVENTS = 90
|
DAYS_TO_KEEP_EVENTS = 90
|
||||||
REPORT_DASHBOARD_URL = 'http://pi.alert/'
|
REPORT_DASHBOARD_URL = 'http://pi.alert/'
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ def importConfigs (db):
|
|||||||
conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 250 , c_d, 'Keep history entries', 'integer', '', 'General')
|
conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 250 , c_d, 'Keep history entries', 'integer', '', 'General')
|
||||||
conf.PIALERT_WEB_PROTECTION = ccd('PIALERT_WEB_PROTECTION', False , c_d, 'Enable logon', 'boolean', '', 'General')
|
conf.PIALERT_WEB_PROTECTION = ccd('PIALERT_WEB_PROTECTION', False , c_d, 'Enable logon', 'boolean', '', 'General')
|
||||||
conf.PIALERT_WEB_PASSWORD = ccd('PIALERT_WEB_PASSWORD', '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92' , c_d, 'Logon password', 'readonly', '', 'General')
|
conf.PIALERT_WEB_PASSWORD = ccd('PIALERT_WEB_PASSWORD', '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92' , c_d, 'Logon password', 'readonly', '', 'General')
|
||||||
conf.INCLUDED_SECTIONS = ccd('INCLUDED_SECTIONS', ['new_devices', 'down_devices', 'events'] , c_d, 'Notify on', 'text.multiselect', "['new_devices', 'down_devices', 'events', 'plugins']", 'General')
|
|
||||||
conf.REPORT_DASHBOARD_URL = ccd('REPORT_DASHBOARD_URL', 'http://pi.alert/' , c_d, 'PiAlert URL', 'text', '', 'General')
|
conf.REPORT_DASHBOARD_URL = ccd('REPORT_DASHBOARD_URL', 'http://pi.alert/' , c_d, 'PiAlert URL', 'text', '', 'General')
|
||||||
conf.DIG_GET_IP_ARG = ccd('DIG_GET_IP_ARG', '-4 myip.opendns.com @resolver1.opendns.com' , c_d, 'DIG arguments', 'text', '', 'General')
|
conf.DIG_GET_IP_ARG = ccd('DIG_GET_IP_ARG', '-4 myip.opendns.com @resolver1.opendns.com' , c_d, 'DIG arguments', 'text', '', 'General')
|
||||||
conf.UI_LANG = ccd('UI_LANG', 'English' , c_d, 'Language Interface', 'text.select', "['English', 'German', 'Spanish']", 'General')
|
conf.UI_LANG = ccd('UI_LANG', 'English' , c_d, 'Language Interface', 'text.select', "['English', 'German', 'Spanish']", 'General')
|
||||||
@@ -260,7 +259,8 @@ replacements = {
|
|||||||
r'REPORT_WEBHOOK=True': 'WEBHOOK_RUN=\'on_notification\'',
|
r'REPORT_WEBHOOK=True': 'WEBHOOK_RUN=\'on_notification\'',
|
||||||
r'REPORT_PUSHSAFER=True': 'PUSHSAFER_RUN=\'on_notification\'',
|
r'REPORT_PUSHSAFER=True': 'PUSHSAFER_RUN=\'on_notification\'',
|
||||||
r'REPORT_MQTT=True': 'MQTT_RUN=\'on_notification\'',
|
r'REPORT_MQTT=True': 'MQTT_RUN=\'on_notification\'',
|
||||||
r'PIHOLE_CMD=': 'PIHOLE_CMD_OLD='
|
r'PIHOLE_CMD=': 'PIHOLE_CMD_OLD=',
|
||||||
|
r'\bINCLUDED_SECTIONS\b': 'NTFPRCS_INCLUDED_SECTIONS'
|
||||||
}
|
}
|
||||||
|
|
||||||
def renameSettings(config_file):
|
def renameSettings(config_file):
|
||||||
|
|||||||
@@ -56,17 +56,20 @@ def get_notifications (db):
|
|||||||
SELECT dev_MAC FROM Devices WHERE dev_AlertDeviceDown = 0
|
SELECT dev_MAC FROM Devices WHERE dev_AlertDeviceDown = 0
|
||||||
)""")
|
)""")
|
||||||
|
|
||||||
|
sections = get_setting_value('NTFPRCS_INCLUDED_SECTIONS')
|
||||||
|
|
||||||
mylog('verbose', ['[Notification] included sections: ', conf.INCLUDED_SECTIONS ])
|
mylog('verbose', ['[Notification] Included sections: ', sections ])
|
||||||
|
|
||||||
if 'new_devices' in conf.INCLUDED_SECTIONS:
|
if 'new_devices' in sections:
|
||||||
# Compose New Devices Section
|
# Compose New Devices Section
|
||||||
sqlQuery = f"""SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
|
sqlQuery = f"""SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
|
||||||
WHERE eve_PendingAlertEmail = 1
|
WHERE eve_PendingAlertEmail = 1
|
||||||
AND eve_EventType = 'New Device'
|
AND eve_EventType = 'New Device'
|
||||||
{get_setting_value('NTFPRCS_new_dev_condition')}
|
{get_setting_value('NTFPRCS_new_dev_condition').replace('{s-quote}',"'")}
|
||||||
ORDER BY eve_DateTime"""
|
ORDER BY eve_DateTime"""
|
||||||
|
|
||||||
|
mylog('debug', ['[Notification] new_devices SQL query: ', sqlQuery ])
|
||||||
|
|
||||||
# Get the events as JSON
|
# Get the events as JSON
|
||||||
json_obj = db.get_table_as_json(sqlQuery)
|
json_obj = db.get_table_as_json(sqlQuery)
|
||||||
|
|
||||||
@@ -77,7 +80,7 @@ def get_notifications (db):
|
|||||||
|
|
||||||
json_new_devices = json_obj.json["data"]
|
json_new_devices = json_obj.json["data"]
|
||||||
|
|
||||||
if 'down_devices' in conf.INCLUDED_SECTIONS:
|
if 'down_devices' in sections:
|
||||||
# Compose Devices Down Section
|
# Compose Devices Down Section
|
||||||
# - select only Down Alerts with pending email of devices that didn't reconnect within the specified time window
|
# - select only Down Alerts with pending email of devices that didn't reconnect within the specified time window
|
||||||
sqlQuery = f"""
|
sqlQuery = f"""
|
||||||
@@ -105,15 +108,17 @@ def get_notifications (db):
|
|||||||
}
|
}
|
||||||
json_down_devices = json_obj.json["data"]
|
json_down_devices = json_obj.json["data"]
|
||||||
|
|
||||||
if 'events' in conf.INCLUDED_SECTIONS:
|
if 'events' in sections:
|
||||||
# Compose Events Section
|
# Compose Events Section
|
||||||
sqlQuery = f"""SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
|
sqlQuery = f"""SELECT eve_MAC as MAC, eve_DateTime as Datetime, dev_LastIP as IP, eve_EventType as "Event Type", dev_Name as "Device name", dev_Comments as Comments FROM Events_Devices
|
||||||
WHERE eve_PendingAlertEmail = 1
|
WHERE eve_PendingAlertEmail = 1
|
||||||
AND eve_EventType IN ('Connected','Disconnected',
|
AND eve_EventType IN ('Connected','Disconnected',
|
||||||
'IP Changed')
|
'IP Changed')
|
||||||
{get_setting_value('NTFPRCS_event_condition')}
|
{get_setting_value('NTFPRCS_event_condition').replace('{s-quote}',"'")}
|
||||||
ORDER BY eve_DateTime"""
|
ORDER BY eve_DateTime"""
|
||||||
|
|
||||||
|
mylog('debug', ['[Notification] events SQL query: ', sqlQuery ])
|
||||||
|
|
||||||
# Get the events as JSON
|
# Get the events as JSON
|
||||||
json_obj = db.get_table_as_json(sqlQuery)
|
json_obj = db.get_table_as_json(sqlQuery)
|
||||||
|
|
||||||
@@ -123,7 +128,7 @@ def get_notifications (db):
|
|||||||
}
|
}
|
||||||
json_events = json_obj.json["data"]
|
json_events = json_obj.json["data"]
|
||||||
|
|
||||||
if 'plugins' in conf.INCLUDED_SECTIONS:
|
if 'plugins' in sections:
|
||||||
# Compose Plugins Section
|
# Compose Plugins Section
|
||||||
sqlQuery = """SELECT Plugin, Object_PrimaryId, Object_SecondaryId, DateTimeChanged, Watched_Value1, Watched_Value2, Watched_Value3, Watched_Value4, Status from Plugins_Events"""
|
sqlQuery = """SELECT Plugin, Object_PrimaryId, Object_SecondaryId, DateTimeChanged, Watched_Value1, Watched_Value2, Watched_Value3, Watched_Value4, Status from Plugins_Events"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user