mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2025-12-06 07:42:03 +01:00
add possibility to start Plugins asynchron
If you are using many Plugins or Plugins with a long execution time you could execute them in an asynchronous manner. It must be pointed out that enabling (0|1) this consume time, so don't use it for one rapid Plugin.
This commit is contained in:
parent
3e7cc1f365
commit
30320b3c71
|
|
@ -402,6 +402,10 @@ finally:
|
|||
finally:
|
||||
# Close Logging
|
||||
logging.debug("close Logging")
|
||||
# Waiting for all Threads to write there logs
|
||||
if globals.config.getboolean("BOSWatch","processAlarmAsync") == True:
|
||||
logging.debug("waiting 3s for threads...")
|
||||
time.sleep(3)
|
||||
logging.info("BOSWatch exit()")
|
||||
logging.shutdown()
|
||||
if nmaHandler:
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ backupCount = 7
|
|||
#rtl_path = /usr/local/bin/
|
||||
#multimon_path = /usr/local/bin/
|
||||
|
||||
# if you are using many Plugins or Plugins with a long execution time
|
||||
# you could execute them in an asynchronous manner
|
||||
# It must be pointed out that enabling (0|1) this consume time,
|
||||
# so don't use it for one rapid Plugin
|
||||
processAlarmAsync = 0
|
||||
|
||||
# Using RegEx-Filter (0|1)
|
||||
# Filter-configuration in section [Filters]
|
||||
useRegExFilter = 0
|
||||
|
|
|
|||
|
|
@ -16,3 +16,8 @@ class MyTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler):
|
|||
def setBackupCount(self, backupCount):
|
||||
"""Set/Change backupCount"""
|
||||
self.backupCount = backupCount
|
||||
|
||||
def close(self):
|
||||
"""Make shure logfile will be flushed"""
|
||||
self.flush()
|
||||
super(self.__class__, self).close()
|
||||
|
|
|
|||
|
|
@ -11,14 +11,48 @@ Handler for the filter and plugins at an alarm
|
|||
"""
|
||||
|
||||
import logging # Global logger
|
||||
from threading import Thread
|
||||
|
||||
from includes import globals # Global variables
|
||||
|
||||
##
|
||||
#
|
||||
# decide to run AlarmHandler sync or async
|
||||
#
|
||||
def processAlarmHandler(typ, freq, data):
|
||||
"""
|
||||
Function to decide if the alarm process will call sync
|
||||
|
||||
@type typ: string (FMS|ZVEI|POC)
|
||||
@param typ: Typ of the dataset
|
||||
@type freq: string
|
||||
@param freq: frequency of the SDR Stick
|
||||
@type data: map of data (structure see interface.txt)
|
||||
@param data: Contains the parameter
|
||||
|
||||
@requires: active plugins in pluginList
|
||||
@requires: Configuration has to be set in the config.ini
|
||||
|
||||
@return: nothing
|
||||
@exception: Exception if starting a Thread failed
|
||||
"""
|
||||
if globals.config.getboolean("BOSWatch","processAlarmAsync") == True:
|
||||
logging.debug("starting processAlarm async")
|
||||
try:
|
||||
Thread(target=processAlarm, args=(typ, freq, data)).start()
|
||||
except:
|
||||
logging.error("Error in starting alarm processing async")
|
||||
logging.debug("Error in starting alarm processing async", exc_info=True)
|
||||
pass
|
||||
else:
|
||||
processAlarm(typ, freq, data)
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
# main function for central filtering and calling the plugins
|
||||
#
|
||||
def processAlarm(typ,freq,data):
|
||||
def processAlarm(typ, freq, data):
|
||||
"""
|
||||
Function to process filters and plugins at Alarm
|
||||
|
||||
|
|
@ -59,4 +93,6 @@ def processAlarm(typ,freq,data):
|
|||
pass
|
||||
logging.debug("[END ALARM]")
|
||||
except:
|
||||
logging.exception("Error in alarm processing")
|
||||
logging.error("Error in alarm processing")
|
||||
logging.debug("Error in alarm processing", exc_info=True)
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from includes import doubleFilter # double alarm filter
|
|||
#
|
||||
def decode(freq, decoded):
|
||||
"""
|
||||
Export FMS Information from Multimon-NG RAW String and call alarmHandler.processAlarm()
|
||||
Export FMS Information from Multimon-NG RAW String and call alarmHandler.processAlarmHandler()
|
||||
|
||||
@type freq: string
|
||||
@param freq: frequency of the SDR Stick
|
||||
|
|
@ -59,7 +59,7 @@ def decode(freq, decoded):
|
|||
# processing the alarm
|
||||
try:
|
||||
from includes import alarmHandler
|
||||
alarmHandler.processAlarm("FMS", freq, data)
|
||||
alarmHandler.processAlarmHandler("FMS", freq, data)
|
||||
except:
|
||||
logging.error("processing alarm failed")
|
||||
logging.debug("processing alarm failed", exc_info=True)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ def isAllowed(poc_id):
|
|||
#
|
||||
def decode(freq, decoded):
|
||||
"""
|
||||
Export POCSAG Information from Multimon-NG RAW String and call alarmHandler.processAlarm()
|
||||
Export POCSAG Information from Multimon-NG RAW String and call alarmHandler.processAlarmHandler()
|
||||
|
||||
@type freq: string
|
||||
@param freq: frequency of the SDR Stick
|
||||
|
|
@ -117,7 +117,7 @@ def decode(freq, decoded):
|
|||
# processing the alarm
|
||||
try:
|
||||
from includes import alarmHandler
|
||||
alarmHandler.processAlarm("POC", freq, data)
|
||||
alarmHandler.processAlarmHandler("POC", freq, data)
|
||||
except:
|
||||
logging.error("processing alarm failed")
|
||||
logging.debug("processing alarm failed", exc_info=True)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ def removeF(zvei):
|
|||
#
|
||||
def decode(freq, decoded):
|
||||
"""
|
||||
Export ZVEI Information from Multimon-NG RAW String and call alarmHandler.processAlarm()
|
||||
Export ZVEI Information from Multimon-NG RAW String and call alarmHandler.processAlarmHandler()
|
||||
|
||||
@type freq: string
|
||||
@param freq: frequency of the SDR Stick
|
||||
|
|
@ -71,7 +71,7 @@ def decode(freq, decoded):
|
|||
# processing the alarm
|
||||
try:
|
||||
from includes import alarmHandler
|
||||
alarmHandler.processAlarm("ZVEI", freq, data)
|
||||
alarmHandler.processAlarmHandler("ZVEI", freq, data)
|
||||
except:
|
||||
logging.error("processing alarm failed")
|
||||
logging.debug("processing alarm failed", exc_info=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue