mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-04-19 08:55:12 +00:00
Update dashboard.py
This commit is contained in:
parent
3ec97021bd
commit
bd714223ce
@ -20,6 +20,8 @@ from modules.Log import Log
|
|||||||
from modules.DashboardLogger import DashboardLogger
|
from modules.DashboardLogger import DashboardLogger
|
||||||
from modules.PeerJobLogger import PeerJobLogger
|
from modules.PeerJobLogger import PeerJobLogger
|
||||||
from modules.PeerJob import PeerJob
|
from modules.PeerJob import PeerJob
|
||||||
|
from modules.SystemStatus import SystemStatus
|
||||||
|
SystemStatus = SystemStatus()
|
||||||
|
|
||||||
DASHBOARD_VERSION = 'v4.2.0'
|
DASHBOARD_VERSION = 'v4.2.0'
|
||||||
|
|
||||||
@ -271,7 +273,6 @@ class PeerShareLinks:
|
|||||||
self.Links.append(PeerShareLink(*link))
|
self.Links.append(PeerShareLink(*link))
|
||||||
|
|
||||||
def getLink(self, Configuration: str, Peer: str) -> list[PeerShareLink]:
|
def getLink(self, Configuration: str, Peer: str) -> list[PeerShareLink]:
|
||||||
# self.__getSharedLinks()
|
|
||||||
return list(filter(lambda x : x.Configuration == Configuration and x.Peer == Peer, self.Links))
|
return list(filter(lambda x : x.Configuration == Configuration and x.Peer == Peer, self.Links))
|
||||||
|
|
||||||
def getLinkByID(self, ShareID: str) -> list[PeerShareLink]:
|
def getLinkByID(self, ShareID: str) -> list[PeerShareLink]:
|
||||||
@ -1132,6 +1133,7 @@ class WireguardConfiguration:
|
|||||||
if not all:
|
if not all:
|
||||||
if network.version == 6 and count > 255:
|
if network.version == 6 and count > 255:
|
||||||
break
|
break
|
||||||
|
|
||||||
return True, availableAddress
|
return True, availableAddress
|
||||||
|
|
||||||
def getRealtimeTrafficUsage(self):
|
def getRealtimeTrafficUsage(self):
|
||||||
@ -2494,7 +2496,6 @@ def API_addPeers(configName):
|
|||||||
if bulkAdd:
|
if bulkAdd:
|
||||||
if type(preshared_key_bulkAdd) is not bool:
|
if type(preshared_key_bulkAdd) is not bool:
|
||||||
preshared_key_bulkAdd = False
|
preshared_key_bulkAdd = False
|
||||||
|
|
||||||
if type(bulkAddAmount) is not int or bulkAddAmount < 1:
|
if type(bulkAddAmount) is not int or bulkAddAmount < 1:
|
||||||
return ResponseObject(False, "Please specify amount of peers you want to add")
|
return ResponseObject(False, "Please specify amount of peers you want to add")
|
||||||
if not availableIps[0]:
|
if not availableIps[0]:
|
||||||
@ -2948,76 +2949,8 @@ def API_Email_PreviewBody():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return ResponseObject(False, message=str(e))
|
return ResponseObject(False, message=str(e))
|
||||||
|
|
||||||
from modules.SystemStatus import SystemStatus
|
|
||||||
SystemStatus = SystemStatus()
|
|
||||||
|
|
||||||
@app.get(f'{APP_PREFIX}/api/systemStatus')
|
@app.get(f'{APP_PREFIX}/api/systemStatus')
|
||||||
def API_SystemStatus():
|
def API_SystemStatus():
|
||||||
# cpu_percpu = psutil.cpu_percent(interval=0.5, percpu=True)
|
|
||||||
# cpu = psutil.cpu_percent(interval=0.5)
|
|
||||||
# memory = psutil.virtual_memory()
|
|
||||||
# swap_memory = psutil.swap_memory()
|
|
||||||
# disks = psutil.disk_partitions()
|
|
||||||
# network = psutil.net_io_counters(pernic=True, nowrap=True)
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# status = {
|
|
||||||
# "cpu": {
|
|
||||||
# "cpu_percent": cpu,
|
|
||||||
# "cpu_percent_per_cpu": cpu_percpu,
|
|
||||||
# },
|
|
||||||
# "memory": {
|
|
||||||
# "virtual_memory": {
|
|
||||||
# "total": memory.total,
|
|
||||||
# "available": memory.available,
|
|
||||||
# "percent": memory.percent
|
|
||||||
# },
|
|
||||||
# "swap_memory": {
|
|
||||||
# "total": swap_memory.total,
|
|
||||||
# "used": swap_memory.used,
|
|
||||||
# "percent": swap_memory.percent
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# "disk": {},
|
|
||||||
# "network": {},
|
|
||||||
# "process": {
|
|
||||||
# "cpu_top_10": [],
|
|
||||||
# "memory_top_10": []
|
|
||||||
# },
|
|
||||||
# "SystemStatus": systemStatus
|
|
||||||
# }
|
|
||||||
# for d in disks:
|
|
||||||
# detail = psutil.disk_usage(d.mountpoint)
|
|
||||||
# status['disk'][d.mountpoint] = {
|
|
||||||
# "total": detail.total,
|
|
||||||
# "used": detail.used,
|
|
||||||
# "free": detail.free,
|
|
||||||
# "percent": detail.percent
|
|
||||||
# }
|
|
||||||
# for i in network.keys():
|
|
||||||
# status["network"][i] = {
|
|
||||||
# "byte_sent": network[i].bytes_sent,
|
|
||||||
# "byte_recv": network[i].bytes_recv
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# while True:
|
|
||||||
# try:
|
|
||||||
# processes = list(psutil.process_iter())
|
|
||||||
# status["process"]["cpu_top_10"] = sorted(list(map(lambda x : {
|
|
||||||
# "name": x.name(),
|
|
||||||
# "command": " ".join(x.cmdline()),
|
|
||||||
# "pid": x.pid,
|
|
||||||
# "cpu_percent": x.cpu_percent()
|
|
||||||
# }, processes)), key=lambda x : x['cpu_percent'], reverse=True)[:10]
|
|
||||||
# status["process"]["memory_top_10"] = sorted(list(map(lambda x : {
|
|
||||||
# "name": x.name(),
|
|
||||||
# "command": " ".join(x.cmdline()),
|
|
||||||
# "pid": x.pid,
|
|
||||||
# "memory_percent": x.memory_percent()
|
|
||||||
# }, processes)), key=lambda x : x['memory_percent'], reverse=True)[:10]
|
|
||||||
# break
|
|
||||||
# except Exception as e:
|
|
||||||
# continue
|
|
||||||
return ResponseObject(data=SystemStatus)
|
return ResponseObject(data=SystemStatus)
|
||||||
|
|
||||||
@app.get(f'{APP_PREFIX}/api/protocolsEnabled')
|
@app.get(f'{APP_PREFIX}/api/protocolsEnabled')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user