mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-22 16:51:35 +03:00
Revert "Enhance Glances browser color (issue #977)"
This reverts commit efaadb4b2a
.
This commit is contained in:
parent
efaadb4b2a
commit
44f24f67bb
@ -114,11 +114,8 @@ class GlancesClientBrowser(object):
|
|||||||
# CPU%
|
# CPU%
|
||||||
cpu_percent = 100 - json.loads(s.getCpu())['idle']
|
cpu_percent = 100 - json.loads(s.getCpu())['idle']
|
||||||
server['cpu_percent'] = '{:.1f}'.format(cpu_percent)
|
server['cpu_percent'] = '{:.1f}'.format(cpu_percent)
|
||||||
# !!! Not correct because we have to look system and iowait too...
|
|
||||||
server['cpu_percent_views'] = json.loads(s.getViewsCpu())['user']['decoration']
|
|
||||||
# MEM%
|
# MEM%
|
||||||
server['mem_percent'] = json.loads(s.getMem())['percent']
|
server['mem_percent'] = json.loads(s.getMem())['percent']
|
||||||
server['mem_percent_views'] = json.loads(s.getViewsMem())['used']['decoration']
|
|
||||||
# OS (Human Readable name)
|
# OS (Human Readable name)
|
||||||
server['hr_name'] = json.loads(s.getSystem())['hr_name']
|
server['hr_name'] = json.loads(s.getSystem())['hr_name']
|
||||||
except (socket.error, Fault, KeyError) as e:
|
except (socket.error, Fault, KeyError) as e:
|
||||||
@ -143,7 +140,6 @@ class GlancesClientBrowser(object):
|
|||||||
# LOAD
|
# LOAD
|
||||||
load_min5 = json.loads(s.getLoad())['min5']
|
load_min5 = json.loads(s.getLoad())['min5']
|
||||||
server['load_min5'] = '{:.2f}'.format(load_min5)
|
server['load_min5'] = '{:.2f}'.format(load_min5)
|
||||||
server['load_percent_views'] = json.loads(s.getViewsLoad())['min5']['decoration']
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Error while grabbing stats form {}: {}".format(uri, e))
|
"Error while grabbing stats form {}: {}".format(uri, e))
|
||||||
|
@ -197,17 +197,17 @@ class GlancesCursesBrowser(_GlancesCurses):
|
|||||||
# ================================
|
# ================================
|
||||||
|
|
||||||
# Table of table
|
# Table of table
|
||||||
# Item description: [stats_id, column name, column size, status_key]
|
# Item description: [stats_id, column name, column size]
|
||||||
column_def = [
|
column_def = [
|
||||||
['name', 'Name', 16, 'status'],
|
['name', 'Name', 16],
|
||||||
['alias', None, None, 'status'],
|
['alias', None, None],
|
||||||
['load_min5', 'LOAD', 6, 'status'],
|
['load_min5', 'LOAD', 6],
|
||||||
['cpu_percent', 'CPU%', 5, 'cpu_percent_views'],
|
['cpu_percent', 'CPU%', 5],
|
||||||
['mem_percent', 'MEM%', 5, 'mem_percent_views'],
|
['mem_percent', 'MEM%', 5],
|
||||||
['status', 'STATUS', 9, 'status'],
|
['status', 'STATUS', 9],
|
||||||
['ip', 'IP', 15, 'status'],
|
['ip', 'IP', 15],
|
||||||
# ['port', 'PORT', 5],
|
# ['port', 'PORT', 5],
|
||||||
['hr_name', 'OS', 16, 'status'],
|
['hr_name', 'OS', 16],
|
||||||
]
|
]
|
||||||
y = 2
|
y = 2
|
||||||
|
|
||||||
@ -261,13 +261,9 @@ class GlancesCursesBrowser(_GlancesCurses):
|
|||||||
xc += 2
|
xc += 2
|
||||||
for c in column_def:
|
for c in column_def:
|
||||||
if xc < screen_x and y < screen_y and c[1] is not None:
|
if xc < screen_x and y < screen_y and c[1] is not None:
|
||||||
# Get the status key in the list
|
|
||||||
status = c[3]
|
|
||||||
if status not in v or v['status'] == 'OFFLINE':
|
|
||||||
status = 'status'
|
|
||||||
# Display server stats
|
# Display server stats
|
||||||
self.term_window.addnstr(
|
self.term_window.addnstr(
|
||||||
y, xc, format(server_stat[c[0]]), c[2], self.colors_list[v[status]])
|
y, xc, format(server_stat[c[0]]), c[2], self.colors_list[v['status']])
|
||||||
xc += c[2] + self.space_between_column
|
xc += c[2] + self.space_between_column
|
||||||
cpt += 1
|
cpt += 1
|
||||||
# Next line, next server...
|
# Next line, next server...
|
||||||
|
@ -447,17 +447,15 @@ class GlancesPlugin(object):
|
|||||||
item_views = self.views[item]
|
item_views = self.views[item]
|
||||||
|
|
||||||
if key is None:
|
if key is None:
|
||||||
ret = item_views
|
return item_views
|
||||||
else:
|
else:
|
||||||
if option is None:
|
if option is None:
|
||||||
ret = item_views[key]
|
return item_views[key]
|
||||||
else:
|
else:
|
||||||
if option in item_views[key]:
|
if option in item_views[key]:
|
||||||
ret = item_views[key][option]
|
return item_views[key][option]
|
||||||
else:
|
else:
|
||||||
ret = 'DEFAULT'
|
return 'DEFAULT'
|
||||||
|
|
||||||
return self._json_dumps(ret)
|
|
||||||
|
|
||||||
def load_limits(self, config):
|
def load_limits(self, config):
|
||||||
"""Load limits from the configuration file, if it exists."""
|
"""Load limits from the configuration file, if it exists."""
|
||||||
|
@ -124,6 +124,7 @@ class GlancesXMLRPCServer(SimpleXMLRPCServer, object):
|
|||||||
"""Main loop"""
|
"""Main loop"""
|
||||||
while not self.finished:
|
while not self.finished:
|
||||||
self.handle_request()
|
self.handle_request()
|
||||||
|
logger.info(self.finished)
|
||||||
|
|
||||||
|
|
||||||
class GlancesInstance(object):
|
class GlancesInstance(object):
|
||||||
|
@ -54,21 +54,9 @@ class GlancesStats(object):
|
|||||||
|
|
||||||
The goal is to dynamically generate the following methods:
|
The goal is to dynamically generate the following methods:
|
||||||
- getPlugname(): return Plugname stat in JSON format
|
- getPlugname(): return Plugname stat in JSON format
|
||||||
- getViewsPlugname(): return views of the Plugname stat in JSON format
|
|
||||||
"""
|
"""
|
||||||
# Check if the attribute starts with 'get'
|
# Check if the attribute starts with 'get'
|
||||||
if item.startswith('getViews'):
|
if item.startswith('get'):
|
||||||
# Get the plugin name
|
|
||||||
plugname = item[len('getViews'):].lower()
|
|
||||||
# Get the plugin instance
|
|
||||||
plugin = self._plugins[plugname]
|
|
||||||
if hasattr(plugin, 'get_views'):
|
|
||||||
# The method get_views exist, return it
|
|
||||||
return getattr(plugin, 'get_views')
|
|
||||||
else:
|
|
||||||
# The method get_views is not found for the plugin
|
|
||||||
raise AttributeError(item)
|
|
||||||
elif item.startswith('get'):
|
|
||||||
# Get the plugin name
|
# Get the plugin name
|
||||||
plugname = item[len('get'):].lower()
|
plugname = item[len('get'):].lower()
|
||||||
# Get the plugin instance
|
# Get the plugin instance
|
||||||
|
Loading…
Reference in New Issue
Block a user