diff --git a/conf/glances.conf b/conf/glances.conf index 4a67cad5..16d97e03 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -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 diff --git a/docker-compose/glances.conf b/docker-compose/glances.conf index 7b41f525..6f904737 100755 --- a/docker-compose/glances.conf +++ b/docker-compose/glances.conf @@ -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 diff --git a/glances/plugins/processlist/__init__.py b/glances/plugins/processlist/__init__.py index 1f196026..407aa203 100644 --- a/glances/plugins/processlist/__init__.py +++ b/glances/plugins/processlist/__init__.py @@ -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)