mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
Merge pull request #1953 from GNS3/revert-1951-disk-usage-all-partitions
Revert "List disk usage for all mount points"
This commit is contained in:
commit
041d2bd2d6
@ -55,9 +55,6 @@ password = gns3
|
|||||||
; Do not forget to allow virbr0 in order for the NAT node to work
|
; Do not forget to allow virbr0 in order for the NAT node to work
|
||||||
allowed_interfaces = eth0,eth1,virbr0
|
allowed_interfaces = eth0,eth1,virbr0
|
||||||
|
|
||||||
; Only allow these mount points to be listed for statistics
|
|
||||||
allowed_mountpoints = /opt,/home
|
|
||||||
|
|
||||||
; Specify the NAT interface to be used by the NAT node
|
; Specify the NAT interface to be used by the NAT node
|
||||||
; Default is virbr0 on Linux (requires libvirt) and vmnet8 for other platforms (requires VMware)
|
; Default is virbr0 on Linux (requires libvirt) and vmnet8 for other platforms (requires VMware)
|
||||||
default_nat_interface = vmnet10
|
default_nat_interface = vmnet10
|
||||||
|
@ -61,27 +61,10 @@ class ServerHandler:
|
|||||||
load_average_percent = [int(x / psutil.cpu_count() * 100) for x in psutil.getloadavg()]
|
load_average_percent = [int(x / psutil.cpu_count() * 100) for x in psutil.getloadavg()]
|
||||||
memory_percent = int(psutil.virtual_memory().percent)
|
memory_percent = int(psutil.virtual_memory().percent)
|
||||||
swap_percent = int(psutil.swap_memory().percent)
|
swap_percent = int(psutil.swap_memory().percent)
|
||||||
disk_usage_percent = []
|
disk_usage_percent = int(psutil.disk_usage('/').percent)
|
||||||
allowed_mountpoints = Config.instance().get_section_config("Server").get("allowed_mountpoints", None)
|
|
||||||
if allowed_mountpoints:
|
|
||||||
allowed_mountpoints = allowed_mountpoints.split(',')
|
|
||||||
for partition in psutil.disk_partitions(all=False):
|
|
||||||
# ignore squashfs partitions or partitions with no fstype or containing 'cdrom' in options.
|
|
||||||
if not partition.fstype or partition.fstype == "squashfs" or 'cdrom' in partition.opts:
|
|
||||||
continue
|
|
||||||
if allowed_mountpoints and partition.mountpoint not in allowed_mountpoints:
|
|
||||||
continue
|
|
||||||
partition_disk_usage_percent = int(psutil.disk_usage(partition.mountpoint).percent)
|
|
||||||
disk_usage_percent.append(
|
|
||||||
{
|
|
||||||
partition.mountpoint: partition_disk_usage_percent
|
|
||||||
}
|
|
||||||
)
|
|
||||||
except psutil.Error as e:
|
except psutil.Error as e:
|
||||||
raise HTTPConflict(text="Psutil error detected: {}".format(e))
|
raise HTTPConflict(text="Psutil error detected: {}".format(e))
|
||||||
response.json(
|
response.json({"memory_total": memory_total,
|
||||||
{
|
|
||||||
"memory_total": memory_total,
|
|
||||||
"memory_free": memory_free,
|
"memory_free": memory_free,
|
||||||
"memory_used": memory_used,
|
"memory_used": memory_used,
|
||||||
"swap_total": swap_total,
|
"swap_total": swap_total,
|
||||||
@ -91,9 +74,7 @@ class ServerHandler:
|
|||||||
"memory_usage_percent": memory_percent,
|
"memory_usage_percent": memory_percent,
|
||||||
"swap_usage_percent": swap_percent,
|
"swap_usage_percent": swap_percent,
|
||||||
"disk_usage_percent": disk_usage_percent,
|
"disk_usage_percent": disk_usage_percent,
|
||||||
"load_average_percent": load_average_percent
|
"load_average_percent": load_average_percent})
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
@Route.get(
|
@Route.get(
|
||||||
r"/debug",
|
r"/debug",
|
||||||
|
@ -68,8 +68,8 @@ SERVER_STATISTICS_SCHEMA = {
|
|||||||
"type": "integer",
|
"type": "integer",
|
||||||
},
|
},
|
||||||
"disk_usage_percent": {
|
"disk_usage_percent": {
|
||||||
"description": "Disk usage in percent for all mountpoints",
|
"description": "Disk usage in percent",
|
||||||
"type": "array",
|
"type": "integer",
|
||||||
},
|
},
|
||||||
"load_average_percent": {
|
"load_average_percent": {
|
||||||
"description": "Average system load over the last 1, 5 and 15 minutes",
|
"description": "Average system load over the last 1, 5 and 15 minutes",
|
||||||
|
Loading…
Reference in New Issue
Block a user