From fe1b6e926964b2f1aef536151d97d662ddf33c04 Mon Sep 17 00:00:00 2001 From: jlashner Date: Wed, 5 Feb 2020 17:26:44 -0800 Subject: [PATCH 1/3] Fixed pysmurf monitor numpy bug --- agents/pysmurf_monitor/pysmurf_monitor.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/agents/pysmurf_monitor/pysmurf_monitor.py b/agents/pysmurf_monitor/pysmurf_monitor.py index eade0a7f7..4f29fd784 100644 --- a/agents/pysmurf_monitor/pysmurf_monitor.py +++ b/agents/pysmurf_monitor/pysmurf_monitor.py @@ -101,6 +101,9 @@ def datagramReceived(self, _data, addr): self.log.info("New file: {fname}", fname=data['payload']['path']) d = data['payload'].copy() + if (d['format'] == 'npy') and (not d['path'].endswith('.npy')): + d['path'] += '.npy' + # Adds additional db info to dict d['timestamp'] = datetime.datetime.utcfromtimestamp(d['timestamp']) d['md5sum'] = get_md5sum(d['path']) From 1c33e5ceb52d7d56ad85f3988b8726e388d9603e Mon Sep 17 00:00:00 2001 From: jlashner Date: Sun, 9 Feb 2020 14:53:58 -0800 Subject: [PATCH 2/3] Add argument to try reconnecting on db timeout --- agents/pysmurf_monitor/pysmurf_monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/pysmurf_monitor/pysmurf_monitor.py b/agents/pysmurf_monitor/pysmurf_monitor.py index 4f29fd784..ea231654e 100644 --- a/agents/pysmurf_monitor/pysmurf_monitor.py +++ b/agents/pysmurf_monitor/pysmurf_monitor.py @@ -72,7 +72,7 @@ def __init__(self, agent, args): if db_host is not None: sql_config['host'] = db_host - self.dbpool = adbapi.ConnectionPool('mysql.connector', **sql_config) + self.dbpool = adbapi.ConnectionPool('mysql.connector', **sql_config, cp_reconnect=True) def _add_file_callback(self, res, d): """Callback for when a file is successfully added to DB""" From fb6fea0cf0b047bff6aed141bb31b37390fd1f9b Mon Sep 17 00:00:00 2001 From: jlashner Date: Sun, 16 Feb 2020 15:03:34 -0500 Subject: [PATCH 3/3] Removed failure return from database errback --- agents/pysmurf_monitor/pysmurf_monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/pysmurf_monitor/pysmurf_monitor.py b/agents/pysmurf_monitor/pysmurf_monitor.py index ea231654e..505c2cd80 100644 --- a/agents/pysmurf_monitor/pysmurf_monitor.py +++ b/agents/pysmurf_monitor/pysmurf_monitor.py @@ -81,7 +81,7 @@ def _add_file_callback(self, res, d): def _add_file_errback(self, failure: Failure, d): """Errback for when there is an exception when adding file to DB""" self.log.error(f"ERROR!!! {d['path']} was not added to the database") - return failure + self.log.error(f"Failure:\n{failure}") def datagramReceived(self, _data, addr): """