diff options
author | Nicolargo <nicolas@nicolargo.com> | 2014-07-06 15:14:49 +0200 |
---|---|---|
committer | Nicolargo <nicolas@nicolargo.com> | 2014-07-06 15:14:49 +0200 |
commit | e0d9fe530d59236b413dacee304240ba9e13e37d (patch) | |
tree | 6d43bd9bf1aa373533c7a8f24fccba826a78ed83 | |
parent | c104772ca409ba7b52c28d3cb063194df97c0638 (diff) |
Give atry to Swap Mem used stat but rejected because too high CPU consumption (issue #372)
-rw-r--r-- | glances/core/glances_processes.py | 12 | ||||
-rw-r--r-- | glances/outputs/glances_curses.py | 11 | ||||
-rw-r--r-- | glances/plugins/glances_plugin.py | 17 | ||||
-rw-r--r-- | glances/plugins/glances_processlist.py | 3 |
4 files changed, 31 insertions, 12 deletions
diff --git a/glances/core/glances_processes.py b/glances/core/glances_processes.py index 8913206d..fe47d646 100644 --- a/glances/core/glances_processes.py +++ b/glances/core/glances_processes.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from glances.core.glances_globals import is_bsd, is_mac, is_windows +from glances.core.glances_globals import is_linux, is_bsd, is_mac, is_windows, logger from glances.core.glances_timer import Timer, getTimeSinceLastUpdate import psutil @@ -112,7 +112,7 @@ class GlancesProcesses(object): procstat['cpu_percent'] = proc.cpu_percent(interval=0) # Process network connections (TCP and UDP) (Experimental) - # !!! High CPU consumption + # REJECTED: Too high CPU consumption # try: # procstat['tcp'] = len(proc.connections(kind="tcp")) # procstat['udp'] = len(proc.connections(kind="udp")) @@ -150,6 +150,14 @@ class GlancesProcesses(object): # Append the IO tag (for display) procstat['io_counters'] += [io_tag] + # SWAP memory + # Only on Linux based OS + # http://www.cyberciti.biz/faq/linux-which-process-is-using-swap/ + # REJECTED: Too high CPU consumption + # if is_linux: + # logger.debug(proc.memory_maps()) + # procstat['memory_swap'] = sum([ v.swap for v in proc.memory_maps() ]) + return procstat def update(self): diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index 20be1cd7..e6cf0ba6 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -422,10 +422,14 @@ class GlancesCurses(object): return True - def display_plugin(self, plugin_stats, display_optional=True, max_y=65535): + def display_plugin(self, plugin_stats, + display_optional=True, + display_additional=True, + max_y=65535): """Display the plugin_stats on the screen. - If display_optional=True display the optional stats. + If display_optional=True display the optional stats + If display_additional=True display additionnal stats max_y do not display line > max_y """ # Exit if: @@ -472,6 +476,9 @@ class GlancesCurses(object): # If display_optional = False do not display optional stats if not display_optional and m['optional']: continue + # If display_additional = False do not display additional stats + if not display_additional and m['additional']: + continue # Is it possible to display the stat with the current screen size # !!! Crach if not try/except... Why ??? try: diff --git a/glances/plugins/glances_plugin.py b/glances/plugins/glances_plugin.py index 2e1e02c1..a78d5986 100644 --- a/glances/plugins/glances_plugin.py +++ b/glances/plugins/glances_plugin.py @@ -284,17 +284,19 @@ class GlancesPlugin(object): if max_width is not None: ret = {'display': display_curse, - 'msgdict': self.msg_curse(args, max_width=max_width), - 'align': align_curse} + 'msgdict': self.msg_curse(args, max_width=max_width), + 'align': align_curse} else: ret = {'display': display_curse, - 'msgdict': self.msg_curse(args), - 'align': align_curse} + 'msgdict': self.msg_curse(args), + 'align': align_curse} return ret - def curse_add_line(self, msg, decoration="DEFAULT", optional=False, splittable=False): - """Return a dict with: { 'msg': msg, 'decoration': decoration, 'optional': False }. + def curse_add_line(self, msg, decoration="DEFAULT", + optional=False, additional=False, + splittable=False): + """Return a dict with Where: msg: string @@ -315,9 +317,10 @@ class GlancesPlugin(object): CRITICAL: Value is CRITICAL and non logged CRITICAL_LOG: Value is CRITICAL and logged optional: True if the stat is optional (display only if space is available) + additional: True if the stat is additional (display only if space is available after optional) spittable: Line can be splitted to fit on the screen (default is not) """ - return {'msg': msg, 'decoration': decoration, 'optional': optional, 'splittable': splittable} + return {'msg': msg, 'decoration': decoration, 'optional': optional, 'additional': additional, 'splittable': splittable} def curse_new_line(self): """Go to a new line.""" diff --git a/glances/plugins/glances_processlist.py b/glances/plugins/glances_processlist.py index 9e583e1c..3acc1afc 100644 --- a/glances/plugins/glances_processlist.py +++ b/glances/plugins/glances_processlist.py @@ -24,7 +24,7 @@ import os from datetime import timedelta # Import Glances libs -from glances.core.glances_globals import glances_processes, is_windows +from glances.core.glances_globals import glances_processes, is_windows, is_linux from glances.plugins.glances_plugin import GlancesPlugin @@ -216,6 +216,7 @@ class Plugin(GlancesPlugin): msg = '{0:>6}'.format("?") ret.append(self.curse_add_line(msg, optional=True)) ret.append(self.curse_add_line(msg, optional=True)) + # Command line # If no command line for the process is available, fallback to # the bare process name instead |