checkFilters() with freq und wildcards

This commit is contained in:
Schrolli 2015-05-28 09:18:21 +02:00
parent 9bfe832530
commit b3ee8d29ae
4 changed files with 36 additions and 23 deletions

View file

@ -48,13 +48,23 @@ For each Plugin that requires configurations a own Section with his Name is avai
For the other Functions see "Usage" below.
##### Filtering Functions
For the Filter Functions see Section `[Filters]`
Syntax: INDIVIDUAL_NAME = TYP;PLUGIN;REGEX
TYP = FMS|ZVEI|POC
PLUGIN = Name of the Plugin
REGEX = Filtering with RegEx
my_own_Filter = ZVEI;template;25[0-9F]{3} #all ZVEI alarm to Plugin template where 25###
##### Filtering Functions (RegEX)
For the RegEX Filter Functions see Section `[Filters]`
http://www.regexr.com/ - RegEX Test Tool an Documentation
No Filter for a Typ/Plugin Combination = all Data pass
Syntax: INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;FREQUENZ;REGEX
- TYP = the Data Typ (FMS|ZVEI|POC)
- DATAFIELD = the field of the Data Array (See interface.txt)
- PLUGIN = the name of the Plugin to call with this Filter (* for all)
- FREQUENZ = the Frequenz to use the Filter (for more SDR Sticks (* for all))
- REGEX = the RegEX
only ZVEI to all Plugins with 25### at 85.5MHz
testfilter = ZVEI;zvei;*;85500000;25[0-9]{3}
only POCSAG to MySQL with the text "ALARM:" in the Message
pocTest = POC;msg;MySQL;*;ALARM:
##### Web Frontend
Put the Files in Folder /wwww/ into your local Webserver Folder (/var/www/).

View file

@ -50,17 +50,18 @@ filter_range_end = 9999999
#RegEX Filter Configuration
#http://www.regexr.com/ - RegEX Test Tool an Documentation
#No Filter for a Typ/Plugin Combination = all Data pass
#INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;REGEX
#TYP = the Data Typ (FMS|ZVEI|POC)
#INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;FREQUENZ;REGEX
#TYP = the Data Typ (FMS|ZVEI|POC)
#DATAFIELD = the field of the Data Array (See interface.txt)
#PLUGIN = the name of the Plugin to call with this Filter
#REGEX = the RegEX
#PLUGIN = the name of the Plugin to call with this Filter (* for all)
#FREQUENZ = the Frequenz to use the Filter (for more SDR Sticks (* for all))
#REGEX = the RegEX
#only ZVEI to template with 25###
#testfilter = ZVEI;zvei;template;25[0-9]{3}
#only ZVEI to all Plugins with 25### at 85.5MHz
#testfilter = ZVEI;zvei;*;85500000;25[0-9]{3}
#only POCSAG to MySQL with the text "ALARM:" in the Message
#pocTest = POC;msg;MySQL;ALARM:
#pocTest = POC;msg;MySQL;*;ALARM:
[Plugins]

View file

@ -38,7 +38,7 @@ def processAlarm(typ,freq,data):
#if enabled use RegEx-Filter
if globals.config.getint("BOSWatch","useRegExFilter"):
from includes import filter
if filter.checkFilters(data,typ,pluginName):
if filter.checkFilters(typ,data,pluginName,freq):
logging.debug("call Plugin: %s", pluginName)
plugin.run(typ,freq,data)
logging.debug("return from: %s", pluginName)

View file

@ -32,22 +32,24 @@ def loadFilters():
logging.debug(" - %s = %s", key, val)
filter = val.split(";")
#insert splitet Data into globals.filterList
globals.filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "regex": filter[3]})
globals.filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "freq": filter[3], "regex": filter[4]})
except:
logging.exception("cannot read config file")
def checkFilters(data,typ,plugin):
def checkFilters(typ,data,plugin,freq):
"""
Check the Typ/Plugin combination with the RegEX Filter
If no Filter for the combination is found, Function returns True.
@type data: map of data (structure see interface.txt)
@param data: Contains the parameter
@type typ: string (FMS|ZVEI|POC)
@param typ: Typ of the dataset
@type data: map of data (structure see interface.txt)
@param data: Contains the parameter
@type plugin: string
@param plugin: Name of the Plugin to checked
@type freq: string
@param freq: frequency of the SDR Stick
@requires: all Filters in the filterList
@ -55,13 +57,13 @@ def checkFilters(data,typ,plugin):
@exception: Exception if Filter check failed
"""
try:
logging.debug("search Filter for %s to %s", typ, plugin)
logging.debug("search Filter for %s to %s at %s Hz", typ, plugin, freq)
foundFilter = False
#go to all Filter in globals.filterList
for i in globals.filterList:
#if Typ/Plugin combination is found
if i["typ"] == typ and i["plugin"] == plugin:
#if Typ/Plugin/Freq combination is found
if i["typ"] == typ and (i["plugin"] == plugin or i['plugin'] == "*") and (i["freq"] == freq or i['freq'] == "*"):
foundFilter = True
logging.debug("found Filter: %s = %s", i["name"], i["regex"])
#Check the RegEX