Add a new field in the process list to identifie Zombie process #3178

This commit is contained in:
nicolargo 2025-05-25 18:52:25 +02:00
parent a78e778b36
commit e28bf6496f
3 changed files with 31 additions and 4 deletions

View File

@ -447,10 +447,15 @@ mem_critical=90
nice_warning=-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
#
# Nice: Example 2, low priority processes escalate from careful to critical
#nice_ok=O
#nice_careful=1,2,3,4,5,6,7,8,9
#nice_warning=10,11,12,13,14
#nice_critical=15,16,17,18,19
#
# Status: define threshold regarding the process status (first letter of process status)
# R: Running, S: Sleeping, Z: Zombie (complete list here https://psutil.readthedocs.io/en/latest/#process-status-constants)
status_ok=R,W,P,I
status_critical=Z,D
# Define the list of processes to export using:
# a comma-separated list of Glances filter
#export=.*firefox.*,pid:1234

View File

@ -447,10 +447,15 @@ mem_critical=90
nice_warning=-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
#
# Nice: Example 2, low priority processes escalate from careful to critical
#nice_ok=O
#nice_careful=1,2,3,4,5,6,7,8,9
#nice_warning=10,11,12,13,14
#nice_critical=15,16,17,18,19
#
# Status: define threshold regarding the process status (first letter of process status)
# R: Running, S: Sleeping, Z: Zombie (complete list here https://psutil.readthedocs.io/en/latest/#process-status-constants)
status_ok=R,W,P,I
status_critical=Z,D
# Define the list of processes to export using:
# a comma-separated list of Glances filter
#export=.*firefox.*,pid:1234

View File

@ -262,9 +262,25 @@ class ProcesslistPlugin(GlancesPluginModel):
return 'WARNING'
if self.get_limit('nice_careful') and value in self.get_limit('nice_careful'):
return 'CAREFUL'
if self.get_limit('nice_ok') and value in self.get_limit('nice_ok'):
return 'OK'
return 'DEFAULT'
def get_status_alert(self, value):
"""Return the alert relative to the Status configuration list"""
value = str(value)
if self.get_limit('status_critical') and value in self.get_limit('status_critical'):
return 'CRITICAL'
if self.get_limit('status_warning') and value in self.get_limit('status_warning'):
return 'WARNING'
if self.get_limit('status_careful') and value in self.get_limit('status_careful'):
return 'CAREFUL'
if self.get_limit('status_ok') and value in self.get_limit('status_ok'):
return 'OK'
return 'OK' if value == 'R' else 'DEFAULT'
def _get_process_curses_cpu_percent(self, p, selected, args):
"""Return process CPU curses"""
if key_exist_value_not_none_not_v('cpu_percent', p, ''):
@ -403,10 +419,11 @@ class ProcesslistPlugin(GlancesPluginModel):
if 'status' in p:
status = p['status']
msg = self.layout_stat['status'].format(status)
if status == 'R':
ret = self.curse_add_line(msg, decoration='STATUS')
else:
ret = self.curse_add_line(msg)
ret = self.curse_add_line(msg, decoration=self.get_status_alert(status))
# if status == 'R':
# ret = self.curse_add_line(msg, decoration='STATUS')
# else:
# ret = self.curse_add_line(msg)
else:
msg = self.layout_header['status'].format('?')
ret = self.curse_add_line(msg)