From cb0fd5371367475df9de145296391ae88e3c2b41 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 3 Oct 2017 18:26:16 +0200 Subject: [PATCH] insert history flag for netIdent --- config/config.template.ini | 2 ++ plugins/MySQL/MySQL.py | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index 7a959f2..1a10636 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -128,6 +128,8 @@ ricd = Unwetter # RIC for net identification # Usually sent periodically, separated by comma netIdent_ric = 0174760, 1398098 +# you can hold one entry per netIdent_ric [0] or the whole history [1] +netIdent_history = 0 [Filters] diff --git a/plugins/MySQL/MySQL.py b/plugins/MySQL/MySQL.py index e9d3d7e..e50d719 100644 --- a/plugins/MySQL/MySQL.py +++ b/plugins/MySQL/MySQL.py @@ -111,10 +111,13 @@ def run(typ,freq,data): elif typ == "POC": if isSignal(data["ric"]): - cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = '"+data["ric"]+"';") - if cursor.rowcount == 0: - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(), '"+data["ric"]+"');") - else: + if globalVars.config.getint("POC","netIdent_histry"): + 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"]+"';") + if cursor.rowcount == 0: + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(), '"+data["ric"]+"');") + else: cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tablePOC")+" (time, ric, function, functionChar, msg, bitrate, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["ric"], data["function"], data["functionChar"], data["msg"], data["bitrate"], data["description"])) else: