Add a key ('F') and a command line option (--fs-free-space) to display FS free space instead of used space (issue #411)

This commit is contained in:
Nicolargo 2014-10-19 21:42:26 +02:00
parent ca9ab6a751
commit 4abad6e89a
7 changed files with 22 additions and 2 deletions

1
NEWS
View File

@ -7,6 +7,7 @@ Version 2.2
* Improve graph history feature (issue #428)
* Extended stats is disable by default (use --enable-process-extended to enable it - issue #430)
* Add a key ('F') and a command line option (--fs-free-space) to display FS free space instead of used space (issue #411)
Version 2.1.2
=============

View File

@ -170,6 +170,7 @@ Command-Line Options
--process-short-name force short name for processes name
-b, --byte display network rate in byte per second
-1, --percpu start Glances in per CPU mode
--fs-free-space display FS free space instead of used
--theme-white optimize display for white background
Interactive Commands
@ -199,6 +200,8 @@ The following commands (key pressed) are supported while in Glances:
Enable/disable top extended stats
``f``
Show/hide file system stats
``F``
Switch between FS used and free space
``g``
Generate hraphs for current history
``h``

View File

@ -129,6 +129,8 @@ class GlancesMain(object):
dest='byte', help=_('display network rate in byte per second'))
parser.add_argument('-1', '--percpu', action='store_true', default=False,
dest='percpu', help=_('start Glances in per CPU mode'))
parser.add_argument('--fs-free-space', action='store_false', default=False,
dest='fs_free_space', help=_('display FS free space instead of used'))
parser.add_argument('--theme-white', action='store_true', default=False,
dest='theme_white', help=_('optimize display for white background'))

View File

@ -263,6 +263,9 @@ class GlancesCurses(object):
glances_processes.disable_extended()
else:
glances_processes.enable_extended()
elif self.pressedkey == ord('F'):
# 'F' > Switch between FS available and free space
self.args.fs_free_space = not self.args.fs_free_space
elif self.pressedkey == ord('f'):
# 'f' > Show/hide fs stats
self.args.disable_fs = not self.args.disable_fs

View File

@ -173,7 +173,10 @@ class Plugin(GlancesPlugin):
# Header
msg = '{0:{width}}'.format(_("FILE SYS"), width=fsname_max_width)
ret.append(self.curse_add_line(msg, "TITLE"))
msg = '{0:>7}'.format(_("Used"))
if args.fs_free_space:
msg = '{0:>7}'.format(_("Free"))
else:
msg = '{0:>7}'.format(_("Used"))
ret.append(self.curse_add_line(msg))
msg = '{0:>7}'.format(_("Total"))
ret.append(self.curse_add_line(msg))
@ -194,7 +197,10 @@ class Plugin(GlancesPlugin):
mnt_point = i['mnt_point']
msg = '{0:{width}}'.format(mnt_point, width=fsname_max_width)
ret.append(self.curse_add_line(msg))
msg = '{0:>7}'.format(self.auto_unit(i['used']))
if args.fs_free_space:
msg = '{0:>7}'.format(self.auto_unit(i['size'] - i['used']))
else:
msg = '{0:>7}'.format(self.auto_unit(i['used']))
ret.append(self.curse_add_line(msg, self.get_alert(i['used'], max=i['size'])))
msg = '{0:>7}'.format(self.auto_unit(i['size']))
ret.append(self.curse_add_line(msg))

View File

@ -116,6 +116,8 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_new_line())
msg = msg_col.format("s", _("Show/hide sensors stats"))
ret.append(self.curse_add_line(msg))
msg = msg_col2.format("F", _("Switch between FS used and free space"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
msg = msg_col.format("2", _("Show/hide left sidebar"))
ret.append(self.curse_add_line(msg))

View File

@ -115,6 +115,9 @@ start Glances in per CPU mode
.B \-1, \-\-process-short-name
Force short name for processes name
.TP
.B \-1, \-\-fs-free-space
Display FS free space instead of used
.TP
.B \-1, \-\-theme-white
Optimize display for white background
.SH INTERACTIVE COMMANDS