Skip to content

Commit

Permalink
Hunting for an issue concerning the persistance of bandwidth data.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphwetzel committed Nov 24, 2019
1 parent f2fdc97 commit 1c5beaf
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
23 changes: 14 additions & 9 deletions theonionbox/sections/monitor/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion theonionbox/stamp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__title__ = 'The Onion Box'
__description__ = 'Dashboard to monitor Tor node operations.'
__version__ = '19.2b5'
__stamp__ = '20191123|222417'
__stamp__ = '20191124|221837'
1 change: 0 additions & 1 deletion theonionbox/tob/apps/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions theonionbox/tob/nodes/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions theonionbox/tob/persistor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1c5beaf

Please sign in to comment.