diff --git a/theonionbox/sections/monitor/monitor.js b/theonionbox/sections/monitor/monitor.js index a3ed4f2..66cc96b 100644 --- a/theonionbox/sections/monitor/monitor.js +++ b/theonionbox/sections/monitor/monitor.js @@ -134,8 +134,6 @@ monitor_handler.prototype.process = function(data, timedelta) { var data_point; var DOM_changed = false; - // console.log(data); - for (var key in data) { if (!data.hasOwnProperty(key)) { //The current property is not a direct property of p @@ -220,18 +218,20 @@ monitor_handler.prototype.process = function(data, timedelta) { var ia = $.inArray(key, monitor_keys); if (ia > -1) { - DOM_changed = connect_canvas(key) || DOM_changed; + // console.log(key) + DOM_changed = connect_canvas(key) || DOM_changed; - if (monitor_read_data[key].length === 0) { - monitor_read_data[key].append(data_points[data_point].m - (monitor_intervals[key] * 1000), 0); - } + if (data_points.length > 0) { + if (monitor_read_data[key].data.length === 0) { + monitor_read_data[key].append(data_points[0].m - (monitor_intervals[key] * 1000), 0); + } - if (monitor_written_data[key].length === 0) { - monitor_written_data[key].append(data_points[data_point].m - (monitor_intervals[key] * 1000), 0); + if (monitor_written_data[key].data.length === 0) { + monitor_written_data[key].append(data_points[0].m - (monitor_intervals[key] * 1000), 0); + } } - for (data_point in data_points) { monitor_read_data[key].append(data_points[data_point].m, data_points[data_point].r / monitor_intervals[key]); monitor_written_data[key].append(data_points[data_point].m, data_points[data_point].w / monitor_intervals[key]); @@ -501,6 +501,11 @@ $(document).ready(function() { function connect_canvas(tag) { + // only show chart with at least 3 points (to avoid empty charts!) + if (monitor_read_data[tag].data.length < 3) { + return false; + } + var glide = $("#monitor_glide_" + tag); if (glide.length > 0) { return false; diff --git a/theonionbox/sections/network_bandwidth/network_bandwidth.js b/theonionbox/sections/network_bandwidth/network_bandwidth.js index 0e4b13d..b31a103 100644 --- a/theonionbox/sections/network_bandwidth/network_bandwidth.js +++ b/theonionbox/sections/network_bandwidth/network_bandwidth.js @@ -410,7 +410,7 @@ $(document).ready(function() { function connect_history_canvas(tag) { - console.log(tag); + // console.log(tag); var glide = $("#history_glide_" + tag); if (glide.length > 0) { diff --git a/theonionbox/stamp.py b/theonionbox/stamp.py index 0cd7483..9c14e65 100644 --- a/theonionbox/stamp.py +++ b/theonionbox/stamp.py @@ -1,4 +1,4 @@ __title__ = 'The Onion Box' __description__ = 'Dashboard to monitor Tor node operations.' __version__ = '19.2b5' -__stamp__ = '20191123|222417' \ No newline at end of file +__stamp__ = '20191124|221837' \ No newline at end of file diff --git a/theonionbox/tob/apps/dashboard.py b/theonionbox/tob/apps/dashboard.py index 4e34ed0..d0f9075 100644 --- a/theonionbox/tob/apps/dashboard.py +++ b/theonionbox/tob/apps/dashboard.py @@ -749,7 +749,6 @@ def post_data(self, session): if len(retval) > 0: return_data_dict['mon'][interval] = retval except Exception as e: - # print(e) pass # if ('network_bw' not in session) or (session['network_bw'] == 0): diff --git a/theonionbox/tob/nodes/node.py b/theonionbox/tob/nodes/node.py index 2a1e21f..5e6c64c 100644 --- a/theonionbox/tob/nodes/node.py +++ b/theonionbox/tob/nodes/node.py @@ -159,6 +159,9 @@ def shutdown(self): log = logging.getLogger('theonionbox') log.debug("Shutting down controller to '{}'...".format(self._id)) + if self._bandwidth is not None: + self._bandwidth.shutdown() + self.disconnect() # if self._onionoo is not None: diff --git a/theonionbox/tob/persistor.py b/theonionbox/tob/persistor.py index 22a66e1..99268a3 100644 --- a/theonionbox/tob/persistor.py +++ b/theonionbox/tob/persistor.py @@ -66,9 +66,9 @@ def __init__(self, storage: Storage, fingerprint: str): self.path = None self.fp = None + log = logging.getLogger('theonionbox') if len(fingerprint) == 0: - log = logging.getLogger('theonionbox') log.debug('Skipped registration for persistance of node with fingerprint of length = 0.') return @@ -85,7 +85,6 @@ def __init__(self, storage: Storage, fingerprint: str): with conn: conn.execute("INSERT OR IGNORE INTO nodes(fp) VALUES(?);", (fingerprint,)) except Exception as exc: - log = logging.getLogger('theonionbox') log.warning('Failed to register {}... for persistance. {}'.format(fingerprint[:6], exc)) return @@ -139,6 +138,8 @@ def persist(self, interval: str, timestamp: float, connection.execute("INSERT INTO bandwidth(fp, interval, timestamp, read, write) VALUES(?, ?, ?, ?, ?)", (self.fp, interval, timestamp, read, write)) except Exception as e: + log = logging.getLogger('theonionbox') + log.warning(f'Failed to open persist bandwidth data for fingerprint {self.fp}: {e}') return False return True