mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-02-03 22:04:18 +01:00
commit
46dcb79258
|
|
@ -17,20 +17,20 @@ unless you are developer you can use the develop-Branch - may be unstable!
|
|||
- Plugin support for easy Functions extension
|
||||
- Filtering double alarms with adjustable time
|
||||
- Filtering Range of POCSAG RIC´s
|
||||
- Filtering Data for each Typ/Plugin combination
|
||||
- All configurations in seperate config File
|
||||
- Data validation (plausibility test)
|
||||
- Logfiles for better Troubleshooting
|
||||
- verbose/quiet Mode for more/none information
|
||||
|
||||
##### Features for the Future:
|
||||
- extensive filtering options
|
||||
- more Plugins
|
||||
|
||||
|
||||
###Plugins
|
||||
##### Implemented Plugins:
|
||||
- MySQL (insert Data into MySQL Database [FMS|ZVEI|POC])
|
||||
- BosMon (send Data to BosMon Server [POC])
|
||||
- BosMon (send Data to BosMon Server [ZVEI|POC])
|
||||
- httpRequest (send a request to an URL [FMS|ZVEI|POC])
|
||||
|
||||
##### Plugins for the Future:
|
||||
|
|
|
|||
17
boswatch.py
17
boswatch.py
|
|
@ -125,15 +125,26 @@ try:
|
|||
globals.config = ConfigParser.ConfigParser()
|
||||
globals.config.read(globals.script_path+"/config/config.ini")
|
||||
for key,val in globals.config.items("BOSWatch"):
|
||||
logging.debug(" - %s = %s", key, val)
|
||||
logging.debug(" - %s = %s", key, val)
|
||||
except:
|
||||
logging.exception("cannot read config file")
|
||||
else:
|
||||
else:
|
||||
|
||||
try:
|
||||
#set the loglevel of the file handler
|
||||
logging.debug("set loglevel of fileHandler")
|
||||
fh.setLevel(globals.config.getint("BOSWatch","loglevel"))
|
||||
except:
|
||||
logging.exception("cannot set loglevel of fileHandler")
|
||||
|
||||
#load plugins
|
||||
from includes import pluginLoader
|
||||
pluginLoader.loadPlugins()
|
||||
|
||||
#load filters
|
||||
from includes import filter
|
||||
filter.getFilters()
|
||||
|
||||
try:
|
||||
#start rtl_fm
|
||||
logging.debug("starting rtl_fm")
|
||||
|
|
@ -191,4 +202,4 @@ finally:
|
|||
logging.warning("failed in clean-up routine")
|
||||
finally:
|
||||
logging.info("BOSWatch exit()")
|
||||
exit(0)
|
||||
exit(0)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,14 @@
|
|||
########################
|
||||
|
||||
[BOSWatch]
|
||||
#set loglevel for logfile
|
||||
#10 = debug
|
||||
#20 = info
|
||||
#30 = warning
|
||||
#40 = error
|
||||
#50 = critical
|
||||
loglevel = 10
|
||||
|
||||
#time to ignore same alarm in a row (sek)
|
||||
fms_double_ignore_time = 5
|
||||
|
||||
|
|
@ -16,6 +24,12 @@ poc_filter_range_start = 0000000
|
|||
poc_filter_range_end = 9999999
|
||||
|
||||
|
||||
[Filters]
|
||||
#No Filter for a Typ/Plugin Combination = all Data pass
|
||||
#INDIVIDUAL_NAME = TYP;PLUGIN;REGEX
|
||||
zvei_local_filter = ZVEI;template;25[0-9F]{3}
|
||||
|
||||
|
||||
[Plugins]
|
||||
#can take on or off the plugins (0|1)
|
||||
MySQL = 0
|
||||
|
|
@ -42,18 +56,15 @@ tablePOC = bos_pocsag
|
|||
#actually no ssl supported
|
||||
bosmon_server = 192.168.0.1
|
||||
bosmon_port = 80
|
||||
|
||||
#channel-name of typ "Web-Telegramm"
|
||||
bosmon_channel = channel
|
||||
|
||||
#Use this, when BosMon has restricted access
|
||||
bosmon_user =
|
||||
bosmon_password =
|
||||
|
||||
|
||||
#####################
|
||||
##### Not ready yet #
|
||||
#####################
|
||||
|
||||
|
||||
[httpRequest]
|
||||
#URL without http://
|
||||
fms_url = www.google.de
|
||||
|
|
@ -61,6 +72,11 @@ zvei_url = www.google.de
|
|||
poc_url = www.google.de
|
||||
|
||||
|
||||
#####################
|
||||
##### Not ready yet #
|
||||
#####################
|
||||
|
||||
|
||||
[template]
|
||||
data1 = test123
|
||||
data2 = test345
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ from includes import globals # Global variables
|
|||
|
||||
def processAlarm(typ,freq,data):
|
||||
logging.debug("[ ALARM ]")
|
||||
for name, plugin in globals.pluginList.items():
|
||||
logging.debug("call Plugin: %s", name)
|
||||
plugin.run(typ,freq,data)
|
||||
logging.debug("return from: %s", name)
|
||||
for pluginName, plugin in globals.pluginList.items():
|
||||
from includes import filter
|
||||
if filter.checkFilters(data,typ,pluginName):
|
||||
logging.debug("call Plugin: %s", pluginName)
|
||||
plugin.run(typ,freq,data)
|
||||
logging.debug("return from: %s", pluginName)
|
||||
logging.debug("[END ALARM]")
|
||||
50
includes/filter.py
Normal file
50
includes/filter.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: cp1252 -*-
|
||||
|
||||
import logging # Global logger
|
||||
|
||||
import re #Regex for Filter Check
|
||||
|
||||
from includes import globals # Global variables
|
||||
|
||||
|
||||
def getFilters():
|
||||
logging.debug("reading config file")
|
||||
try:
|
||||
for key,val in globals.config.items("Filters"):
|
||||
logging.debug(" - %s = %s", key, val)
|
||||
filter = val.split(";")
|
||||
globals.filterList.append({"name": key, "typ": filter[0], "plugin": filter[1], "regex": filter[2]})
|
||||
except:
|
||||
logging.exception("cannot read config file")
|
||||
|
||||
|
||||
def checkFilters(data,typ,plugin):
|
||||
try:
|
||||
logging.debug("search Filter for %s to %s", typ, plugin)
|
||||
|
||||
#extract the correct data for filtering
|
||||
if typ == "FMS": data = data["fms"]
|
||||
if typ == "ZVEI": data = data["zvei"]
|
||||
if typ == "POC": data = data["poc"]
|
||||
|
||||
foundFilter = False
|
||||
for i in globals.filterList:
|
||||
if i["typ"] == typ and i["plugin"] == plugin:
|
||||
foundFilter = True
|
||||
logging.debug("found Filter: %s = %s", i["name"], i["regex"])
|
||||
if re.search(i["regex"], data):
|
||||
logging.debug("Filter passed: %s", i["name"])
|
||||
return True
|
||||
else:
|
||||
logging.debug("Filter not passed: %s", i["name"])
|
||||
|
||||
if foundFilter:
|
||||
logging.debug("no Filter passed")
|
||||
return False
|
||||
else:
|
||||
logging.debug("no Filter found")
|
||||
return True
|
||||
|
||||
except:
|
||||
logging.exception("Error in Filter checking")
|
||||
|
|
@ -15,5 +15,8 @@ zvei_time_old = 0
|
|||
poc_id_old = 0
|
||||
poc_time_old = 0
|
||||
|
||||
#pluginHandler
|
||||
pluginList = {}
|
||||
#pluginLoader
|
||||
pluginList = {}
|
||||
|
||||
#filter
|
||||
filterList = []
|
||||
|
|
@ -14,6 +14,7 @@ import time #timestamp for doublealarm
|
|||
from includes import globals # Global variables
|
||||
from includes import pluginLoader
|
||||
from includes import alarmHandler
|
||||
from includes import filter
|
||||
|
||||
#create new logger
|
||||
logger = logging.getLogger()
|
||||
|
|
@ -52,6 +53,8 @@ except:
|
|||
|
||||
pluginLoader.loadPlugins()
|
||||
|
||||
filter.getFilters()
|
||||
|
||||
|
||||
# ----- Test Data ----- #
|
||||
#typ = "FMS"
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ def run(typ,freq,data):
|
|||
logging.warning("Invalid Typ: %s", typ)
|
||||
|
||||
except:
|
||||
loggin.exception("cannot send HTTP request")
|
||||
logging.exception("cannot send HTTP request")
|
||||
else:
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue