mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Merge branch 'jokob-sk:main' into Pi.Alert-MULTIPLE-FIX-ES_ES.JSON-V3
This commit is contained in:
@@ -46,6 +46,7 @@ services:
|
|||||||
- ${DEV_LOCATION}/front/presence.php:/home/pi/pialert/front/presence.php
|
- ${DEV_LOCATION}/front/presence.php:/home/pi/pialert/front/presence.php
|
||||||
- ${DEV_LOCATION}/front/settings.php:/home/pi/pialert/front/settings.php
|
- ${DEV_LOCATION}/front/settings.php:/home/pi/pialert/front/settings.php
|
||||||
- ${DEV_LOCATION}/front/systeminfo.php:/home/pi/pialert/front/systeminfo.php
|
- ${DEV_LOCATION}/front/systeminfo.php:/home/pi/pialert/front/systeminfo.php
|
||||||
|
- ${DEV_LOCATION}/front/report.php:/home/pi/pialert/front/report.php
|
||||||
- ${DEV_LOCATION}/front/flows.php:/home/pi/pialert/front/flows.php
|
- ${DEV_LOCATION}/front/flows.php:/home/pi/pialert/front/flows.php
|
||||||
- ${DEV_LOCATION}/front/plugins:/home/pi/pialert/front/plugins
|
- ${DEV_LOCATION}/front/plugins:/home/pi/pialert/front/plugins
|
||||||
# DELETE END anyone trying to use this file: comment out / delete ABOVE lines, they are only for development purposes
|
# DELETE END anyone trying to use this file: comment out / delete ABOVE lines, they are only for development purposes
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ from const import *
|
|||||||
from logger import mylog
|
from logger import mylog
|
||||||
from helper import filePermissions, isNewVersion, timeNowTZ, updateState
|
from helper import filePermissions, isNewVersion, timeNowTZ, updateState
|
||||||
from api import update_api
|
from api import update_api
|
||||||
# from networkscan import process_scan, scan_network
|
from networkscan import process_scan
|
||||||
from initialise import importConfigs
|
from initialise import importConfigs
|
||||||
from mac_vendor import update_devices_MAC_vendors
|
from mac_vendor import update_devices_MAC_vendors
|
||||||
from database import DB, get_all_devices
|
from database import DB, get_all_devices
|
||||||
@@ -205,10 +205,12 @@ def main ():
|
|||||||
if conf.ENABLE_PLUGINS:
|
if conf.ENABLE_PLUGINS:
|
||||||
run_plugin_scripts(db,'always_after_scan')
|
run_plugin_scripts(db,'always_after_scan')
|
||||||
|
|
||||||
# --------------------------------------------------
|
|
||||||
# process all the scanned data into new devices
|
# process all the scanned data into new devices
|
||||||
# mylog('debug', "[MAIN] start processig scan results")
|
if conf.currentScanNeedsProcessing == True:
|
||||||
# process_scan (db)
|
mylog('debug', "[MAIN] start processig scan results")
|
||||||
|
process_scan(db)
|
||||||
|
conf.currentScanNeedsProcessing = False
|
||||||
|
|
||||||
# Reporting
|
# Reporting
|
||||||
if conf.cycle in conf.check_report:
|
if conf.cycle in conf.check_report:
|
||||||
@@ -261,6 +263,12 @@ def main ():
|
|||||||
time.sleep(5) # wait for N seconds
|
time.sleep(5) # wait for N seconds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# BEGIN
|
# BEGIN
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
""" config related functions for Pi.Alert """
|
""" config related functions for Pi.Alert """
|
||||||
|
|
||||||
|
# TODO: Create and manage this as part of an app_state class object
|
||||||
|
#===============================================================================
|
||||||
|
# class app_state:
|
||||||
|
# def __init__(self, currentScanNeedsProcessing = False):
|
||||||
|
# self.currentScanNeedsProcessing = currentScanNeedsProcessing
|
||||||
|
|
||||||
|
|
||||||
# These are global variables, not config items and should not exist !
|
# These are global variables, not config items and should not exist !
|
||||||
mySettings = []
|
mySettings = []
|
||||||
@@ -15,6 +21,8 @@ tz = ''
|
|||||||
# set to a small value to force import at first run
|
# set to a small value to force import at first run
|
||||||
lastImportedConfFile = 1.1
|
lastImportedConfFile = 1.1
|
||||||
|
|
||||||
|
currentScanNeedsProcessing = False
|
||||||
|
|
||||||
plugins_once_run = False
|
plugins_once_run = False
|
||||||
newVersionAvailable = False
|
newVersionAvailable = False
|
||||||
time_started = ''
|
time_started = ''
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ from const import pluginsPath, logPath
|
|||||||
from logger import mylog
|
from logger import mylog
|
||||||
from helper import timeNowTZ, updateState, get_file_content, write_file, get_setting, get_setting_value
|
from helper import timeNowTZ, updateState, get_file_content, write_file, get_setting, get_setting_value
|
||||||
from api import update_api
|
from api import update_api
|
||||||
from networkscan import process_scan
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
def run_plugin_scripts(db, runType):
|
def run_plugin_scripts(db, runType):
|
||||||
@@ -25,6 +24,7 @@ def run_plugin_scripts(db, runType):
|
|||||||
for plugin in conf.plugins:
|
for plugin in conf.plugins:
|
||||||
|
|
||||||
shouldRun = False
|
shouldRun = False
|
||||||
|
prefix = plugin["unique_prefix"]
|
||||||
|
|
||||||
set = get_plugin_setting(plugin, "RUN")
|
set = get_plugin_setting(plugin, "RUN")
|
||||||
if set != None and set['value'] == runType:
|
if set != None and set['value'] == runType:
|
||||||
@@ -32,7 +32,7 @@ def run_plugin_scripts(db, runType):
|
|||||||
shouldRun = True
|
shouldRun = True
|
||||||
elif runType == "schedule":
|
elif runType == "schedule":
|
||||||
# run if overdue scheduled time
|
# run if overdue scheduled time
|
||||||
prefix = plugin["unique_prefix"]
|
|
||||||
|
|
||||||
# check schedules if any contains a unique plugin prefix matching the current plugin
|
# check schedules if any contains a unique plugin prefix matching the current plugin
|
||||||
for schd in conf.mySchedules:
|
for schd in conf.mySchedules:
|
||||||
@@ -44,6 +44,8 @@ def run_plugin_scripts(db, runType):
|
|||||||
schd.last_run = timeNowTZ()
|
schd.last_run = timeNowTZ()
|
||||||
|
|
||||||
if shouldRun:
|
if shouldRun:
|
||||||
|
# Header
|
||||||
|
updateState(db,f"Plugins: {prefix}")
|
||||||
|
|
||||||
print_plugin_info(plugin, ['display_name'])
|
print_plugin_info(plugin, ['display_name'])
|
||||||
mylog('debug', ['[Plugins] CMD: ', get_plugin_setting(plugin, "CMD")["value"]])
|
mylog('debug', ['[Plugins] CMD: ', get_plugin_setting(plugin, "CMD")["value"]])
|
||||||
@@ -418,7 +420,8 @@ def combine_plugin_objects(old, new):
|
|||||||
def process_plugin_events(db, plugin):
|
def process_plugin_events(db, plugin):
|
||||||
sql = db.sql
|
sql = db.sql
|
||||||
|
|
||||||
##global pluginObjects, pluginEvents
|
# capturing if we need to process scan results for devices
|
||||||
|
conf.currentScanNeedsProcessing = False
|
||||||
|
|
||||||
pluginPref = plugin["unique_prefix"]
|
pluginPref = plugin["unique_prefix"]
|
||||||
|
|
||||||
@@ -591,17 +594,11 @@ def process_plugin_events(db, plugin):
|
|||||||
|
|
||||||
# perform scan if mapped to CurrentScan table
|
# perform scan if mapped to CurrentScan table
|
||||||
if dbTable == 'CurrentScan':
|
if dbTable == 'CurrentScan':
|
||||||
process_scan(db)
|
conf.currentScanNeedsProcessing = True
|
||||||
|
|
||||||
|
|
||||||
db.commitDB()
|
db.commitDB()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
class plugin_object_class:
|
class plugin_object_class:
|
||||||
def __init__(self, plugin, objDbRow):
|
def __init__(self, plugin, objDbRow):
|
||||||
|
|||||||
Reference in New Issue
Block a user