mirror of https://github.com/nicolargo/glances.git
Keybind(s) for modifying nice level #2081
This commit is contained in:
parent
e4437a59ee
commit
034bc69cd0
841
docs/api.rst
841
docs/api.rst
File diff suppressed because it is too large
Load Diff
|
|
@ -297,8 +297,14 @@ The following commands (key pressed) are supported while in Glances:
|
|||
``I``
|
||||
Show/hide IP module
|
||||
|
||||
``+``
|
||||
Increase selected process nice level (need root right) - Only in standalone mode.
|
||||
|
||||
``-``
|
||||
Decrease selected process nice level (need root right) - Only in standalone mode.
|
||||
|
||||
``k``
|
||||
Kill selected process
|
||||
Kill selected process - Only in standalone mode.
|
||||
|
||||
``K``
|
||||
Show/hide TCP connections
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
|||
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
||||
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
|
||||
..
|
||||
.TH "GLANCES" "1" "Jul 05, 2022" "3.2.7_beta01" "Glances"
|
||||
.TH "GLANCES" "1" "Jul 09, 2022" "3.2.7_beta01" "Glances"
|
||||
.SH NAME
|
||||
glances \- An eye on your system
|
||||
.SH SYNOPSIS
|
||||
|
|
@ -400,8 +400,14 @@ Sort processes by I/O rate
|
|||
.B \fBI\fP
|
||||
Show/hide IP module
|
||||
.TP
|
||||
.B \fB+\fP
|
||||
Increase selected process nice level (need root right) \- Only in standalone mode.
|
||||
.TP
|
||||
.B \fB\-\fP
|
||||
Decrease selected process nice level (need root right) \- Only in standalone mode.
|
||||
.TP
|
||||
.B \fBk\fP
|
||||
Kill selected process
|
||||
Kill selected process \- Only in standalone mode.
|
||||
.TP
|
||||
.B \fBK\fP
|
||||
Show/hide TCP connections
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ class _GlancesCurses(object):
|
|||
'W': {'switch': 'disable_wifi'},
|
||||
# 'x' > Delete finished warning and critical logs
|
||||
# 'z' > Enable or disable processes
|
||||
# '+' > Increase the process nice level
|
||||
# '-' > Decrease the process nice level
|
||||
# "<" (left arrow) navigation through process sort
|
||||
# ">" (right arrow) navigation through process sort
|
||||
# 'UP' > Up in the server list
|
||||
|
|
@ -162,6 +164,10 @@ class _GlancesCurses(object):
|
|||
# Init edit filter tag
|
||||
self.edit_filter = False
|
||||
|
||||
# Init nice increase/decrease tag
|
||||
self.increase_nice_process = False
|
||||
self.decrease_nice_process = False
|
||||
|
||||
# Init kill process tag
|
||||
self.kill_process = False
|
||||
|
||||
|
|
@ -415,6 +421,12 @@ class _GlancesCurses(object):
|
|||
# 'f' > Show/hide fs / folder stats
|
||||
self.args.disable_fs = not self.args.disable_fs
|
||||
self.args.disable_folders = not self.args.disable_folders
|
||||
elif self.pressedkey == ord('+'):
|
||||
# '+' > Increase process nice level
|
||||
self.increase_nice_process = not self.increase_nice_process
|
||||
elif self.pressedkey == ord('-'):
|
||||
# '+' > Decrease process nice level
|
||||
self.decrease_nice_process = not self.decrease_nice_process
|
||||
elif self.pressedkey == ord('k'):
|
||||
# 'k' > Kill selected process (after confirmation)
|
||||
self.kill_process = not self.kill_process
|
||||
|
|
@ -683,10 +695,18 @@ class _GlancesCurses(object):
|
|||
self.display_popup('Process filter only available in standalone mode')
|
||||
self.edit_filter = False
|
||||
|
||||
# Manage increase/decrease nice level of the selected process
|
||||
# Only in standalone mode (cs_status is None)
|
||||
if self.increase_nice_process and cs_status is None:
|
||||
self.nice_increase(stats.get_plugin('processlist').get_raw()[self.args.cursor_position])
|
||||
self.increase_nice_process = False
|
||||
if self.decrease_nice_process and cs_status is None:
|
||||
self.nice_decrease(stats.get_plugin('processlist').get_raw()[self.args.cursor_position])
|
||||
self.decrease_nice_process = False
|
||||
|
||||
# Display kill process confirmation popup
|
||||
# Only in standalone mode (cs_status is None)
|
||||
if self.kill_process and cs_status is None:
|
||||
logger.info(stats.get_plugin('processlist').get_raw()[self.args.cursor_position])
|
||||
self.kill(stats.get_plugin('processlist').get_raw()[self.args.cursor_position])
|
||||
elif self.kill_process and cs_status is not None:
|
||||
self.display_popup('Kill process only available for local processes')
|
||||
|
|
@ -698,6 +718,12 @@ class _GlancesCurses(object):
|
|||
|
||||
return True
|
||||
|
||||
def nice_increase(self, process):
|
||||
glances_processes.nice_increase(process['pid'])
|
||||
|
||||
def nice_decrease(self, process):
|
||||
glances_processes.nice_decrease(process['pid'])
|
||||
|
||||
def kill(self, process):
|
||||
"""Kill a process, or a list of process if the process has a childrens field.
|
||||
|
||||
|
|
@ -1132,6 +1158,11 @@ class _GlancesCurses(object):
|
|||
# Were asked to refresh
|
||||
return isexitkey
|
||||
|
||||
if pressedkey in (curses.KEY_UP, 65, curses.KEY_DOWN, 66):
|
||||
# Up of won key pressed, reset the countdown
|
||||
# Better for user experience
|
||||
countdown.reset()
|
||||
|
||||
if isexitkey and self.args.help_tag:
|
||||
# Quit from help should return to main screen, not exit #1874
|
||||
self.args.help_tag = not self.args.help_tag
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
<div class="divTableCell">{{ vm.help.sort_process_name }}</div>
|
||||
<div class="divTableCell">{{ vm.help.show_hide_filesystem }}</div>
|
||||
<div class="divTableCell">{{ vm.help.toggle_separate_combined }}</div>
|
||||
<div class="divTableCell">{{ vm.help.misc_kill_process }}</div>
|
||||
<div class="divTableCell">{{ vm.help.misc_kill_process }} - N/A in WebUI</div>
|
||||
</div>
|
||||
<div class="divTableRow">
|
||||
<div class="divTableCell">{{ vm.help.sort_cpu_times }}</div>
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
<div class="divTableCell"> </div>
|
||||
<div class="divTableCell">{{ vm.help.sort_cpu_times }}</div>
|
||||
<div class="divTableCell"> </div>
|
||||
<div class="divTableCell">{{ vm.help.misc_edit_process_filter_pattern }}</div>
|
||||
<div class="divTableCell">{{ vm.help.misc_edit_process_filter_pattern }} - N/A in WebUI</div>
|
||||
</div>
|
||||
<div class="divTableRow">
|
||||
<div class="divTableCell"> </div>
|
||||
|
|
@ -139,3 +139,11 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>For an exhaustive list of key bindings, <a href="https://glances.readthedocs.io/en/latest/cmds.html#interactive-commands">click here</a>.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>Press <b>h</b> to came back to Glances.</p>
|
||||
</div>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -106,6 +106,8 @@ class Plugin(GlancesPlugin):
|
|||
self.view_data['misc_generate_history_graphs'] = msg_col.format('g', 'Generate history graphs')
|
||||
self.view_data['misc_help'] = msg_col.format('h', 'HELP')
|
||||
self.view_data['misc_accumulate_processes_by_program'] = msg_col.format('j', 'Accumulate processes by program')
|
||||
self.view_data['misc_increase_nice_process'] = msg_col.format('+', 'Increase nice process (need admin rights)')
|
||||
self.view_data['misc_decrease_nice_process'] = msg_col.format('-', 'Decrease nice process')
|
||||
self.view_data['misc_kill_process'] = msg_col.format('k', 'Kill process')
|
||||
self.view_data['misc_reset_processes_summary_min_max'] = msg_col.format('M', 'Reset processes summary min/max')
|
||||
self.view_data['misc_quit'] = msg_col.format('q', 'QUIT (or Esc or Ctrl-C)')
|
||||
|
|
@ -214,5 +216,10 @@ class Plugin(GlancesPlugin):
|
|||
ret.append(self.curse_add_line(self.view_data['show_hide_left_sidebar']))
|
||||
ret.append(self.curse_add_line(self.view_data['misc_edit_process_filter_pattern']))
|
||||
|
||||
ret.append(self.curse_new_line())
|
||||
ret.append(self.curse_new_line())
|
||||
ret.append(self.curse_add_line('For an exhaustive list of key bindings:'))
|
||||
ret.append(self.curse_new_line())
|
||||
ret.append(self.curse_add_line('https://glances.readthedocs.io/en/latest/cmds.html#interactive-commands'))
|
||||
# Return the message with decoration
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -429,6 +429,28 @@ class GlancesProcesses(object):
|
|||
self.auto_sort = auto
|
||||
self._sort_key = key
|
||||
|
||||
def nice_increase(self, pid):
|
||||
""" Increase nice level
|
||||
On UNIX this is a number which usually goes from -20 to 20.
|
||||
The higher the nice value, the lower the priority of the process."""
|
||||
p = psutil.Process(pid)
|
||||
try:
|
||||
p.nice(p.nice() - 1)
|
||||
logger.info('Set nice level of process {} to {}'.format(pid, p.nice()))
|
||||
except psutil.AccessDenied:
|
||||
logger.warning('Can not increase the nice level of process {} (access denied)'.format(pid))
|
||||
|
||||
def nice_decrease(self, pid):
|
||||
""" Decrease nice level
|
||||
On UNIX this is a number which usually goes from -20 to 20.
|
||||
The higher the nice value, the lower the priority of the process."""
|
||||
p = psutil.Process(pid)
|
||||
try:
|
||||
p.nice(p.nice() + 1)
|
||||
logger.info('Set nice level of process {} to {}'.format(pid, p.nice()))
|
||||
except psutil.AccessDenied:
|
||||
logger.warning('Can not decrease the nice level of process {} (access denied)'.format(pid))
|
||||
|
||||
def kill(self, pid, timeout=3):
|
||||
"""Kill process with pid"""
|
||||
assert pid != os.getpid(), "Glances can kill itself..."
|
||||
|
|
@ -438,6 +460,8 @@ class GlancesProcesses(object):
|
|||
return p.wait(timeout)
|
||||
|
||||
|
||||
|
||||
|
||||
def weighted(value):
|
||||
"""Manage None value in dict value."""
|
||||
return -float('inf') if value is None else value
|
||||
|
|
|
|||
Loading…
Reference in New Issue