Skip to content

Commit

Permalink
Merge pull request #372 from Schrolli91/v2.4
Browse files Browse the repository at this point in the history
V2.4
  • Loading branch information
Schrolli91 authored Aug 16, 2018
2 parents 25365b0 + dbaedf8 commit 56f62c3
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 126 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ log/
\.pydevproject

\.settings/

\.idea/
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# Changelog

### __[v2.4]__ - 17.08.2018
##### Added
- Config Eintrag um Port für MySQL Plugin festzulegen [#345](https://github.com/Schrolli91/BOSWatch/pull/345)
- FMS und ZVEI Support für Pushover Plugin [#352](https://github.com/Schrolli91/BOSWatch/pull/352)
- Benutzerdefinierte Nachrichten für Pushover Plugin in config [#352](https://github.com/Schrolli91/BOSWatch/pull/352)
##### Changed
- multicastAlarm Plugin - RICs die von multicastAlarm genutzt werden, müssen nicht mehr in der config bei allow_ric bzw. filter_range_start/filter_range_end berücksichtigt werden. [#357](https://github.com/Schrolli91/BOSWatch/pull/357)
- FFAgent Plugin - Debug Logging für die alarmHeaders eingebaut zwecks Troubleshooting [#354](https://github.com/Schrolli91/BOSWatch/pull/354)
- multicastAlarm Plugin - Buffer nach jedem Alarm löschen - erlaubt in kombination mit "doubleFilter_check_msg" die Verwendung in Netzen, die zwischen multicastAlarm RICs auch normale Alarme senden. #370(https://github.com/Schrolli91/BOSWatch/pull/370)
##### Fixed
- Fehler beim Auslesen der netIdent_RIC im MySQL Plugin [#347](https://github.com/Schrolli91/BOSWatch/pull/347)
- FFAgent Plugin - Typo bei alarmHeaders für Live Betrieb gefixt [#354](https://github.com/Schrolli91/BOSWatch/pull/354)


### __[2.3]__ - 22.12.2017
### __[v2.3]__ - 22.12.2017
##### Added
- zuschaltbare POCSAG Multicast-Alarm Funktionalität [#307](https://github.com/Schrolli91/BOSWatch/pull/307)
- Flag in Config um nur letzte Net Ident oder gesamte Historie zu speichern [#317](https://github.com/Schrolli91/BOSWatch/pull/317)
Expand Down Expand Up @@ -48,7 +61,7 @@
Zum schreiben des Changelog's siehe:
http://keepachangelog.com/de/1.0.0/

### __[version]__ - date
### __[v#.#]__ - date
##### Added
##### Changed
##### Deprecated
Expand Down
4 changes: 3 additions & 1 deletion citest/config.httpRequest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ template = 0

[MySQL]
# MySQL configuration
#default port: 3306
dbserver = localhost
dbuser = root
dbport = 3306
dbuser = boswatch
dbpassword = root
database = boswatch

Expand Down
2 changes: 2 additions & 0 deletions citest/config.mysql.ini
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ template = 0

[MySQL]
# MySQL configuration
#default port: 3306
dbserver = localhost
dbport = 3306
dbuser = boswatch
dbpassword = root
database = boswatch
Expand Down
29 changes: 21 additions & 8 deletions config/config.template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ multicastAlarm = 0
# time limit for alarms that do not belong to the multicastAlarm sequence in seconds
multicastAlarm_ignore_time = 15

# multicastAlarm delimiter RIC (usually used as a starting point for a alarm sequence) (can be empty)
# multicastAlarm delimiter RIC (usually used as a starting point for a alarm sequence). Needs to be empty if multicastAlarms are interrupted by normal alarms.
multicastAlarm_delimiter_ric =

# multicastAlarm RIC that is used to send the text message
Expand Down Expand Up @@ -191,7 +191,9 @@ template = 0

[MySQL]
# MySQL configuration
#default port: 3306
dbserver = localhost
dbport = 3306
dbuser = boswatch
dbpassword = root
database = boswatch
Expand Down Expand Up @@ -375,14 +377,24 @@ api_key =
# Pushover Userkey or Groupkey to receive message
user_key =

# Title of the message
title = BOSWatch Message

# Section for POCSAG
# Adapt Pocsag Subric (a,b,c,d) to Pushover Priorities (see https://pushover.net/api#priority)
SubA = 0
SubB = 2
SubC = 1
SubD = 0
SubA = 1
SubB = 1
SubC = 2
SubD = -2
poc_title = Alarm: %RIC%%LPAR%%FUNCCHAR%%RPAR%
poc_message = %DATE% %TIME% - %DESCR%: %MSG%

# Section for ZVEI
zvei_prio = 1
zvei_title = Alarm: %ZVEI%
zvei_message = %DATE% %TIME%: %ZVEI%

# Section for FMS
fms_prio = 1
fms_title = FMS: %FMS%
fms_message = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI% %LPAR%%DESCR%%RPAR%

# how often should Pushover re-alert in seconds (emergency-messages)
retry = 30
Expand Down Expand Up @@ -474,6 +486,7 @@ test2 = 123456
# %RIC% = POCSAG RIC
# %FUNC% = POCSAG function/Subric (1-4)
# %FUNCCHAR% = POCSAG function/Subric als character (a-d)
# %FUNCTEXT% = POCSAG static Subric message (see [POC])
# %MSG% = Message of the POCSAG telegram
# %BITRATE% = Bitrate of the POCSAG telegram
# %DESCR% = Description, if description-module is used
Expand Down
36 changes: 18 additions & 18 deletions exampleAddOns/simpleWeb/mysql.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
function __construct($host, $user, $password, $database, $show_error = 1)
{
$this->show_error = $show_error;
@$this->conn = mysql_connect($host, $user, $password);
@$this->conn = mysqli_connect($host, $user, $password);
if ($this->conn == false)
{
$this->error("Keine Verbindung zum Datenbank Server!", mysql_error());
$this->error("Keine Verbindung zum Datenbank Server!", mysqli_error($this->conn));
return false;
}

if (!@mysql_select_db($database, $this->conn))
if (!@mysqli_select_db($this->conn, $database))
{
$this->error("Datenbank nicht gefunden!", mysql_error());
$this->error("Datenbank nicht gefunden!", mysqli_error($this->conn));
return false;
}
return true;
Expand All @@ -41,17 +41,17 @@ function __construct($host, $user, $password, $database, $show_error = 1)
/**
* Database::query()
*
* F�hrt einen MySQL Query aus
* Fuehrt einen MySQL Query aus
*
* @param mixed $query Auszuf�hrender Query
* @param mixed $query Auszufuehrender Query
* @return Result-Handler/FALSE
*/
function query($query)
{
$this->result = @mysql_query($query, $this->conn);
$this->result = @mysqli_query($this->conn, $query);
if ($this->result == false)
{
$this->error("Fehlerhafte Datenbank Anfrage!", mysql_error());
$this->error("Fehlerhafte Datenbank Anfrage!", mysqli_error($this->conn));
return false;
}
return $this->result;
Expand All @@ -60,51 +60,51 @@ function query($query)
/**
* Database::fetchAssoc()
*
* Liefert alle gefundnen Datens�tze als Assoc
* Liefert alle gefundnen Datensaetze als Assoc
*
* @param mixed $result Externer Result-Handler
* @return gefundene Datens�tze als Assoc
* @return gefundene Datensaetze als Assoc
*/
function fetchAssoc($result = null)
{
if ($result != null)
{
return @mysql_fetch_assoc($result);
return @mysqli_fetch_assoc($result);
} else
{
return @mysql_fetch_assoc($this->result);
return @mysqli_fetch_assoc($this->result);
}
}

/**
* Database::count()
*
* Z�hlt alle gefundenen Datens�tze
* Zaehlt alle gefundenen Datensaetze
*
* @param mixed $result Externer Result-Handler
* @return Anzahl gefundener Datens�tze
* @return Anzahl gefundener Datensaetze
*/
function count($result = null)
{
if ($result != null)
{
return @mysql_num_rows($result);
return @mysqli_num_rows($result);
} else
{
return @mysql_num_rows($this->result);
return @mysqli_num_rows($this->result);
}
}

/**
* Database::closeConnection()
*
* Schlie�t die bestehende MySQL Verbindung
* Schliesst die bestehende MySQL Verbindung
*
* @return TRUE/FALSE
*/
function closeConnection()
{
if (!@mysql_close($this->conn))
if (!@mysqli_close($this->conn))
{
$this->error("Verbindung zur Datenbank konnte nicht getrennt werden!", mysql_error());
return false;
Expand Down
14 changes: 13 additions & 1 deletion includes/decoders/poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,23 @@ def isAllowed(poc_id):
return True
else:
allowed = 0
# 5.) Implementation for multicastAlarm
if globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"):
if poc_id in globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"):
logging.info("RIC %s as multicastAlarm delimiter", poc_id)
return True
else:
allowed = 0
if globalVars.config.get("multicastAlarm", "multicastAlarm_ric"):
if poc_id in globalVars.config.get("multicastAlarm", "multicastAlarm_ric"):
logging.info("RIC %s as multicastAlarm message", poc_id)
return True
else:
allowed = 0

if allowed == 0:
return False
return True

##
#
# POCSAG decoder function
Expand Down
4 changes: 2 additions & 2 deletions includes/globalVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"""

# version info
versionNr = "2.3"
versionNr = "2.4"
branch = "master"
buildDate = "22/12/2017"
buildDate = "17.08.2018"


# Global variables
Expand Down
4 changes: 3 additions & 1 deletion includes/multicastAlarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def newEntrymultiList(data):
timestamp = int(time.time())
# multicastAlarm processing if enabled and delimiter RIC has been received
if data['ric'] == globalVars.config.get("multicastAlarm", "multicastAlarm_delimiter_ric"):
multiList = []
del multiList[:]
logging.debug("delimiter RIC received - buffer cleared")
else:
multiList.append([data, timestamp])
Expand Down Expand Up @@ -61,3 +61,5 @@ def multicastAlarmExec(freq, data):
except:
logging.error("processing alarm failed")
logging.debug("processing alarm failed", exc_info=True)
del multiList[:]
logging.debug("multicastAlarm finished - buffer cleared")
3 changes: 2 additions & 1 deletion plugins/FFAgent/FFAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ def run(typ,freq,data):
"selectiveCallCode": selectiveCallCode,
"hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()
}
logging.debug(alarmHeaders)

if globalVars.config.get("FFAgent", "live") == "1":
r = requests.post(url, data=alarmData, headers=headers, verify=serverCertFile, cert=(clientCertFile, clientCertPass))
r = requests.post(url, data=alarmData, headers=alarmHeaders, verify=serverCertFile, cert=(clientCertFile, clientCertPass))
else:
r = requests.post(url, data=alarmData, headers=alarmHeaders, verify=serverCertFile)

Expand Down
4 changes: 2 additions & 2 deletions plugins/MySQL/MySQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def run(typ,freq,data):
# Connect to MySQL
#
logging.debug("connect to MySQL")
connection = mysql.connector.connect(host = globalVars.config.get("MySQL","dbserver"), user = globalVars.config.get("MySQL","dbuser"), passwd = globalVars.config.get("MySQL","dbpassword"), db = globalVars.config.get("MySQL","database"), charset='utf8')
connection = mysql.connector.connect(host = globalVars.config.get("MySQL","dbserver"), port = globalVars.config.get("MySQL","dbport"), user = globalVars.config.get("MySQL","dbuser"), passwd = globalVars.config.get("MySQL","dbpassword"), db = globalVars.config.get("MySQL","database"), charset='utf8')
cursor = connection.cursor()
except:
logging.error("cannot connect to MySQL")
Expand All @@ -111,7 +111,7 @@ def run(typ,freq,data):

elif typ == "POC":
if isSignal(data["ric"]):
if globalVars.config.getint("POC","netIdent_histry"):
if globalVars.config.getint("POC","netIdent_history"):
cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(), '"+data["ric"]+"');")
else:
cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = '"+data["ric"]+"';")
Expand Down
Loading

0 comments on commit 56f62c3

Please sign in to comment.