summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Hennion <nicolas@nicolargo.com>2012-12-18 21:33:47 +0100
committerNicolas Hennion <nicolas@nicolargo.com>2012-12-18 21:33:47 +0100
commit4247fdcace34196bb1801bcb25162b5fcf9b2c83 (patch)
tree17b49d078316ce4250b7eb5b36007ff596115d6f
parent3ebef317f1af444fba22ca5b32419d081b0a2fad (diff)
Filter and hide idle processes on Windows and FreeBSD
-rwxr-xr-xglances/glances.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/glances/glances.py b/glances/glances.py
index 193c1193..e311dd41 100755
--- a/glances/glances.py
+++ b/glances/glances.py
@@ -43,6 +43,12 @@ gettext.install(__appname__)
import json
import collections
+# Somes libs depends of OS
+is_Bsd = sys.platform.endswith('bsd')
+is_Linux = sys.platform.startswith('linux')
+is_Mac = sys.platform.startswith('darwin')
+is_Windows = sys.platform.startswith('win')
+
try:
# For Python v2.x
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
@@ -59,7 +65,6 @@ except ImportError:
# For Python v3.x
from xmlrpc.client import ServerProxy
-is_Windows = sys.platform.startswith('win')
if not is_Windows:
# Only import curses for non Windows OS
# Curses did not exist on Windows OS (shame on it)
@@ -91,7 +96,6 @@ except Exception:
else:
psutil_get_cpu_percent_tag = True
-is_Linux = sys.platform.startswith('linux')
try:
# get_io_counter method only available with PsUtil 0.2.1+
psutil.Process(os.getpid()).get_io_counters()
@@ -523,8 +527,14 @@ class GlancesGrabProcesses:
self.processcount = {'total': 0, 'running': 0, 'sleeping': 0}
for proc in psutil.process_iter():
+ procstat = self.__get_process_stats__(proc)
+ # Ignore the 'idle' process on Windows or Bsd
+ # Waiting upstream patch from PsUtil
+ if ((is_Windows or is_Bsd)
+ and (procstat['cmdline'] == 'idle')):
+ continue
# Update processlist
- self.processlist.append(self.__get_process_stats__(proc))
+ self.processlist.append(procstat)
# Update processcount
try:
self.processcount[str(proc.status)] += 1