mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-28 11:41:46 +03:00
Merge branch 'issue1265' into develop
This commit is contained in:
commit
3db4e105d3
1
NEWS
1
NEWS
@ -28,6 +28,7 @@ Enhancements and new features:
|
|||||||
* Add time zone to the current time #1249
|
* Add time zone to the current time #1249
|
||||||
* Use https URLs for checking external IP #1253
|
* Use https URLs for checking external IP #1253
|
||||||
* Add labels support to Promotheus exporter #1255
|
* Add labels support to Promotheus exporter #1255
|
||||||
|
* Overlap in Web UI when monitoring a machine with 16 cpu threads #1265
|
||||||
|
|
||||||
One more thing ! A new Grafana Dash is available with:
|
One more thing ! A new Grafana Dash is available with:
|
||||||
* Network interface variable
|
* Network interface variable
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
"""Per-CPU plugin."""
|
"""Per-CPU plugin."""
|
||||||
|
|
||||||
|
from glances.logger import logger
|
||||||
from glances.cpu_percent import cpu_percent
|
from glances.cpu_percent import cpu_percent
|
||||||
from glances.plugins.glances_plugin import GlancesPlugin
|
from glances.plugins.glances_plugin import GlancesPlugin
|
||||||
|
|
||||||
@ -76,6 +77,10 @@ class Plugin(GlancesPlugin):
|
|||||||
# Init the return message
|
# Init the return message
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
|
# Only process if stats exist...
|
||||||
|
if not self.stats or self.is_disable():
|
||||||
|
return ret
|
||||||
|
|
||||||
# No per CPU stat ? Exit...
|
# No per CPU stat ? Exit...
|
||||||
if not self.stats:
|
if not self.stats:
|
||||||
msg = 'PER CPU not available'
|
msg = 'PER CPU not available'
|
||||||
@ -83,35 +88,36 @@ class Plugin(GlancesPlugin):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
# Build the string message
|
# Build the string message
|
||||||
# Header
|
if self.is_disable('quicklook'):
|
||||||
msg = '{:8}'.format('PER CPU')
|
msg = '{:7}'.format('PER CPU')
|
||||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||||
|
|
||||||
# Total per-CPU usage
|
# Per CPU stats displayed per line
|
||||||
|
for stat in ['user', 'system', 'idle', 'iowait', 'steal']:
|
||||||
|
if stat not in self.stats[0]:
|
||||||
|
continue
|
||||||
|
msg = '{:>7}'.format(stat)
|
||||||
|
ret.append(self.curse_add_line(msg))
|
||||||
|
|
||||||
|
# Per CPU stats displayed per column
|
||||||
for cpu in self.stats:
|
for cpu in self.stats:
|
||||||
|
ret.append(self.curse_new_line())
|
||||||
|
if self.is_disable('quicklook'):
|
||||||
try:
|
try:
|
||||||
msg = '{:6.1f}%'.format(cpu['total'])
|
msg = '{:6.1f}%'.format(cpu['total'])
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# TypeError: string indices must be integers (issue #1027)
|
# TypeError: string indices must be integers (issue #1027)
|
||||||
msg = '{:>6}%'.format('?')
|
msg = '{:>6}%'.format('?')
|
||||||
ret.append(self.curse_add_line(msg))
|
ret.append(self.curse_add_line(msg))
|
||||||
|
|
||||||
# Stats per-CPU
|
|
||||||
for stat in ['user', 'system', 'idle', 'iowait', 'steal']:
|
for stat in ['user', 'system', 'idle', 'iowait', 'steal']:
|
||||||
if stat not in self.stats[0]:
|
if stat not in self.stats[0]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ret.append(self.curse_new_line())
|
|
||||||
msg = '{:8}'.format(stat + ':')
|
|
||||||
ret.append(self.curse_add_line(msg))
|
|
||||||
for cpu in self.stats:
|
|
||||||
try:
|
try:
|
||||||
msg = '{:6.1f}%'.format(cpu[stat])
|
msg = '{:6.1f}%'.format(cpu[stat])
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# TypeError: string indices must be integers (issue #1027)
|
|
||||||
msg = '{:>6}%'.format('?')
|
msg = '{:>6}%'.format('?')
|
||||||
ret.append(self.curse_add_line(msg,
|
ret.append(self.curse_add_line(msg,
|
||||||
self.get_alert(cpu[stat], header=stat)))
|
self.get_alert(cpu[stat],
|
||||||
|
header=stat)))
|
||||||
|
|
||||||
# Return the message with decoration
|
|
||||||
return ret
|
return ret
|
||||||
|
@ -124,18 +124,20 @@ class GlancesPlugin(object):
|
|||||||
"""Return the key of the list."""
|
"""Return the key of the list."""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def is_enable(self):
|
def is_enable(self, plugin_name=None):
|
||||||
"""Return true if plugin is enabled."""
|
"""Return true if plugin is enabled."""
|
||||||
|
if not plugin_name:
|
||||||
|
plugin_name = self.plugin_name
|
||||||
try:
|
try:
|
||||||
d = getattr(self.args, 'disable_' + self.plugin_name)
|
d = getattr(self.args, 'disable_' + plugin_name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return d is False
|
return d is False
|
||||||
|
|
||||||
def is_disable(self):
|
def is_disable(self, plugin_name=None):
|
||||||
"""Return true if plugin is disabled."""
|
"""Return true if plugin is disabled."""
|
||||||
return not self.is_enable()
|
return not self.is_enable(plugin_name=plugin_name)
|
||||||
|
|
||||||
def _json_dumps(self, d):
|
def _json_dumps(self, d):
|
||||||
"""Return the object 'd' in a JSON format.
|
"""Return the object 'd' in a JSON format.
|
||||||
|
Loading…
Reference in New Issue
Block a user