#! /usr/bin/env python
# coding:utf8
import psutil
import math
#获取各个挂载点及对应的分区
print psutil.disk_partitions()
[sdiskpart(device='/dev/mapper/debian-root', mountpoint='/', fstype='ext4', opts='rw,relatime,errors=remount-ro,data=ordered')]
#获取根分区 / 的信息
psutil.disk_usage('/')
sdiskusage(total=30259671040, used=18238128128, free=10460844032, percent=63.5)
#获取各个挂载分区的使用百分比
[{i.mountpoint:int(math.ceil(psutil.disk_usage(i.mountpoint).percent))} for i in psutil.disk_partitions()]
网友评论