mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-04 15:50:30 +01:00
add firEmergency-plugin
This commit is contained in:
parent
bdf670bd46
commit
70094d55a3
|
|
@ -67,8 +67,10 @@ filter_range_end = 9999999
|
|||
[Plugins]
|
||||
#can take on or off the plugins (0|1)
|
||||
MySQL = 0
|
||||
BosMon = 0
|
||||
httpRequest = 0
|
||||
eMail = 0
|
||||
BosMon = 0
|
||||
firEmergency = 0
|
||||
|
||||
# for developing template-module
|
||||
template = 0
|
||||
|
|
@ -86,20 +88,6 @@ tableZVEI = bos_zvei
|
|||
tablePOC = bos_pocsag
|
||||
|
||||
|
||||
[BosMon]
|
||||
#Server as IP of DNS-Name (without http://)
|
||||
#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 =
|
||||
|
||||
|
||||
[httpRequest]
|
||||
#URL without http://
|
||||
|
||||
|
|
@ -125,6 +113,25 @@ zvei_url =
|
|||
poc_url =
|
||||
|
||||
|
||||
[BosMon]
|
||||
#Server as IP of DNS-Name (without http://)
|
||||
#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 =
|
||||
|
||||
|
||||
[firEmergency]
|
||||
firserver = localhost
|
||||
firport = 9001
|
||||
|
||||
|
||||
#####################
|
||||
##### Not ready yet #
|
||||
#####################
|
||||
|
|
|
|||
93
plugins/firEmergency/firEmergency.py
Normal file
93
plugins/firEmergency/firEmergency.py
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: cp1252 -*-
|
||||
|
||||
"""
|
||||
firEmergency-Plugin to dispatch ZVEI- and POCSAG - messages to firEmergency
|
||||
|
||||
@autor: Smith-fms
|
||||
|
||||
@requires: firEmergency-Configuration has to be set in the config.ini
|
||||
"""
|
||||
|
||||
import logging # Global logger
|
||||
import socket
|
||||
|
||||
from includes import globals # Global variables
|
||||
|
||||
##
|
||||
#
|
||||
# Main function of firEmergency-plugin
|
||||
# will be called by the alarmHandler
|
||||
#
|
||||
def run(typ,freq,data):
|
||||
"""
|
||||
This function is the implementation of the firEmergency-Plugin.
|
||||
It will send the data to an firEmergency-Instance.
|
||||
|
||||
The configuration for the firEmergency-Connection is set in the config.ini.
|
||||
|
||||
@type typ: string (ZVEI|POC)
|
||||
@param typ: Typ of the dataset for sending to firEmergency
|
||||
@type data: map of data (structure see interface.txt)
|
||||
@param data: Contains the parameter for dispatch to firEmergency.
|
||||
@type freq: string
|
||||
@keyword freq: frequency is not used in this plugin
|
||||
|
||||
@requires: firEmergency-Configuration has to be set in the config.ini
|
||||
|
||||
@return: nothing
|
||||
@exception: Exception if ConfigParser failed
|
||||
@exception: Exception ifconnect to firEmergency failed
|
||||
@exception: Exception if sending the data failed
|
||||
"""
|
||||
try:
|
||||
#
|
||||
#ConfigParser
|
||||
#
|
||||
logging.debug("reading config file")
|
||||
try:
|
||||
for key,val in globals.config.items("firEmergency"):
|
||||
logging.debug(" - %s = %s", key, val)
|
||||
except:
|
||||
logging.exception("cannot read config file")
|
||||
|
||||
try:
|
||||
#
|
||||
# connect to firEmergency
|
||||
#
|
||||
firSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
firSocket.connect((globals.config.get("firEmergency", "firserver"), globals.config.getint("firEmergency", "firport")))
|
||||
except:
|
||||
logging.exception("cannot connect to firEmergency")
|
||||
else:
|
||||
#
|
||||
# Format given data-structure to xml-string for firEmergency
|
||||
#
|
||||
if typ == "FMS":
|
||||
logging.debug("FMS not supported by firEmgency")
|
||||
|
||||
elif typ == "ZVEI":
|
||||
logging.debug("ZVEI to firEmergency")
|
||||
try:
|
||||
firXML = "<event>\n<address>"+data["zvei"]+"</address>\n<message>"+data["zvei"]+" alarmiert.</message>\n</event>\n"
|
||||
firSocket.send(firXML)
|
||||
except:
|
||||
logging.exception("ZVEI to firEmergency failed")
|
||||
|
||||
elif typ == "POC":
|
||||
logging.debug("POC to firEmergency")
|
||||
try:
|
||||
firXML = "<event>\n<address>"+data["ric"]+"</address>\n<message>"+data["msg"]+"</message>\n</event>\n"
|
||||
firSocket.send(firXML)
|
||||
except:
|
||||
logging.exception("POC to firEmergency failed")
|
||||
|
||||
else:
|
||||
logging.warning("Invalid Typ: %s", typ)
|
||||
|
||||
finally:
|
||||
logging.debug("close firEmergency-Connection")
|
||||
firSocket.close()
|
||||
|
||||
except:
|
||||
logging.exception("unknown error")
|
||||
Loading…
Reference in a new issue