def main():
args = parse_args()
mountpoints = []
with open('/proc/mounts', 'r') as fp:
for line in fp:
a, mountpoint, fstype, a = line.split(' ', 3)
if fstype in ['ext2', 'ext3', 'ext4', 'xfs']:
mountpoints.append(mountpoint)
template = args.prefix + '.{}.{} {} ' + str(int(time()))
for mp in mountpoints:
stat = os.statvfs(mp)
used = stat.f_frsize * stat.f_blocks - stat.f_bfree * stat.f_bsize
size = stat.f_frsize * stat.f_blocks
if mp == '/':
mp = 'rootfs'
mp = mp.replace('/', '_').lstrip('_')
print(template.format(mp, 'used', used))
print(template.format(mp, 'size', size))
评论列表
文章目录