INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Update the command result attributed. | def update(self):
"""Update the command result attributed."""
# Only continue if monitor list is not empty
if len(self.__folder_list) == 0:
return self.__folder_list
# Iter upon the folder list
for i in range(len(self.get())):
# Update folder size
... |
Return the bars. | def get(self):
"""Return the bars."""
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_... |
Init the connection to the CouchDB server. | def init(self):
"""Init the connection to the CouchDB server."""
if not self.export_enable:
return None
server_uri = 'tcp://{}:{}'.format(self.host, self.port)
try:
self.context = zmq.Context()
publisher = self.context.socket(zmq.PUB)
pub... |
Close the socket and context | def exit(self):
"""Close the socket and context"""
if self.client is not None:
self.client.close()
if self.context is not None:
self.context.destroy() |
Write the points to the ZeroMQ server. | def export(self, name, columns, points):
"""Write the points to the ZeroMQ server."""
logger.debug("Export {} stats to ZeroMQ".format(name))
# Create DB input
data = dict(zip(columns, points))
# Do not publish empty stats
if data == {}:
return False
... |
Init the connection to the Cassandra server. | def init(self):
"""Init the connection to the Cassandra server."""
if not self.export_enable:
return None
# if username and/or password are not set the connection will try to connect with no auth
auth_provider = PlainTextAuthProvider(
username=self.username, pass... |
Write the points to the Cassandra cluster. | def export(self, name, columns, points):
"""Write the points to the Cassandra cluster."""
logger.debug("Export {} stats to Cassandra".format(name))
# Remove non number stats and convert all to float (for Boolean)
data = {k: float(v) for (k, v) in dict(zip(columns, points)).iteritems() i... |
Close the Cassandra export module. | def exit(self):
"""Close the Cassandra export module."""
# To ensure all connections are properly closed
self.session.shutdown()
self.cluster.shutdown()
# Call the father method
super(Export, self).exit() |
Try to determine the name of a Linux distribution. | def _linux_os_release():
"""Try to determine the name of a Linux distribution.
This function checks for the /etc/os-release file.
It takes the name from the 'NAME' field and the version from 'VERSION_ID'.
An empty string is returned if the above values cannot be determined.
"""
pretty_name = ''... |
Update the host/ system info using the input method. | def update(self):
"""Update the host/system info using the input method.
Return the stats (dict)
"""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
stats['os_name'] = p... |
Return the string to display in the curse interface. | def msg_curse(self, args=None, max_width=None):
"""Return the string to display in the curse interface."""
# Init the return message
ret = []
# Build the string message
if args.client:
# Client mode
if args.cs_status.lower() == "connected":
... |
Update swap memory stats using the input method. | def update(self):
"""Update swap memory stats using the input method."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
# Grab SWAP using the psutil swap_memory method
sm_st... |
Update stats views. | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert and log
self.views['used']['decoration'] = self.get_alert_log(self.stats['used'], maximum=self.stats['total']) |
Return the dict to display in the curse interface. | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and plugin not disabled
if not self.stats or self.is_disable():
return ret
# Build the s... |
Update the AMP list. | def update(self):
"""Update the AMP list."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
for k, v in iteritems(self.glances_amps.update()):
stats.append({'key': k,
'name': v.NAME,
... |
Return the alert status relative to the process number. | def get_alert(self, nbprocess=0, countmin=None, countmax=None, header="", log=False):
"""Return the alert status relative to the process number."""
if nbprocess is None:
return 'OK'
if countmin is None:
countmin = nbprocess
if countmax is None:
countma... |
Return the dict to display in the curse interface. | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
# Only process if stats exist and display plugin enable...
ret = []
if not self.stats or args.disable_process or self.is_disable():
retu... |
Update per - CPU stats using the input method. | def update(self):
"""Update per-CPU stats using the input method."""
# Init new stats
stats = self.get_init_value()
# Grab per-CPU stats using psutil's cpu_percent(percpu=True) and
# cpu_times_percent(percpu=True) methods
if self.input_method == 'local':
stat... |
Return the dict to display in the curse interface. | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist...
if not self.stats or not self.args.percpu or self.is_disable():
return ret
# Build th... |
Overwrite the exit method to close threads. | def exit(self):
"""Overwrite the exit method to close threads."""
if self._thread is not None:
self._thread.stop()
# Call the father class
super(Plugin, self).exit() |
Update the ports list. | def update(self):
"""Update the ports list."""
if self.input_method == 'local':
# Only refresh:
# * if there is not other scanning thread
# * every refresh seconds (define in the configuration file)
if self._thread is None:
thread_is_runnin... |
Return the alert status relative to the port scan return value. | def get_ports_alert(self, port, header="", log=False):
"""Return the alert status relative to the port scan return value."""
ret = 'OK'
if port['status'] is None:
ret = 'CAREFUL'
elif port['status'] == 0:
ret = 'CRITICAL'
elif (isinstance(port['status'], (... |
Return the alert status relative to the web/ url scan return value. | def get_web_alert(self, web, header="", log=False):
"""Return the alert status relative to the web/url scan return value."""
ret = 'OK'
if web['status'] is None:
ret = 'CAREFUL'
elif web['status'] not in [200, 301, 302]:
ret = 'CRITICAL'
elif web['rtt_warn... |
Return the dict to display in the curse interface. | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
# Only process if stats exist and display plugin enable...
ret = []
if not self.stats or args.disable_ports:
return ret
# Max s... |
Grab the stats. | def run(self):
"""Grab the stats.
Infinite loop, should be stopped by calling the stop() method.
"""
for p in self._stats:
# End of the thread has been asked
if self.stopped():
break
# Scan a port (ICMP or TCP)
if 'port' in... |
Stop the thread. | def stop(self, timeout=None):
"""Stop the thread."""
logger.debug("ports plugin - Close thread for scan list {}".format(self._stats))
self._stopper.set() |
Scan the Web/ URL ( dict ) and update the status key. | def _web_scan(self, web):
"""Scan the Web/URL (dict) and update the status key."""
try:
req = requests.head(web['url'],
allow_redirects=True,
verify=web['ssl_verify'],
proxies=web['proxies'],
... |
Scan the port structure ( dict ) and update the status key. | def _port_scan(self, port):
"""Scan the port structure (dict) and update the status key."""
if int(port['port']) == 0:
return self._port_scan_icmp(port)
else:
return self._port_scan_tcp(port) |
Convert hostname to IP address. | def _resolv_name(self, hostname):
"""Convert hostname to IP address."""
ip = hostname
try:
ip = socket.gethostbyname(hostname)
except Exception as e:
logger.debug("{}: Cannot convert {} to IP address ({})".format(self.plugin_name, hostname, e))
return ip |
Scan the ( ICMP ) port structure ( dict ) and update the status key. | def _port_scan_icmp(self, port):
"""Scan the (ICMP) port structure (dict) and update the status key."""
ret = None
# Create the ping command
# Use the system ping command because it already have the steacky bit set
# Python can not create ICMP packet with non root right
... |
Scan the ( TCP ) port structure ( dict ) and update the status key. | def _port_scan_tcp(self, port):
"""Scan the (TCP) port structure (dict) and update the status key."""
ret = None
# Create and configure the scanning socket
try:
socket.setdefaulttimeout(port['timeout'])
_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
... |
Wrapper to load: plugins and export modules. | def load_modules(self, args):
"""Wrapper to load: plugins and export modules."""
# Init the plugins dict
# Active plugins dictionnary
self._plugins = collections.defaultdict(dict)
# Load the plugins
self.load_plugins(args=args)
# Init the export modules dict
... |
Load the plugin ( script ) init it and add to the _plugin dict. | def _load_plugin(self, plugin_script, args=None, config=None):
"""Load the plugin (script), init it and add to the _plugin dict."""
# The key is the plugin name
# for example, the file glances_xxx.py
# generate self._plugins_list["xxx"] = ...
name = plugin_script[len(self.header)... |
Load all plugins in the plugins folder. | def load_plugins(self, args=None):
"""Load all plugins in the 'plugins' folder."""
for item in os.listdir(plugins_path):
if (item.startswith(self.header) and
item.endswith(".py") and
item != (self.header + "plugin.py")):
# Load the plug... |
Load all export modules in the exports folder. | def load_exports(self, args=None):
"""Load all export modules in the 'exports' folder."""
if args is None:
return False
header = "glances_"
# Build the export module available list
args_var = vars(locals()['args'])
for item in os.listdir(exports_path):
... |
Return the plugins list. | def getPluginsList(self, enable=True):
"""Return the plugins list.
if enable is True, only return the active plugins (default)
if enable is False, return all the plugins
Return: list of plugin name
"""
if enable:
return [p for p in self._plugins if self._plu... |
Return the exports list. | def getExportsList(self, enable=True):
"""Return the exports list.
if enable is True, only return the active exporters (default)
if enable is False, return all the exporters
Return: list of export module name
"""
if enable:
return [e for e in self._exports]
... |
Load the stats limits ( except the one in the exclude list ). | def load_limits(self, config=None):
"""Load the stats limits (except the one in the exclude list)."""
# For each plugins, call the load_limits method
for p in self._plugins:
self._plugins[p].load_limits(config) |
Wrapper method to update the stats. | def update(self):
"""Wrapper method to update the stats."""
# For standalone and server modes
# For each plugins, call the update method
for p in self._plugins:
if self._plugins[p].is_disable():
# If current plugin is disable
# then continue to... |
Export all the stats. | def export(self, input_stats=None):
"""Export all the stats.
Each export module is ran in a dedicated thread.
"""
# threads = []
input_stats = input_stats or {}
for e in self._exports:
logger.debug("Export stats using the %s module" % e)
thread =... |
Return all the stats ( dict ). | def getAllAsDict(self):
"""Return all the stats (dict)."""
return {p: self._plugins[p].get_raw() for p in self._plugins} |
Return all the stats to be exported ( list ). Default behavor is to export all the stat if plugin_list is provided only export stats of given plugin ( list ) | def getAllExports(self, plugin_list=None):
"""
Return all the stats to be exported (list).
Default behavor is to export all the stat
if plugin_list is provided, only export stats of given plugin (list)
"""
if plugin_list is None:
# All plugins should be export... |
Return all the stats to be exported ( list ). Default behavor is to export all the stat if plugin_list is provided only export stats of given plugin ( list ) | def getAllExportsAsDict(self, plugin_list=None):
"""
Return all the stats to be exported (list).
Default behavor is to export all the stat
if plugin_list is provided, only export stats of given plugin (list)
"""
if plugin_list is None:
# All plugins should be ... |
Return all the stats limits ( dict ). Default behavor is to export all the limits if plugin_list is provided only export limits of given plugin ( list ) | def getAllLimitsAsDict(self, plugin_list=None):
"""
Return all the stats limits (dict).
Default behavor is to export all the limits
if plugin_list is provided, only export limits of given plugin (list)
"""
if plugin_list is None:
# All plugins should be export... |
Return all the stats views ( dict ). | def getAllViewsAsDict(self):
"""Return all the stats views (dict)."""
return {p: self._plugins[p].get_views() for p in self._plugins} |
End of the Glances stats. | def end(self):
"""End of the Glances stats."""
# Close export modules
for e in self._exports:
self._exports[e].exit()
# Close plugins
for p in self._plugins:
self._plugins[p].exit() |
Update network stats using the input method. | def update(self):
"""Update network stats using the input method.
Stats is a list of dict (one dict per interface)
"""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
#... |
Update stats views. | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert
for i in self.stats:
ifrealname = i['interface_name'].split(':')[0]
# Convert rate in bps ( to be ... |
Return the dict to display in the curse interface. | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or self.is_disable():
return ret
# Max si... |
Init the connection to the ES server. | def init(self):
"""Init the connection to the ES server."""
if not self.export_enable:
return None
self.index='{}-{}'.format(self.index, datetime.utcnow().strftime("%Y.%m.%d"))
template_body = {
"mappings": {
"glances": {
"dynamic_templat... |
Write the points to the ES server. | def export(self, name, columns, points):
"""Write the points to the ES server."""
logger.debug("Export {} stats to ElasticSearch".format(name))
# Create DB input
# https://elasticsearch-py.readthedocs.io/en/master/helpers.html
actions = []
for c, p in zip(columns, points... |
Update IP stats using the input method. | def update(self):
"""Update IP stats using the input method.
Stats is dict
"""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local' and not import_error_tag:
# Update stats using the netifaces lib
try:
de... |
Update stats views. | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Optional
for key in iterkeys(self.stats):
self.views[key]['optional'] = True |
Return the dict to display in the curse interface. | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or self.is_disable():
return ret
# Build ... |
Get the first public IP address returned by one of the online services. | def get(self):
"""Get the first public IP address returned by one of the online services."""
q = queue.Queue()
for u, j, k in urls:
t = threading.Thread(target=self._get_ip_public, args=(q, u, j, k))
t.daemon = True
t.start()
timer = Timer(self.timeo... |
Request the url service and put the result in the queue_target. | def _get_ip_public(self, queue_target, url, json=False, key=None):
"""Request the url service and put the result in the queue_target."""
try:
response = urlopen(url, timeout=self.timeout).read().decode('utf-8')
except Exception as e:
logger.debug("IP plugin - Cannot open ... |
Update the AMP | def update(self, process_list):
"""Update the AMP"""
# Get the Nginx status
logger.debug('{}: Update stats using status URL {}'.format(self.NAME, self.get('status_url')))
res = requests.get(self.get('status_url'))
if res.ok:
# u'Active connections: 1 \nserver accepts ... |
Init the connection to the Kafka server. | def init(self):
"""Init the connection to the Kafka server."""
if not self.export_enable:
return None
# Build the server URI with host and port
server_uri = '{}:{}'.format(self.host, self.port)
try:
s = KafkaProducer(bootstrap_servers=server_uri,
... |
Write the points to the kafka server. | def export(self, name, columns, points):
"""Write the points to the kafka server."""
logger.debug("Export {} stats to Kafka".format(name))
# Create DB input
data = dict(zip(columns, points))
# Send stats to the kafka topic
# key=<plugin name>
# value=JSON dict
... |
Close the Kafka export module. | def exit(self):
"""Close the Kafka export module."""
# To ensure all connections are properly closed
self.client.flush()
self.client.close()
# Call the father method
super(Export, self).exit() |
Specific case for io_counters Sum of io_r + io_w | def _sort_io_counters(process,
sortedby='io_counters',
sortedby_secondary='memory_percent'):
"""Specific case for io_counters
Sum of io_r + io_w"""
return process[sortedby][0] - process[sortedby][2] + process[sortedby][1] - process[sortedby][3] |
Return a sort lambda function for the sortedbykey | def _sort_lambda(sortedby='cpu_percent',
sortedby_secondary='memory_percent'):
"""Return a sort lambda function for the sortedbykey"""
ret = None
if sortedby == 'io_counters':
ret = _sort_io_counters
elif sortedby == 'cpu_times':
ret = _sort_cpu_times
return ret |
Return the stats ( dict ) sorted by ( sortedby ). | def sort_stats(stats,
sortedby='cpu_percent',
sortedby_secondary='memory_percent',
reverse=True):
"""Return the stats (dict) sorted by (sortedby).
Reverse the sort if reverse is True.
"""
if sortedby is None and sortedby_secondary is None:
# No need ... |
Update the global process count from the current processes list | def update_processcount(self, plist):
"""Update the global process count from the current processes list"""
# Update the maximum process ID (pid) number
self.processcount['pid_max'] = self.pid_max
# For each key in the processcount dict
# count the number of processes with the sa... |
Get the maximum PID value. | def pid_max(self):
"""
Get the maximum PID value.
On Linux, the value is read from the `/proc/sys/kernel/pid_max` file.
From `man 5 proc`:
The default value for this file, 32768, results in the same range of
PIDs as on earlier kernels. On 32-bit platfroms, 32768 is the ... |
Reset the maximum values dict. | def reset_max_values(self):
"""Reset the maximum values dict."""
self._max_values = {}
for k in self._max_values_list:
self._max_values[k] = 0.0 |
Update the processes stats. | def update(self):
"""Update the processes stats."""
# Reset the stats
self.processlist = []
self.reset_processcount()
# Do not process if disable tag is set
if self.disable_tag:
return
# Time since last update (for disk_io rate computation)
t... |
Update the AMP | def update(self, process_list):
"""Update the AMP"""
# Get the systemctl status
logger.debug('{}: Update stats using service {}'.format(self.NAME, self.get('service_cmd')))
try:
res = check_output(self.get('service_cmd').split(), stderr=STDOUT).decode('utf-8')
except ... |
Convert seconds to human - readable time. | def seconds_to_hms(input_seconds):
"""Convert seconds to human-readable time."""
minutes, seconds = divmod(input_seconds, 60)
hours, minutes = divmod(minutes, 60)
hours = int(hours)
minutes = int(minutes)
seconds = str(int(seconds)).zfill(2)
return hours, minutes, seconds |
Return path cmd and arguments for a process cmdline. | def split_cmdline(cmdline):
"""Return path, cmd and arguments for a process cmdline."""
path, cmd = os.path.split(cmdline[0])
arguments = ' '.join(cmdline[1:])
return path, cmd, arguments |
Update processes stats using the input method. | def update(self):
"""Update processes stats using the input method."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
# Note: Update is done in the processcount plugin
# Jus... |
Return the alert relative to the Nice configuration list | def get_nice_alert(self, value):
"""Return the alert relative to the Nice configuration list"""
value = str(value)
try:
if value in self.get_limit('nice_critical'):
return 'CRITICAL'
except KeyError:
pass
try:
if value in self.g... |
Get curses data to display for a process. | def get_process_curses_data(self, p, first, args):
"""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
"""
ret = [self.curse_new_line()]
# CPU
if 'cpu_percent' in p and p['cpu_pe... |
Return the dict to display in the curse interface. | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or args.disable_process:
return ret
# Com... |
Build the header and add it to the ret dict. | def __msg_curse_header(self, ret, process_sort_key, args=None):
"""Build the header and add it to the ret dict."""
sort_style = 'SORT'
if args.disable_irix and 0 < self.nb_log_core < 10:
msg = self.layout_header['cpu'].format('CPU%/' + str(self.nb_log_core))
elif args.disabl... |
Build the sum message ( only when filter is on ) and add it to the ret dict. | def __msg_curse_sum(self, ret, sep_char='_', mmm=None, args=None):
"""
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... |
Return the sum of the stats value for the given key. | def __sum_stats(self, key, indice=None, mmm=None):
"""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)
"""
# Compute stats summary
ret = 0
for p in self.... |
Return the stats ( dict ) sorted by ( sortedby ). | def __sort_stats(self, sortedby=None):
"""Return the stats (dict) sorted by (sortedby)."""
return sort_stats(self.stats, sortedby,
reverse=glances_processes.sort_reverse) |
Build and return the header line | def build_header(self, plugin, attribute, stat):
"""Build and return the header line"""
line = ''
if attribute is not None:
line += '{}.{}{}'.format(plugin, attribute, self.separator)
else:
if isinstance(stat, dict):
for k in stat.keys():
... |
Build and return the data line | def build_data(self, plugin, attribute, stat):
"""Build and return the data line"""
line = ''
if attribute is not None:
line += '{}{}'.format(str(stat.get(attribute, self.na)),
self.separator)
else:
if isinstance(stat, dict):
... |
Display stats to stdout. Refresh every duration second. | def update(self,
stats,
duration=3):
"""Display stats to stdout.
Refresh every duration second.
"""
# Build the stats list
line = ''
for plugin, attribute in self.plugins_list:
# Check if the plugin exist and is enable
... |
Init the connection to the Riemann server. | def init(self):
"""Init the connection to the Riemann server."""
if not self.export_enable:
return None
try:
client = bernhard.Client(host=self.host, port=self.port)
return client
except Exception as e:
logger.critical("Connection to Rieman... |
Write the points in Riemann. | def export(self, name, columns, points):
"""Write the points in Riemann."""
for i in range(len(columns)):
if not isinstance(points[i], Number):
continue
else:
data = {'host': self.hostname, 'service': name + " " + columns[i], 'metric': points[i]}
... |
Return the elapsed time since last update. | def getTimeSinceLastUpdate(IOType):
"""Return the elapsed time since last update."""
global last_update_times
# assert(IOType in ['net', 'disk', 'process_disk'])
current_time = time()
last_time = last_update_times.get(IOType)
if not last_time:
time_since_update = 1
else:
time... |
Compute a simple mean subsampling. | def subsample(data, sampling):
"""Compute a simple mean subsampling.
Data should be a list of numerical itervalues
Return a subsampled list of sampling lenght
"""
if len(data) <= sampling:
return data
sampling_length = int(round(len(data) / float(sampling)))
return [mean(data[s * s... |
Compute a simple mean subsampling. | def time_serie_subsample(data, sampling):
"""Compute a simple mean subsampling.
Data should be a list of set (time, value)
Return a subsampled list of sampling lenght
"""
if len(data) <= sampling:
return data
t = [t[0] for t in data]
v = [t[1] for t in data]
sampling_length = i... |
Init the connection to the CouchDB server. | def init(self):
"""Init the connection to the CouchDB server."""
if not self.export_enable:
return None
if self.user is None:
server_uri = 'http://{}:{}/'.format(self.host,
self.port)
else:
server_uri = ... |
Write the points to the CouchDB server. | def export(self, name, columns, points):
"""Write the points to the CouchDB server."""
logger.debug("Export {} stats to CouchDB".format(name))
# Create DB input
data = dict(zip(columns, points))
# Set the type to the current stat name
data['type'] = name
data['t... |
Update core stats. | def update(self):
"""Update core stats.
Stats is a dict (with both physical and log cpu number) instead of a integer.
"""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
... |
Return True if the theme * name * should be used. | def is_theme(self, name):
"""Return True if the theme *name* should be used."""
return getattr(self.args, 'theme_' + name) or self.theme['name'] == name |
Init cursors. | def _init_cursor(self):
"""Init cursors."""
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):
"""Init the Curses color layout."""
# Set curses options
try:
if hasattr(curses, 'start_color'):
curses.start_color()
if hasattr(curses, 'use_default_colors'):
curses.use_default_colors()
except Exception as... |
Return the current sort in the loop | def loop_position(self):
"""Return the current sort in the loop"""
for i, v in enumerate(self._sort_loop):
if v == glances_processes.sort_key:
return i
return 0 |
Disable the full quicklook mode | def enable_fullquicklook(self):
"""Disable the full quicklook mode"""
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):
"""Shutdown the curses window."""
if hasattr(curses, 'echo'):
curses.echo()
if hasattr(curses, 'nocbreak'):
curses.nocbreak()
if hasattr(curses, 'curs_set'):
try:
curses.curs_set(1)
except Exception:
... |
Return a dict of dict with all the stats display. stats: Global stats dict layer: ~ 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 | def __get_stat_display(self, stats, layer):
"""Return a dict of dict with all the stats display.
stats: Global stats dict
layer: ~ cs_status
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a... |
Display stats on the screen. | def display(self, stats, cs_status=None):
"""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
... |
Display the firsts lines ( header ) in the Curses interface. | def __display_header(self, stat_display):
"""Display the firsts lines (header) in the Curses interface.
system + ip + uptime
(cloud)
"""
# First line
self.new_line()
self.space_between_column = 0
l_uptime = (self.get_stats_display_width(stat_display["syst... |
Display the second line in the Curses interface. | def __display_top(self, stat_display, stats):
"""Display the second line in the Curses interface.
<QUICKLOOK> + CPU|PERCPU + <GPU> + MEM + SWAP + LOAD
"""
self.init_column()
self.new_line()
# Init quicklook
stat_display['quicklook'] = {'msgdict': []}
# ... |
Display the left sidebar in the Curses interface. | def __display_left(self, stat_display):
"""Display the left sidebar in the Curses interface."""
self.init_column()
if self.args.disable_left_sidebar:
return
for s in self._left_sidebar:
if ((hasattr(self.args, 'enable_' + s) or
hasattr(self.args... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.