desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Set the active server or None if no server selected.'
| @active_server.setter
def active_server(self, index):
| self._active_server = index
|
'Get the cursor position.'
| @property
def cursor(self):
| return self.cursor_position
|
'Set the cursor position.'
| @cursor.setter
def cursor(self, position):
| self.cursor_position = position
|
'Set the cursor to position N-1 in the list.'
| def cursor_up(self, servers_list):
| if (self.cursor_position > 0):
self.cursor_position -= 1
else:
self.cursor_position = (len(servers_list) - 1)
|
'Set the cursor to position N-1 in the list.'
| def cursor_down(self, servers_list):
| if (self.cursor_position < (len(servers_list) - 1)):
self.cursor_position += 1
else:
self.cursor_position = 0
|
'Update the servers\' list screen.
Wait for __refresh_time sec / catch key every 100 ms.
servers_list: Dict of dict with servers stats'
| def update(self, servers_list):
| logger.debug('Servers list: {}'.format(servers_list))
self.flush(servers_list)
exitkey = False
countdown = Timer(self.__refresh_time)
while ((not countdown.finished()) and (not exitkey)):
pressedkey = self.__catch_key(servers_list)
exitkey = ((pressedkey == ord('\x1b')) or (pre... |
'Update the servers\' list screen.
servers_list: List of dict with servers stats'
| def flush(self, servers_list):
| self.erase()
self.display(servers_list)
|
'Display the servers list.
Return:
True if the stats have been displayed
False if the stats have not been displayed (no server available)'
| def display(self, servers_list):
| self.init_line_column()
screen_x = self.screen.getmaxyx()[1]
screen_y = self.screen.getmaxyx()[0]
x = 0
y = 0
if (len(servers_list) == 0):
if (self.first_scan and (not self.args.disable_autodiscover)):
msg = 'Glances is scanning your network. Please wait...'... |
'Load the outputs section of the configuration file.'
| def load_config(self, config):
| if ((config is not None) and config.has_section('outputs')):
logger.debug('Read number of processes to display in the WebUI')
n = config.get_value('outputs', 'max_processes_display', default=None)
logger.debug('Number of processes to display in the ... |
'Check if a username/password combination is valid.'
| def check_auth(self, username, password):
| if (username == self.args.username):
from glances.password import GlancesPassword
pwd = GlancesPassword()
return pwd.check_password(self.args.password, pwd.sha256_hash(password))
else:
return False
|
'Define route.'
| def _route(self):
| self._app.route('/', method='GET', callback=self._index)
self._app.route('/<refresh_time:int>', method=['GET'], callback=self._index)
self._app.route('/api/2/config', method='GET', callback=self._api_config)
self._app.route('/api/2/config/<item>', method='GET', callback=self._api_config_item)
self._... |
'Start the bottle.'
| def start(self, stats):
| self.stats = stats
self.plugins_list = self.stats.getAllPlugins()
bindurl = 'http://{}:{}/'.format(self.args.bind_address, self.args.port)
bindmsg = 'Glances web server started on {}'.format(bindurl)
logger.info(bindmsg)
print bindmsg
if self.args.open_web_browser:
web... |
'End the bottle.'
| def end(self):
| pass
|
'Bottle callback for index.html (/) file.'
| def _index(self, refresh_time=None):
| self.__update__()
return static_file('index.html', root=self.STATIC_PATH)
|
'Bottle callback for resources files.'
| def _resource(self, filepath):
| return static_file(filepath, root=self.STATIC_PATH)
|
'Glances API RESTFul implementation.
Return the help data or 404 error.'
| def _api_help(self):
| response.content_type = 'application/json'
view_data = self.stats.get_plugin('help').get_view_data()
try:
plist = json.dumps(view_data, sort_keys=True)
except Exception as e:
abort(404, ('Cannot get help view data (%s)' % str(e)))
return plist
|
'@api {get} /api/2/pluginslist Get plugins list
@apiVersion 2.0
@apiName pluginslist
@apiGroup plugin
@apiSuccess {String[]} Plugins list.
@apiSuccessExample Success-Response:
HTTP/1.1 200 OK
"load",
"help",
"ip",
"memswap",
"processlist",
@apiError Cannot get plugin list.
@apiErrorExample Error-Response:
HTTP/1.1 404 ... | def _api_plugins(self):
| response.content_type = 'application/json'
self.__update__()
try:
plist = json.dumps(self.plugins_list)
except Exception as e:
abort(404, ('Cannot get plugin list (%s)' % str(e)))
return plist
|
'Glances API RESTFul implementation.
Return the JSON representation of all the plugins
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api_all(self):
| response.content_type = 'application/json'
if self.args.debug:
fname = os.path.join(tempfile.gettempdir(), 'glances-debug.json')
try:
with open(fname) as f:
return f.read()
except IOError:
logger.debug(('Debug file (%s) not found' % fna... |
'Glances API RESTFul implementation.
Return the JSON representation of all the plugins limits
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api_all_limits(self):
| response.content_type = 'application/json'
try:
limits = json.dumps(self.stats.getAllLimitsAsDict())
except Exception as e:
abort(404, ('Cannot get limits (%s)' % str(e)))
return limits
|
'Glances API RESTFul implementation.
Return the JSON representation of all the plugins views
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api_all_views(self):
| response.content_type = 'application/json'
try:
limits = json.dumps(self.stats.getAllViewsAsDict())
except Exception as e:
abort(404, ('Cannot get views (%s)' % str(e)))
return limits
|
'Glances API RESTFul implementation.
Return the JSON representation of a given plugin
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api(self, plugin):
| response.content_type = 'application/json'
if (plugin not in self.plugins_list):
abort(400, ('Unknown plugin %s (available plugins: %s)' % (plugin, self.plugins_list)))
self.__update__()
try:
statval = self.stats.get_plugin(plugin).get_stats()
except Exception as e:
... |
'Glances API RESTFul implementation.
Return the JSON representation of a given plugin history
Limit to the last nb items (all if nb=0)
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api_history(self, plugin, nb=0):
| response.content_type = 'application/json'
if (plugin not in self.plugins_list):
abort(400, ('Unknown plugin %s (available plugins: %s)' % (plugin, self.plugins_list)))
self.__update__()
try:
statval = self.stats.get_plugin(plugin).get_stats_history(nb=int(nb))
except ... |
'Glances API RESTFul implementation.
Return the JSON limits of a given plugin
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api_limits(self, plugin):
| response.content_type = 'application/json'
if (plugin not in self.plugins_list):
abort(400, ('Unknown plugin %s (available plugins: %s)' % (plugin, self.plugins_list)))
try:
ret = self.stats.get_plugin(plugin).limits
except Exception as e:
abort(404, ('Cannot ge... |
'Glances API RESTFul implementation.
Return the JSON views of a given plugin
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api_views(self, plugin):
| response.content_type = 'application/json'
if (plugin not in self.plugins_list):
abort(400, ('Unknown plugin %s (available plugins: %s)' % (plugin, self.plugins_list)))
try:
ret = self.stats.get_plugin(plugin).get_views()
except Exception as e:
abort(404, ('Cannot ... |
'Father method for _api_item and _api_value'
| def _api_itemvalue(self, plugin, item, value=None, history=False, nb=0):
| response.content_type = 'application/json'
if (plugin not in self.plugins_list):
abort(400, ('Unknown plugin %s (available plugins: %s)' % (plugin, self.plugins_list)))
self.__update__()
if (value is None):
if history:
ret = self.stats.get_plugin(plugin).get_st... |
'Glances API RESTFul implementation.
Return the JSON representation of the couple plugin/item
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api_item(self, plugin, item):
| return self._api_itemvalue(plugin, item)
|
'Glances API RESTFul implementation.
Return the JSON representation of the couple plugin/history of item
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api_item_history(self, plugin, item, nb=0):
| return self._api_itemvalue(plugin, item, history=True, nb=int(nb))
|
'Glances API RESTFul implementation.
Return the process stats (dict) for the given item=value
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error'
| def _api_value(self, plugin, item, value):
| return self._api_itemvalue(plugin, item, value)
|
'Glances API RESTFul implementation.
Return the JSON representation of the Glances configuration file
HTTP/200 if OK
HTTP/404 if others error'
| def _api_config(self):
| response.content_type = 'application/json'
try:
args_json = json.dumps(self.config.as_dict())
except Exception as e:
abort(404, ('Cannot get config (%s)' % str(e)))
return args_json
|
'Glances API RESTFul implementation.
Return the JSON representation of the Glances configuration item
HTTP/200 if OK
HTTP/400 if item is not found
HTTP/404 if others error'
| def _api_config_item(self, item):
| response.content_type = 'application/json'
config_dict = self.config.as_dict()
if (item not in config_dict):
abort(400, ('Unknown configuration item %s' % item))
try:
args_json = json.dumps(config_dict[item])
except Exception as e:
abort(404, ('Cannot get confi... |
'Glances API RESTFul implementation.
Return the JSON representation of the Glances command line arguments
HTTP/200 if OK
HTTP/404 if others error'
| def _api_args(self):
| response.content_type = 'application/json'
try:
args_json = json.dumps(vars(self.args))
except Exception as e:
abort(404, ('Cannot get args (%s)' % str(e)))
return args_json
|
'Glances API RESTFul implementation.
Return the JSON representation of the Glances command line arguments item
HTTP/200 if OK
HTTP/400 if item is not found
HTTP/404 if others error'
| def _api_args_item(self, item):
| response.content_type = 'application/json'
if (item not in self.args):
abort(400, ('Unknown argument item %s' % item))
try:
args_json = json.dumps(vars(self.args)[item])
except Exception as e:
abort(404, ('Cannot get args item (%s)' % str(e)))
return args... |
'Return the bars.'
| def __str__(self):
| (frac, whole) = modf(((self.size * self.percent) / 100.0))
ret = (curses_bars[8] * int(whole))
if (frac > 0):
ret += curses_bars[int((frac * 8))]
whole += 1
ret += (self.__empty_char * int((self.size - whole)))
if self.__with_text:
ret = '{}{:5.1f}%'.format(ret, self.percent)... |
'Load the outputs section of the configuration file.'
| def load_config(self, config):
| if ((config is not None) and config.has_section('outputs')):
logger.debug('Read the outputs section in the configuration file')
self.theme['name'] = config.get_value('outputs', 'curse_theme', default='black')
logger.debug('Theme for the curse interface: {}... |
'Return True if the theme *name* should be used.'
| def is_theme(self, name):
| return (getattr(self.args, ('theme_' + name)) or (self.theme['name'] == name))
|
'Init the history option.'
| def _init_history(self):
| self.reset_history_tag = False
self.graph_tag = False
if self.args.export_graph:
logger.info(('Export graphs function enabled with output path %s' % self.args.path_graph))
from glances.exports.graph import GlancesGraph
self.glances_graph = GlancesGraph(self.args.... |
'Init cursors.'
| def _init_cursor(self):
| if hasattr(curses, 'noecho'):
curses.noecho()
if hasattr(curses, 'cbreak'):
curses.cbreak()
self.set_cursor(0)
|
'Init the Curses color layout.'
| def _init_colors(self):
| if hasattr(curses, 'start_color'):
curses.start_color()
if hasattr(curses, 'use_default_colors'):
curses.use_default_colors()
if self.args.disable_bold:
A_BOLD = 0
self.args.disable_bg = True
else:
A_BOLD = curses.A_BOLD
self.title_color = A_BOLD
self.titl... |
'Configure the curse cursor apparence.
0: invisible
1: visible
2: very visible'
| def set_cursor(self, value):
| if hasattr(curses, 'curs_set'):
try:
curses.curs_set(value)
except Exception:
pass
|
'Return the current sort in the loop'
| def loop_position(self):
| for (i, v) in enumerate(self._sort_loop):
if (v == glances_processes.sort_key):
return i
return 0
|
'Disable the top panel'
| def disable_top(self):
| for p in ['quicklook', 'cpu', 'gpu', 'mem', 'memswap', 'load']:
setattr(self.args, ('disable_' + p), True)
|
'Enable the top panel'
| def enable_top(self):
| for p in ['quicklook', 'cpu', 'gpu', 'mem', 'memswap', 'load']:
setattr(self.args, ('disable_' + p), False)
|
'Disable the full quicklook mode'
| def disable_fullquicklook(self):
| for p in ['quicklook', 'cpu', 'gpu', 'mem', 'memswap']:
setattr(self.args, ('disable_' + p), False)
|
'Disable the full quicklook mode'
| def enable_fullquicklook(self):
| self.args.disable_quicklook = False
for p in ['cpu', 'gpu', 'mem', 'memswap']:
setattr(self.args, ('disable_' + p), True)
|
'Shutdown the curses window.'
| def end(self):
| if hasattr(curses, 'echo'):
curses.echo()
if hasattr(curses, 'nocbreak'):
curses.nocbreak()
if hasattr(curses, 'curs_set'):
try:
curses.curs_set(1)
except Exception:
pass
curses.endwin()
|
'Init the line and column position for the curses interface.'
| def init_line_column(self):
| self.init_line()
self.init_column()
|
'Init the line position for the curses interface.'
| def init_line(self):
| self.line = 0
self.next_line = 0
|
'Init the column position for the curses interface.'
| def init_column(self):
| self.column = 0
self.next_column = 0
|
'New line in the curses interface.'
| def new_line(self):
| self.line = self.next_line
|
'New column in the curses interface.'
| def new_column(self):
| self.column = self.next_column
|
'Return a dict of dict with all the stats display
* key: plugin name
* value: dict returned by the get_stats_display Plugin method
:returns: dict of dict'
| def __get_stat_display(self, stats, plugin_max_width):
| ret = {}
for p in stats.getAllPlugins(enable=False):
if (p in ['network', 'wifi', 'irq', 'fs', 'folders']):
ret[p] = stats.get_plugin(p).get_stats_display(args=self.args, max_width=plugin_max_width)
elif (p in ['quicklook']):
continue
else:
try:
... |
'Display stats on the screen.
stats: Stats database to display
cs_status:
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a SNMP server
"Disconnected": Client is disconnected from the server
Return:
True if the stats have been displayed
False if the ... | def display(self, stats, cs_status=None):
| self.init_line_column()
if (cs_status == 'SNMP'):
plugin_max_width = 43
else:
plugin_max_width = None
self.args.cs_status = cs_status
__stat_display = self.__get_stat_display(stats, plugin_max_width)
max_processes_displayed = (((self.screen.getmaxyx()[0] - 11) - self.get_stats_di... |
'Display the first line in the Curses interface.
system + ip + uptime'
| def __display_firstline(self, stat_display):
| self.space_between_column = 0
self.new_line()
l_uptime = ((((self.get_stats_display_width(stat_display['system']) + self.space_between_column) + self.get_stats_display_width(stat_display['ip'])) + 3) + self.get_stats_display_width(stat_display['uptime']))
self.display_plugin(stat_display['system'], disp... |
'Display the second line in the Curses interface.
<QUICKLOOK> + CPU|PERCPU + <GPU> + MEM + SWAP + LOAD'
| def __display_secondline(self, stat_display, stats):
| self.init_column()
self.new_line()
stat_display['quicklook'] = {'msgdict': []}
plugin_widths = {'quicklook': 0}
for p in ['cpu', 'gpu', 'mem', 'memswap', 'load']:
plugin_widths[p] = (self.get_stats_display_width(stat_display[p]) if (hasattr(self.args, ('disable_' + p)) and (p in stat_display... |
'Display the left sidebar in the Curses interface.
network+wifi+ports+diskio+fs+irq+folders+raid+sensors+now'
| def __display_left(self, stat_display):
| self.init_column()
if (not self.args.disable_left_sidebar):
for s in ['network', 'wifi', 'ports', 'diskio', 'fs', 'irq', 'folders', 'raid', 'sensors', 'now']:
if ((hasattr(self.args, ('enable_' + s)) or hasattr(self.args, ('disable_' + s))) and (s in stat_display)):
self.new_... |
'Display the right sidebar in the Curses interface.
docker + processcount + amps + processlist + alert'
| def __display_right(self, stat_display):
| if (self.screen.getmaxyx()[1] > 52):
self.next_line = self.saved_line
self.new_column()
self.new_line()
self.display_plugin(stat_display['docker'])
self.new_line()
self.display_plugin(stat_display['processcount'])
self.new_line()
self.display_plugin(st... |
'Display a centered popup.
If is_input is False:
Display a centered popup with the given message during duration seconds
If size_x and size_y: set the popup size
else set it automatically
Return True if the popup could be displayed
If is_input is True:
Display a centered popup with the given message and a input field
I... | def display_popup(self, message, size_x=None, size_y=None, duration=3, is_input=False, input_size=30, input_value=None):
| sentence_list = message.split('\n')
if (size_x is None):
size_x = (len(max(sentence_list, key=len)) + 4)
if is_input:
size_x += input_size
if (size_y is None):
size_y = (len(sentence_list) + 4)
screen_x = self.screen.getmaxyx()[1]
screen_y = self.screen.getmaxyx()... |
'Display the plugin_stats on the screen.
If display_optional=True display the optional stats
If display_additional=True display additionnal stats
max_y do not display line > max_y'
| def display_plugin(self, plugin_stats, display_optional=True, display_additional=True, max_y=65535, add_space=True):
| if ((plugin_stats is None) or (not plugin_stats['msgdict']) or (not plugin_stats['display'])):
return 0
screen_x = self.screen.getmaxyx()[1]
screen_y = self.screen.getmaxyx()[0]
if (plugin_stats['align'] == 'right'):
display_x = (screen_x - self.get_stats_display_width(plugin_stats))
... |
'Erase the content of the screen.'
| def erase(self):
| self.term_window.erase()
|
'Clear and update the screen.
stats: Stats database to display
cs_status:
"None": standalone or server mode
"Connected": Client is connected to the server
"Disconnected": Client is disconnected from the server'
| def flush(self, stats, cs_status=None):
| self.erase()
self.display(stats, cs_status=cs_status)
|
'Update the screen.
Wait for __refresh_time sec / catch key every 100 ms.
INPUT
stats: Stats database to display
cs_status:
"None": standalone or server mode
"Connected": Client is connected to the server
"Disconnected": Client is disconnected from the server
return_to_browser:
True: Do not exist, return to the browser... | def update(self, stats, cs_status=None, return_to_browser=False):
| self.flush(stats, cs_status=cs_status)
exitkey = False
countdown = Timer(self.__refresh_time)
while ((not countdown.finished()) and (not exitkey)):
pressedkey = self.__catch_key(return_to_browser=return_to_browser)
exitkey = ((pressedkey == ord('\x1b')) or (pressedkey == ord('q')))
... |
'Wait delay in ms'
| def wait(self, delay=100):
| curses.napms(100)
|
'Return the width of the formatted curses message.
The height is defined by the maximum line.'
| def get_stats_display_width(self, curse_msg, without_option=False):
| try:
if without_option:
c = len(max(''.join([(re.sub('[^\\x00-\\x7F]+', ' ', i['msg']) if (not i['optional']) else '') for i in curse_msg['msgdict']]).split('\n'), key=len))
else:
c = len(max(''.join([re.sub('[^\\x00-\\x7F]+', ' ', i['msg']) for i in curse_msg['msgdict'... |
'Return the height of the formatted curses message.
The height is defined by the number of \'\n\' (new line).'
| def get_stats_display_height(self, curse_msg):
| try:
c = [i['msg'] for i in curse_msg['msgdict']].count('\n')
except Exception:
return 0
else:
return (c + 1)
|
'items_history_list: list of stats to historized (define inside plugins)'
| def __init__(self):
| self.stats_history = {}
|
'Add an new item (key, value) to the current history.'
| def add(self, key, value, description='', history_max_size=None):
| if (key not in self.stats_history):
self.stats_history[key] = GlancesAttribute(key, description=description, history_max_size=history_max_size)
self.stats_history[key].value = value
|
'Reset all the stats history'
| def reset(self):
| for a in self.stats_history:
self.stats_history[a].history_reset()
|
'Get the history as a dict of list'
| def get(self, nb=0):
| return {i: self.stats_history[i].history_raw(nb=nb) for i in self.stats_history}
|
'Get the history as a dict of list (with list JSON compliant)'
| def get_json(self, nb=0):
| return {i: self.stats_history[i].history_json(nb=nb) for i in self.stats_history}
|
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
|
'Reset/init the stats.'
| def reset(self):
| self.stats = {}
|
'Update processes stats using the input method.'
| def update(self):
| self.reset()
if (self.input_method == 'local'):
glances_processes.update()
self.stats = glances_processes.getcount()
elif (self.input_method == 'snmp'):
pass
return self.stats
|
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if args.disable_process:
msg = "PROCESSES DISABLED (press 'z' to display)"
ret.append(self.curse_add_line(msg))
return ret
if (not self.stats):
return ret
if (glances_processes.process_filter is not None):
msg = 'Processes filter:'
... |
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
self.tag_proc_time = True
try:
self.nb_log_core = CorePlugin(args=self.args).update()['log']
except Exception:
self.nb_log_core = 0
self.max_values = glances_processes.max_values()
self.pid_max = glances_proces... |
'Return the key of the list.'
| def get_key(self):
| return 'pid'
|
'Reset/init the stats.'
| def reset(self):
| self.stats = []
|
'Update processes stats using the input method.'
| def update(self):
| self.reset()
if (self.input_method == 'local'):
if glances_processes.is_tree_enabled():
self.stats = glances_processes.gettree()
else:
self.stats = glances_processes.getlist()
self.max_values = glances_processes.max_values()
elif (self.input_method == 'snmp'):... |
'Get curses data to display for a process tree.'
| def get_process_tree_curses_data(self, node, args, first_level=True, max_node_count=None):
| ret = []
node_count = 0
if ((not node.is_root) and ((max_node_count is None) or (max_node_count > 0))):
node_data = self.get_process_curses_data(node.stats, False, args)
node_count += 1
ret.extend(node_data)
for child in node.iter_children():
if ((max_node_count is not No... |
'Add tree curses decoration and indentation to a subtree.'
| def add_tree_decoration(self, child_data, is_last_child, first_level):
| pos = []
for (i, m) in enumerate(child_data):
if m.get('_tree_decoration', False):
del m['_tree_decoration']
pos.append(i)
new_child_data = []
new_pos = []
for (i, m) in enumerate(child_data):
if (i in pos):
new_pos.append(len(new_child_data))
... |
'Get curses data to display for a process.
- p is the process to display
- first is a tag=True if the process is the first on the list'
| def get_process_curses_data(self, p, first, args):
| ret = [self.curse_new_line()]
if (('cpu_percent' in p) and (p['cpu_percent'] is not None) and (p['cpu_percent'] != '')):
if (args.disable_irix and (self.nb_log_core != 0)):
msg = '{:>6.1f}'.format((p['cpu_percent'] / float(self.nb_log_core)))
else:
msg = '{:>6.1f}'.format... |
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if ((not self.stats) or args.disable_process):
return ret
process_sort_key = glances_processes.sort_key
self.__msg_curse_header(ret, process_sort_key, args)
if glances_processes.is_tree_enabled():
ret.extend(self.get_process_tree_curses_data(self.__sort_stats(process_sort_ke... |
'Build the header and add it to the ret dict'
| def __msg_curse_header(self, ret, process_sort_key, args=None):
| sort_style = 'SORT'
if (args.disable_irix and (0 < self.nb_log_core < 10)):
msg = '{:>6}'.format(('CPU%/' + str(self.nb_log_core)))
elif (args.disable_irix and (self.nb_log_core != 0)):
msg = '{:>6}'.format('CPU%/C')
else:
msg = '{:>6}'.format('CPU%')
ret.append(self.curse_ad... |
'Build the sum message (only when filter is on) and add it to the ret dict
* ret: list of string where the message is added
* sep_char: define the line separation char
* mmm: display min, max, mean or current (if mmm=None)
* args: Glances args'
| def __msg_curse_sum(self, ret, sep_char='_', mmm=None, args=None):
| ret.append(self.curse_new_line())
if (mmm is None):
ret.append(self.curse_add_line((sep_char * 69)))
ret.append(self.curse_new_line())
msg = '{:>6.1f}'.format(self.__sum_stats('cpu_percent', mmm=mmm))
ret.append(self.curse_add_line(msg, decoration=self.__mmm_deco(mmm)))
msg = '{:>6.1... |
'Return the decoration string for the current mmm status'
| def __mmm_deco(self, mmm):
| if (mmm is not None):
return 'DEFAULT'
else:
return 'FILTER'
|
'Reset the MMM stats'
| def __mmm_reset(self):
| self.mmm_min = {}
self.mmm_max = {}
|
'Return the sum of the stats value for the given key
* indice: If indice is set, get the p[key][indice]
* mmm: display min, max, mean or current (if mmm=None)'
| def __sum_stats(self, key, indice=None, mmm=None):
| ret = 0
for p in self.stats:
if (indice is None):
ret += p[key]
else:
ret += p[key][indice]
mmm_key = self.__mmm_key(key, indice)
if (mmm == 'min'):
try:
if (self.mmm_min[mmm_key] > ret):
self.mmm_min[mmm_key] = ret
exce... |
'Return the stats (dict) sorted by (sortedby)'
| def __sort_stats(self, sortedby=None):
| return sort_stats(self.stats, sortedby, tree=glances_processes.is_tree_enabled(), reverse=glances_processes.sort_reverse)
|
'Return the maximum PID size in number of char'
| def __max_pid_size(self):
| if (self.pid_max is not None):
return len(str(self.pid_max))
else:
return 5
|
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
self.reset()
|
'Reset/init the stats.'
| def reset(self):
| self.stats = {}
|
'Update RAID stats using the input method.'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (self.input_method == 'local'):
try:
mds = MdStat()
self.stats = mds.get_stats()['arrays']
except Exception as e:
logger.debug(('Can not grab RAID stats (%s)' % e))
return self.stats
elif (self.input_method == 'sn... |
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if (not self.stats):
return ret
msg = '{:11}'.format('RAID disks')
ret.append(self.curse_add_line(msg, 'TITLE'))
msg = '{:>6}'.format('Used')
ret.append(self.curse_add_line(msg))
msg = '{:>6}'.format('Avail')
ret.append(self.curse_add_line(msg))
arrays = sorted(it... |
'RAID alert messages.
[available/used] means that ideally the array may have _available_
devices however, _used_ devices are in use.
Obviously when used >= available then things are good.'
| def raid_alert(self, status, used, available):
| if (status == 'inactive'):
return 'CRITICAL'
if ((used is None) or (available is None)):
return 'DEFAULT'
elif (used < available):
return 'WARNING'
return 'OK'
|
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
self.reset()
|
'Return the key of the list.'
| def get_key(self):
| return 'cpu_number'
|
'Reset/init the stats.'
| def reset(self):
| self.stats = []
|
'Update per-CPU stats using the input method.'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (self.input_method == 'local'):
self.stats = cpu_percent.get(percpu=True)
else:
pass
return self.stats
|
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if (not self.stats):
msg = 'PER CPU not available'
ret.append(self.curse_add_line(msg, 'TITLE'))
return ret
msg = '{:8}'.format('PER CPU')
ret.append(self.curse_add_line(msg, 'TITLE'))
for cpu in self.stats:
try:
msg = '{:6.1f}%'.forma... |
'Init the CPU plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.display_curse = True
self.reset()
try:
self.nb_log_core = CorePlugin(args=self.args).update()['log']
except Exception:
self.nb_log_core = 1
|
'Reset/init the stats.'
| def reset(self):
| self.stats = {}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.