Skip to content

Commit 2cd6fa1

Browse files
fred-yu-2013stiartsly
authored andcommitted
CU-3nv249z - Add memory and storage details in the node info.
1 parent 24ea121 commit 2cd6fa1

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ google-api-python-client
1414
google-auth
1515
google-auth-oauthlib
1616
google-auth-httplib2
17+
psutil==5.9.2
1718
pyftpdlib==1.5.6
1819
PyOpenSSL==22.0.0
1920
pysendfile==2.0.1

src/modules/about/about.py

+14
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@ def get_commit_id(self):
3131
}
3232

3333
def get_node_info(self):
34+
import shutil
35+
import psutil
36+
3437
from src.modules.auth.user import UserManager
3538
from src.modules.subscription.vault import VaultManager
3639
from src.modules.backup.backup import BackupManager
3740

41+
def get_last_access_time():
42+
vaults = VaultManager().get_all_vaults()
43+
return max(list(map(lambda v: v.get_latest_access_time(), vaults)))
44+
3845
owner_did, credential = Provider.get_verified_owner_did()
3946
auth = Auth()
47+
memory, storage = psutil.virtual_memory(), shutil.disk_usage("/")
48+
4049
return {
4150
"service_did": auth.did_str,
4251
"owner_did": owner_did,
@@ -49,4 +58,9 @@ def get_node_info(self):
4958
"user_count": UserManager().get_user_count(),
5059
"vault_count": VaultManager().get_vault_count(),
5160
"backup_count": BackupManager().get_backup_count(),
61+
"latest_access_time": get_last_access_time(),
62+
"memory_used": memory.available,
63+
"memory_total": memory.total,
64+
"storage_used": storage.used,
65+
"storage_total": storage.total
5266
}

src/modules/subscription/vault.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_end_time(self):
6262
return self.end_time
6363

6464
def get_latest_access_time(self):
65-
return int(self.latest_access_time) if hasattr(self, VAULT_SERVICE_LATEST_ACCESS_TIME) else -1
65+
return int(self.latest_access_time) if hasattr(self, VAULT_SERVICE_LATEST_ACCESS_TIME) and self.latest_access_time else -1
6666

6767

6868
class AppSpaceDetector:

src/view/about.py

+5
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ def get(self):
107107
"user_count": <int>,
108108
"vault_count": <int>,
109109
"backup_count": <int>,
110+
"latest_access_time": <int>,
111+
"memory_used": <int>,
112+
"memory_total": <int>,
113+
"storage_used": <int>,
114+
"storage_total": <int>
110115
}
111116
112117
**Response Error**:

0 commit comments

Comments
 (0)