From d24fd41c53582e4489c4e7656cf6b41ba2afc391 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 24 Mar 2020 03:18:05 -0500 Subject: [PATCH] added fd and disk usage stats --- src/lan/client/__init__.py | 2 +- src/onionrstatistics/serializeddata.py | 11 ++++++++++- static-data/www/private/index.html | 18 ++++++++++++++---- static-data/www/shared/main/stats.js | 2 ++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/lan/client/__init__.py b/src/lan/client/__init__.py index 61f627ef..8604f12b 100644 --- a/src/lan/client/__init__.py +++ b/src/lan/client/__init__.py @@ -28,5 +28,5 @@ class Client: def start(self): while True: - print(1, self.peers, type(self.peers)) + #print(1, self.peers, type(self.peers)) better_sleep(1) diff --git a/src/onionrstatistics/serializeddata.py b/src/onionrstatistics/serializeddata.py index fab01298..37fba2e4 100755 --- a/src/onionrstatistics/serializeddata.py +++ b/src/onionrstatistics/serializeddata.py @@ -5,9 +5,11 @@ Serialize various node information import json from gevent import sleep -from psutil import Process +from psutil import Process, WINDOWS from coredb import blockmetadb +from utils.sizeutils import size, human_size +from utils.identifyhome import identify_home import communicator """ This program is free software: you can redistribute it and/or modify @@ -40,6 +42,11 @@ class SerializedData: """Return statistics about our node""" stats = {} proc = Process() + + def get_open_files(): + if WINDOWS: return proc.num_handles() + return proc.num_fds() + try: self._too_many except AttributeError: @@ -53,4 +60,6 @@ class SerializedData: stats['blockQueueCount'] = len(comm_inst.blockQueue) stats['threads'] = proc.num_threads() stats['ramPercent'] = proc.memory_percent() + stats['fd'] = get_open_files() + stats['diskUsage'] = human_size(size(identify_home())) return json.dumps(stats) diff --git a/static-data/www/private/index.html b/static-data/www/private/index.html index 46deb44f..a82bd826 100755 --- a/static-data/www/private/index.html +++ b/static-data/www/private/index.html @@ -235,7 +235,7 @@ --> -
Session Connections
+

Connections

️ Last Received: None since start @@ -251,10 +251,10 @@
Unable to get nodes

-
Blocks
+

Blocks

- + Stored Blocks:
@@ -262,7 +262,7 @@ Blocks in queue:
-
Process Info
+

Process

@@ -273,6 +273,16 @@ RAM usage:
+

Storage

+
+
+ + File descriptors: +
+
+ + Disk Usage: +
diff --git a/static-data/www/shared/main/stats.js b/static-data/www/shared/main/stats.js index f2cd2c99..a33068e4 100755 --- a/static-data/www/shared/main/stats.js +++ b/static-data/www/shared/main/stats.js @@ -104,6 +104,8 @@ var getStats = function(){ queuedBlockDisplay.innerText = stats['blockQueueCount'] document.getElementById('threads').innerText = stats['threads'] document.getElementById('ramPercent').innerText = (stats['ramPercent']).toFixed(2) + '%' + document.getElementById('fileDescriptors').innerText = stats['fd'] + document.getElementById('diskUsage').innerText = stats['diskUsage'] securityLevel.innerText = sec_description_str fetch('/hitcount', { headers: {