nicolargo/glances — Issue #23: FreeBSD support
Author: BorisLassort
Created: 2012-01-06 09:49:20+00:00
State: open

I add the FreebSD support, just add two imports and change in glancesGrabFs.__update__() (tested in FreeBSD 9.0-RC3) :

Imports to add :

import platform
import subprocess

glancesGrabFs.__update__() to change :

def __update__(self):
"""
Update the stats
"""

# Reset the list
self.fs_list = []

# Ignore the following fs
ignore_fsname = ('none', 'gvfs-fuse-daemon', 'fusectl', 'cgroup')
ignore_fstype = ('binfmt_misc', 'devpts', 'iso9660', 'none', 'proc', 'sysfs', 'usbfs')

# Open the current mounted FS
if platform.system() == "FreeBSD":
# Get 'mout -p' output, replace tabs by space, split for each line, remove last empty line
mtab = subprocess.check_output('mount -p', shell=True).replace('\t', ' ').split('\n')
mtab.remove('')
elif platform.system() == "Linux":
mtab = open("/etc/mtab", "r").readlines()
for line in mtab:
if line.split()[0] in ignore_fsname: continue
if line.split()[2] in ignore_fstype: continue
# Get FS stats
fs_current = {}
fs_name = self.__getmount__(line.split()[1])
fs_stats = os.statvfs(fs_name)
# Build the list
fs_current['device_name'] = str(line.split()[0])
fs_current['fs_type'] = str(line.split()[2])
fs_current['mnt_point'] = str(fs_name)
fs_current['size'] = float(fs_stats.f_blocks) * long(fs_stats.f_frsize)
fs_current['used'] = float(fs_stats.f_blocks - fs_stats.f_bfree) * long(fs_stats.f_frsize)
fs_current['avail'] = float(fs_stats.f_bfree) * long(fs_stats.f_frsize)
self.fs_list.append(fs_current)
if platform.system() == "Linux":
mtab.close()

Screen :
![GitHub Logo](http://img4.hostingpics.net/pics/799820Capturedcran20120106103800.png)

ps : dependencies installation in FreeBSD :
pkg_add -r libstatgrab py27-statgrab