mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-25 19:17:09 +03:00
Add thread number in the processes summary line
This commit is contained in:
parent
3bd4e87568
commit
c27dd7e2f5
@ -365,6 +365,14 @@ Three views are available for processes:
|
|||||||
* Optional monitored processes list (new in 1.7)
|
* Optional monitored processes list (new in 1.7)
|
||||||
* Processes list
|
* Processes list
|
||||||
|
|
||||||
|
The processes summary line display:
|
||||||
|
|
||||||
|
* Tasks number (total number of processes)
|
||||||
|
* Threads number
|
||||||
|
* Running tasks number
|
||||||
|
* Sleeping tasks number
|
||||||
|
* Other tasks number (not running or sleeping)
|
||||||
|
|
||||||
By default, or if you hit the ``a`` key, the processes list is automatically
|
By default, or if you hit the ``a`` key, the processes list is automatically
|
||||||
sorted by CPU of memory usage.
|
sorted by CPU of memory usage.
|
||||||
|
|
||||||
|
@ -1202,7 +1202,7 @@ class GlancesGrabProcesses:
|
|||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.processlist = []
|
self.processlist = []
|
||||||
self.processcount = {'total': 0, 'running': 0, 'sleeping': 0}
|
self.processcount = {'total': 0, 'running': 0, 'sleeping': 0, 'thread': 0}
|
||||||
|
|
||||||
time_since_update = getTimeSinceLastUpdate('process_disk')
|
time_since_update = getTimeSinceLastUpdate('process_disk')
|
||||||
# For each existing process...
|
# For each existing process...
|
||||||
@ -1217,7 +1217,7 @@ class GlancesGrabProcesses:
|
|||||||
is_Windows and procstat['name'] == 'System Idle Process' or
|
is_Windows and procstat['name'] == 'System Idle Process' or
|
||||||
is_Mac and procstat['name'] == 'kernel_task'):
|
is_Mac and procstat['name'] == 'kernel_task'):
|
||||||
continue
|
continue
|
||||||
# Update processcount (global stattistics)
|
# Update processcount (global statistics)
|
||||||
try:
|
try:
|
||||||
self.processcount[str(proc.status)] += 1
|
self.processcount[str(proc.status)] += 1
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -1225,6 +1225,12 @@ class GlancesGrabProcesses:
|
|||||||
self.processcount[str(proc.status)] = 1
|
self.processcount[str(proc.status)] = 1
|
||||||
else:
|
else:
|
||||||
self.processcount['total'] += 1
|
self.processcount['total'] += 1
|
||||||
|
# Update thread number
|
||||||
|
# sum([psutil.Process(p).get_num_threads() for p in psutil.get_pid_list()])
|
||||||
|
try:
|
||||||
|
self.processcount['thread'] += proc.get_num_threads()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@ -3257,22 +3263,31 @@ class glancesScreen:
|
|||||||
curses.A_UNDERLINE)
|
curses.A_UNDERLINE)
|
||||||
return 0
|
return 0
|
||||||
if screen_y > self.process_y + 4 and screen_x > process_x + 48:
|
if screen_y > self.process_y + 4 and screen_x > process_x + 48:
|
||||||
self.term_window.addnstr(self.process_y, process_x, _("Processes"),
|
# Compute others processes
|
||||||
9, self.title_color if self.hascolors else
|
|
||||||
curses.A_UNDERLINE)
|
|
||||||
other = (processcount['total'] -
|
other = (processcount['total'] -
|
||||||
stats.getProcessCount()['running'] -
|
stats.getProcessCount()['running'] -
|
||||||
stats.getProcessCount()['sleeping'])
|
stats.getProcessCount()['sleeping'])
|
||||||
|
# Thread is only available in Glances 1.7.4 or higher
|
||||||
|
try:
|
||||||
|
thread = processcount['thread']
|
||||||
|
except KeyError:
|
||||||
|
thread = '?'
|
||||||
|
# Display the summary
|
||||||
|
self.term_window.addnstr(self.process_y, process_x, _("Tasks"),
|
||||||
|
9, self.title_color if self.hascolors else
|
||||||
|
curses.A_UNDERLINE)
|
||||||
self.term_window.addnstr(
|
self.term_window.addnstr(
|
||||||
self.process_y, process_x + 10,
|
self.process_y, process_x + 8,
|
||||||
'{0:>3}, {1:>2} {2}, {3:>3} {4}, {5:>2} {6}'.format(
|
'{0:>3} ({1:>3} {2}), {3:>2} {4}, {5:>3} {6}, {7:>2} {8}'.format(
|
||||||
str(processcount['total']),
|
str(processcount['total']),
|
||||||
|
str(thread),
|
||||||
|
_("thr"),
|
||||||
str(processcount['running']),
|
str(processcount['running']),
|
||||||
_("running"),
|
_("run"),
|
||||||
str(processcount['sleeping']),
|
str(processcount['sleeping']),
|
||||||
_("sleeping"),
|
_("slp"),
|
||||||
str(other),
|
str(other),
|
||||||
_("other")), 42)
|
_("oth")), 42)
|
||||||
|
|
||||||
# Sort info
|
# Sort info
|
||||||
# self.getProcessSortedBy() -> User sort choice
|
# self.getProcessSortedBy() -> User sort choice
|
||||||
|
Loading…
Reference in New Issue
Block a user