added fd and disk usage stats

master
Kevin Froman 2020-03-24 03:18:05 -05:00
parent 8e31d51740
commit d24fd41c53
4 changed files with 27 additions and 6 deletions

View File

@ -28,5 +28,5 @@ class Client:
def start(self): def start(self):
while True: while True:
print(1, self.peers, type(self.peers)) #print(1, self.peers, type(self.peers))
better_sleep(1) better_sleep(1)

View File

@ -5,9 +5,11 @@ Serialize various node information
import json import json
from gevent import sleep from gevent import sleep
from psutil import Process from psutil import Process, WINDOWS
from coredb import blockmetadb from coredb import blockmetadb
from utils.sizeutils import size, human_size
from utils.identifyhome import identify_home
import communicator import communicator
""" """
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@ -40,6 +42,11 @@ class SerializedData:
"""Return statistics about our node""" """Return statistics about our node"""
stats = {} stats = {}
proc = Process() proc = Process()
def get_open_files():
if WINDOWS: return proc.num_handles()
return proc.num_fds()
try: try:
self._too_many self._too_many
except AttributeError: except AttributeError:
@ -53,4 +60,6 @@ class SerializedData:
stats['blockQueueCount'] = len(comm_inst.blockQueue) stats['blockQueueCount'] = len(comm_inst.blockQueue)
stats['threads'] = proc.num_threads() stats['threads'] = proc.num_threads()
stats['ramPercent'] = proc.memory_percent() stats['ramPercent'] = proc.memory_percent()
stats['fd'] = get_open_files()
stats['diskUsage'] = human_size(size(identify_home()))
return json.dumps(stats) return json.dumps(stats)

View File

@ -235,7 +235,7 @@
</div> </div>
</div> </div>
--> -->
<h6>Session Connections</h6> <h4>Connections</h4>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
Last Received: <span id="lastIncoming">None since start</span> Last Received: <span id="lastIncoming">None since start</span>
@ -251,10 +251,10 @@
<pre id="connectedNodes">Unable to get nodes</pre> <pre id="connectedNodes">Unable to get nodes</pre>
</div> </div>
<br> <br>
<h6>Blocks</h6> <h4>Blocks</h4>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<i class="fas fa-hdd"></i> <i class="fas fa-database"></i>
Stored Blocks: <span id="storedBlocks"></span> Stored Blocks: <span id="storedBlocks"></span>
</div> </div>
<div class="column"> <div class="column">
@ -262,7 +262,7 @@
Blocks in queue: <span id="blockQueue"></span> Blocks in queue: <span id="blockQueue"></span>
</div> </div>
</div> </div>
<h6>Process Info</h6> <h4>Process</h4>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<i class="fas fa-microchip"></i> <i class="fas fa-microchip"></i>
@ -273,6 +273,16 @@
RAM usage: <span id="ramPercent"></span> RAM usage: <span id="ramPercent"></span>
</div> </div>
</div> </div>
<h4>Storage</h4>
<div class="columns">
<div class="column">
<i class="fas fa-folder-open"></i>
File descriptors: <span id="fileDescriptors"></span>
</div>
<div class="column">
<i class="fas fa-hdd"></i>
Disk Usage: <span id="diskUsage"></span>
</div>
</div> </div>
</div> </div>

View File

@ -104,6 +104,8 @@ var getStats = function(){
queuedBlockDisplay.innerText = stats['blockQueueCount'] queuedBlockDisplay.innerText = stats['blockQueueCount']
document.getElementById('threads').innerText = stats['threads'] document.getElementById('threads').innerText = stats['threads']
document.getElementById('ramPercent').innerText = (stats['ramPercent']).toFixed(2) + '%' 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 securityLevel.innerText = sec_description_str
fetch('/hitcount', { fetch('/hitcount', {
headers: { headers: {