repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
nicolargo/glances
glances/plugins/glances_gpu.py
Plugin.exit
def exit(self): """Overwrite the exit method to close the GPU API.""" if self.nvml_ready: try: pynvml.nvmlShutdown() except Exception as e: logger.debug("pynvml failed to shutdown correctly ({})".format(e)) # Call the father exit method ...
python
def exit(self): """Overwrite the exit method to close the GPU API.""" if self.nvml_ready: try: pynvml.nvmlShutdown() except Exception as e: logger.debug("pynvml failed to shutdown correctly ({})".format(e)) # Call the father exit method ...
[ "def", "exit", "(", "self", ")", ":", "if", "self", ".", "nvml_ready", ":", "try", ":", "pynvml", ".", "nvmlShutdown", "(", ")", "except", "Exception", "as", "e", ":", "logger", ".", "debug", "(", "\"pynvml failed to shutdown correctly ({})\"", ".", "format"...
Overwrite the exit method to close the GPU API.
[ "Overwrite", "the", "exit", "method", "to", "close", "the", "GPU", "API", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_gpu.py#L239-L248
train
nicolargo/glances
glances/client.py
GlancesClient.log_and_exit
def log_and_exit(self, msg=''): """Log and exit.""" if not self.return_to_browser: logger.critical(msg) sys.exit(2) else: logger.error(msg)
python
def log_and_exit(self, msg=''): """Log and exit.""" if not self.return_to_browser: logger.critical(msg) sys.exit(2) else: logger.error(msg)
[ "def", "log_and_exit", "(", "self", ",", "msg", "=", "''", ")", ":", "if", "not", "self", ".", "return_to_browser", ":", "logger", ".", "critical", "(", "msg", ")", "sys", ".", "exit", "(", "2", ")", "else", ":", "logger", ".", "error", "(", "msg",...
Log and exit.
[ "Log", "and", "exit", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client.py#L79-L85
train
nicolargo/glances
glances/client.py
GlancesClient._login_glances
def _login_glances(self): """Login to a Glances server""" client_version = None try: client_version = self.client.init() except socket.error as err: # Fallback to SNMP self.client_mode = 'snmp' logger.error("Connection to Glances server fai...
python
def _login_glances(self): """Login to a Glances server""" client_version = None try: client_version = self.client.init() except socket.error as err: # Fallback to SNMP self.client_mode = 'snmp' logger.error("Connection to Glances server fai...
[ "def", "_login_glances", "(", "self", ")", ":", "client_version", "=", "None", "try", ":", "client_version", "=", "self", ".", "client", ".", "init", "(", ")", "except", "socket", ".", "error", "as", "err", ":", "# Fallback to SNMP", "self", ".", "client_m...
Login to a Glances server
[ "Login", "to", "a", "Glances", "server" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client.py#L101-L137
train
nicolargo/glances
glances/client.py
GlancesClient._login_snmp
def _login_snmp(self): """Login to a SNMP server""" logger.info("Trying to grab stats by SNMP...") from glances.stats_client_snmp import GlancesStatsClientSNMP # Init stats self.stats = GlancesStatsClientSNMP(config=self.config, args=self.args) if not self.stats.check_...
python
def _login_snmp(self): """Login to a SNMP server""" logger.info("Trying to grab stats by SNMP...") from glances.stats_client_snmp import GlancesStatsClientSNMP # Init stats self.stats = GlancesStatsClientSNMP(config=self.config, args=self.args) if not self.stats.check_...
[ "def", "_login_snmp", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Trying to grab stats by SNMP...\"", ")", "from", "glances", ".", "stats_client_snmp", "import", "GlancesStatsClientSNMP", "# Init stats", "self", ".", "stats", "=", "GlancesStatsClientSNMP", "...
Login to a SNMP server
[ "Login", "to", "a", "SNMP", "server" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client.py#L139-L152
train
nicolargo/glances
glances/client.py
GlancesClient.login
def login(self): """Logon to the server.""" if self.args.snmp_force: # Force SNMP instead of Glances server self.client_mode = 'snmp' else: # First of all, trying to connect to a Glances server if not self._login_glances(): return ...
python
def login(self): """Logon to the server.""" if self.args.snmp_force: # Force SNMP instead of Glances server self.client_mode = 'snmp' else: # First of all, trying to connect to a Glances server if not self._login_glances(): return ...
[ "def", "login", "(", "self", ")", ":", "if", "self", ".", "args", ".", "snmp_force", ":", "# Force SNMP instead of Glances server", "self", ".", "client_mode", "=", "'snmp'", "else", ":", "# First of all, trying to connect to a Glances server", "if", "not", "self", ...
Logon to the server.
[ "Logon", "to", "the", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client.py#L154-L183
train
nicolargo/glances
glances/client.py
GlancesClient.update
def update(self): """Update stats from Glances/SNMP server.""" if self.client_mode == 'glances': return self.update_glances() elif self.client_mode == 'snmp': return self.update_snmp() else: self.end() logger.critical("Unknown server mode: ...
python
def update(self): """Update stats from Glances/SNMP server.""" if self.client_mode == 'glances': return self.update_glances() elif self.client_mode == 'snmp': return self.update_snmp() else: self.end() logger.critical("Unknown server mode: ...
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "client_mode", "==", "'glances'", ":", "return", "self", ".", "update_glances", "(", ")", "elif", "self", ".", "client_mode", "==", "'snmp'", ":", "return", "self", ".", "update_snmp", "(", ")", ...
Update stats from Glances/SNMP server.
[ "Update", "stats", "from", "Glances", "/", "SNMP", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client.py#L185-L194
train
nicolargo/glances
glances/client.py
GlancesClient.update_glances
def update_glances(self): """Get stats from Glances server. Return the client/server connection status: - Connected: Connection OK - Disconnected: Connection NOK """ # Update the stats try: server_stats = json.loads(self.client.getAll()) excep...
python
def update_glances(self): """Get stats from Glances server. Return the client/server connection status: - Connected: Connection OK - Disconnected: Connection NOK """ # Update the stats try: server_stats = json.loads(self.client.getAll()) excep...
[ "def", "update_glances", "(", "self", ")", ":", "# Update the stats", "try", ":", "server_stats", "=", "json", ".", "loads", "(", "self", ".", "client", ".", "getAll", "(", ")", ")", "except", "socket", ".", "error", ":", "# Client cannot get server stats", ...
Get stats from Glances server. Return the client/server connection status: - Connected: Connection OK - Disconnected: Connection NOK
[ "Get", "stats", "from", "Glances", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client.py#L196-L215
train
nicolargo/glances
glances/client.py
GlancesClient.serve_forever
def serve_forever(self): """Main client loop.""" # Test if client and server are in the same major version if not self.login(): logger.critical("The server version is not compatible with the client") self.end() return self.client_mode exitkey = False...
python
def serve_forever(self): """Main client loop.""" # Test if client and server are in the same major version if not self.login(): logger.critical("The server version is not compatible with the client") self.end() return self.client_mode exitkey = False...
[ "def", "serve_forever", "(", "self", ")", ":", "# Test if client and server are in the same major version", "if", "not", "self", ".", "login", "(", ")", ":", "logger", ".", "critical", "(", "\"The server version is not compatible with the client\"", ")", "self", ".", "e...
Main client loop.
[ "Main", "client", "loop", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client.py#L234-L261
train
nicolargo/glances
glances/plugins/glances_folders.py
Plugin.update
def update(self): """Update the foldered list.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Folder list only available in a full Glances environment # Check if the glances_folder instance is init if self.glances...
python
def update(self): """Update the foldered list.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Folder list only available in a full Glances environment # Check if the glances_folder instance is init if self.glances...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "self", ".", "input_method", "==", "'local'", ":", "# Folder list only available in a full Glances environment", "# Check if the glances_folder instanc...
Update the foldered list.
[ "Update", "the", "foldered", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_folders.py#L53-L75
train
nicolargo/glances
glances/plugins/glances_folders.py
Plugin.get_alert
def get_alert(self, stat, header=""): """Manage limits of the folder list.""" if not isinstance(stat['size'], numbers.Number): ret = 'DEFAULT' else: ret = 'OK' if stat['critical'] is not None and \ stat['size'] > int(stat['critical']) * 1000000...
python
def get_alert(self, stat, header=""): """Manage limits of the folder list.""" if not isinstance(stat['size'], numbers.Number): ret = 'DEFAULT' else: ret = 'OK' if stat['critical'] is not None and \ stat['size'] > int(stat['critical']) * 1000000...
[ "def", "get_alert", "(", "self", ",", "stat", ",", "header", "=", "\"\"", ")", ":", "if", "not", "isinstance", "(", "stat", "[", "'size'", "]", ",", "numbers", ".", "Number", ")", ":", "ret", "=", "'DEFAULT'", "else", ":", "ret", "=", "'OK'", "if",...
Manage limits of the folder list.
[ "Manage", "limits", "of", "the", "folder", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_folders.py#L77-L106
train
nicolargo/glances
glances/plugins/glances_folders.py
Plugin.msg_curse
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...
python
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...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Only process if stats exist and display plugin enable...", "if", "not", "self", ".", "stats", "or", "self", ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_folders.py#L108-L143
train
nicolargo/glances
glances/actions.py
GlancesActions.run
def run(self, stat_name, criticity, commands, repeat, mustache_dict=None): """Run the commands (in background). - stats_name: plugin_name (+ header) - criticity: criticity of the trigger - commands: a list of command line with optional {{mustache}} - If True, then repeat the act...
python
def run(self, stat_name, criticity, commands, repeat, mustache_dict=None): """Run the commands (in background). - stats_name: plugin_name (+ header) - criticity: criticity of the trigger - commands: a list of command line with optional {{mustache}} - If True, then repeat the act...
[ "def", "run", "(", "self", ",", "stat_name", ",", "criticity", ",", "commands", ",", "repeat", ",", "mustache_dict", "=", "None", ")", ":", "if", "(", "self", ".", "get", "(", "stat_name", ")", "==", "criticity", "and", "not", "repeat", ")", "or", "n...
Run the commands (in background). - stats_name: plugin_name (+ header) - criticity: criticity of the trigger - commands: a list of command line with optional {{mustache}} - If True, then repeat the action - mustache_dict: Plugin stats (can be use within {{mustache}}) Re...
[ "Run", "the", "commands", "(", "in", "background", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/actions.py#L66-L106
train
nicolargo/glances
glances/globals.py
safe_makedirs
def safe_makedirs(path): """A safe function for creating a directory tree.""" try: os.makedirs(path) except OSError as err: if err.errno == errno.EEXIST: if not os.path.isdir(path): raise else: raise
python
def safe_makedirs(path): """A safe function for creating a directory tree.""" try: os.makedirs(path) except OSError as err: if err.errno == errno.EEXIST: if not os.path.isdir(path): raise else: raise
[ "def", "safe_makedirs", "(", "path", ")", ":", "try", ":", "os", ".", "makedirs", "(", "path", ")", "except", "OSError", "as", "err", ":", "if", "err", ".", "errno", "==", "errno", ".", "EEXIST", ":", "if", "not", "os", ".", "path", ".", "isdir", ...
A safe function for creating a directory tree.
[ "A", "safe", "function", "for", "creating", "a", "directory", "tree", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/globals.py#L44-L53
train
nicolargo/glances
glances/stats_client.py
GlancesStatsClient.set_plugins
def set_plugins(self, input_plugins): """Set the plugin list according to the Glances server.""" header = "glances_" for item in input_plugins: # Import the plugin try: plugin = __import__(header + item) except ImportError: # Se...
python
def set_plugins(self, input_plugins): """Set the plugin list according to the Glances server.""" header = "glances_" for item in input_plugins: # Import the plugin try: plugin = __import__(header + item) except ImportError: # Se...
[ "def", "set_plugins", "(", "self", ",", "input_plugins", ")", ":", "header", "=", "\"glances_\"", "for", "item", "in", "input_plugins", ":", "# Import the plugin", "try", ":", "plugin", "=", "__import__", "(", "header", "+", "item", ")", "except", "ImportError...
Set the plugin list according to the Glances server.
[ "Set", "the", "plugin", "list", "according", "to", "the", "Glances", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_client.py#L43-L61
train
nicolargo/glances
glances/stats_client.py
GlancesStatsClient.update
def update(self, input_stats): """Update all the stats.""" # For Glances client mode for p in input_stats: # Update plugin stats with items sent by the server self._plugins[p].set_stats(input_stats[p]) # Update the views for the updated stats self....
python
def update(self, input_stats): """Update all the stats.""" # For Glances client mode for p in input_stats: # Update plugin stats with items sent by the server self._plugins[p].set_stats(input_stats[p]) # Update the views for the updated stats self....
[ "def", "update", "(", "self", ",", "input_stats", ")", ":", "# For Glances client mode", "for", "p", "in", "input_stats", ":", "# Update plugin stats with items sent by the server", "self", ".", "_plugins", "[", "p", "]", ".", "set_stats", "(", "input_stats", "[", ...
Update all the stats.
[ "Update", "all", "the", "stats", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_client.py#L63-L70
train
nicolargo/glances
glances/plugins/glances_quicklook.py
Plugin.update
def update(self): """Update quicklook stats using the input method.""" # Init new stats stats = self.get_init_value() # Grab quicklook stats: CPU, MEM and SWAP if self.input_method == 'local': # Get the latest CPU percent value stats['cpu'] = cpu_percent....
python
def update(self): """Update quicklook stats using the input method.""" # Init new stats stats = self.get_init_value() # Grab quicklook stats: CPU, MEM and SWAP if self.input_method == 'local': # Get the latest CPU percent value stats['cpu'] = cpu_percent....
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "# Grab quicklook stats: CPU, MEM and SWAP", "if", "self", ".", "input_method", "==", "'local'", ":", "# Get the latest CPU percent value", "stats", "[",...
Update quicklook stats using the input method.
[ "Update", "quicklook", "stats", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_quicklook.py#L71-L103
train
nicolargo/glances
glances/plugins/glances_quicklook.py
Plugin.update_views
def update_views(self): """Update stats views.""" # Call the father's method super(Plugin, self).update_views() # Add specifics informations # Alert only for key in ['cpu', 'mem', 'swap']: if key in self.stats: self.views[key]['decoration'] = ...
python
def update_views(self): """Update stats views.""" # Call the father's method super(Plugin, self).update_views() # Add specifics informations # Alert only for key in ['cpu', 'mem', 'swap']: if key in self.stats: self.views[key]['decoration'] = ...
[ "def", "update_views", "(", "self", ")", ":", "# Call the father's method", "super", "(", "Plugin", ",", "self", ")", ".", "update_views", "(", ")", "# Add specifics informations", "# Alert only", "for", "key", "in", "[", "'cpu'", ",", "'mem'", ",", "'swap'", ...
Update stats views.
[ "Update", "stats", "views", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_quicklook.py#L105-L114
train
nicolargo/glances
glances/plugins/glances_quicklook.py
Plugin.msg_curse
def msg_curse(self, args=None, max_width=10): """Return the list to display in the UI.""" # Init the return message ret = [] # Only process if stats exist... if not self.stats or self.is_disable(): return ret # Define the data: Bar (default behavor) or Spark...
python
def msg_curse(self, args=None, max_width=10): """Return the list to display in the UI.""" # Init the return message ret = [] # Only process if stats exist... if not self.stats or self.is_disable(): return ret # Define the data: Bar (default behavor) or Spark...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "10", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Only process if stats exist...", "if", "not", "self", ".", "stats", "or", "self", ".", "is_disable", "(", ...
Return the list to display in the UI.
[ "Return", "the", "list", "to", "display", "in", "the", "UI", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_quicklook.py#L116-L179
train
nicolargo/glances
glances/plugins/glances_quicklook.py
Plugin._msg_create_line
def _msg_create_line(self, msg, data, key): """Create a new line to the Quickview.""" ret = [] ret.append(self.curse_add_line(msg)) ret.append(self.curse_add_line(data.pre_char, decoration='BOLD')) ret.append(self.curse_add_line(data.get(), self.get_views(key=key, option='decora...
python
def _msg_create_line(self, msg, data, key): """Create a new line to the Quickview.""" ret = [] ret.append(self.curse_add_line(msg)) ret.append(self.curse_add_line(data.pre_char, decoration='BOLD')) ret.append(self.curse_add_line(data.get(), self.get_views(key=key, option='decora...
[ "def", "_msg_create_line", "(", "self", ",", "msg", ",", "data", ",", "key", ")", ":", "ret", "=", "[", "]", "ret", ".", "append", "(", "self", ".", "curse_add_line", "(", "msg", ")", ")", "ret", ".", "append", "(", "self", ".", "curse_add_line", "...
Create a new line to the Quickview.
[ "Create", "a", "new", "line", "to", "the", "Quickview", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_quicklook.py#L181-L191
train
nicolargo/glances
glances/amps/glances_default.py
Amp.update
def update(self, process_list): """Update the AMP""" # Get the systemctl status logger.debug('{}: Update AMP stats using service {}'.format(self.NAME, self.get('service_cmd'))) try: res = self.get('command') except OSError as e: logger.debug('{}: Error whi...
python
def update(self, process_list): """Update the AMP""" # Get the systemctl status logger.debug('{}: Update AMP stats using service {}'.format(self.NAME, self.get('service_cmd'))) try: res = self.get('command') except OSError as e: logger.debug('{}: Error whi...
[ "def", "update", "(", "self", ",", "process_list", ")", ":", "# Get the systemctl status", "logger", ".", "debug", "(", "'{}: Update AMP stats using service {}'", ".", "format", "(", "self", ".", "NAME", ",", "self", ".", "get", "(", "'service_cmd'", ")", ")", ...
Update the AMP
[ "Update", "the", "AMP" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_default.py#L59-L81
train
nicolargo/glances
glances/exports/glances_restful.py
Export.init
def init(self): """Init the connection to the RESTful server.""" if not self.export_enable: return None # Build the RESTful URL where the stats will be posted url = '{}://{}:{}{}'.format(self.protocol, self.host, ...
python
def init(self): """Init the connection to the RESTful server.""" if not self.export_enable: return None # Build the RESTful URL where the stats will be posted url = '{}://{}:{}{}'.format(self.protocol, self.host, ...
[ "def", "init", "(", "self", ")", ":", "if", "not", "self", ".", "export_enable", ":", "return", "None", "# Build the RESTful URL where the stats will be posted", "url", "=", "'{}://{}:{}{}'", ".", "format", "(", "self", ".", "protocol", ",", "self", ".", "host",...
Init the connection to the RESTful server.
[ "Init", "the", "connection", "to", "the", "RESTful", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_restful.py#L57-L68
train
nicolargo/glances
glances/exports/glances_restful.py
Export.export
def export(self, name, columns, points): """Export the stats to the Statsd server.""" if name == self.plugins_to_export()[0] and self.buffer != {}: # One complete loop have been done logger.debug("Export stats ({}) to RESTful endpoint ({})".format(listkeys(self.buffer), ...
python
def export(self, name, columns, points): """Export the stats to the Statsd server.""" if name == self.plugins_to_export()[0] and self.buffer != {}: # One complete loop have been done logger.debug("Export stats ({}) to RESTful endpoint ({})".format(listkeys(self.buffer), ...
[ "def", "export", "(", "self", ",", "name", ",", "columns", ",", "points", ")", ":", "if", "name", "==", "self", ".", "plugins_to_export", "(", ")", "[", "0", "]", "and", "self", ".", "buffer", "!=", "{", "}", ":", "# One complete loop have been done", ...
Export the stats to the Statsd server.
[ "Export", "the", "stats", "to", "the", "Statsd", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_restful.py#L70-L82
train
nicolargo/glances
glances/folder_list.py
FolderList.__set_folder_list
def __set_folder_list(self, section): """Init the monitored folder list. The list is defined in the Glances configuration file. """ for l in range(1, self.__folder_list_max_size + 1): value = {} key = 'folder_' + str(l) + '_' # Path is mandatory ...
python
def __set_folder_list(self, section): """Init the monitored folder list. The list is defined in the Glances configuration file. """ for l in range(1, self.__folder_list_max_size + 1): value = {} key = 'folder_' + str(l) + '_' # Path is mandatory ...
[ "def", "__set_folder_list", "(", "self", ",", "section", ")", ":", "for", "l", "in", "range", "(", "1", ",", "self", ".", "__folder_list_max_size", "+", "1", ")", ":", "value", "=", "{", "}", "key", "=", "'folder_'", "+", "str", "(", "l", ")", "+",...
Init the monitored folder list. The list is defined in the Glances configuration file.
[ "Init", "the", "monitored", "folder", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/folder_list.py#L75-L105
train
nicolargo/glances
glances/folder_list.py
FolderList.__folder_size
def __folder_size(self, path): """Return the size of the directory given by path path: <string>""" ret = 0 for f in scandir(path): if f.is_dir() and (f.name != '.' or f.name != '..'): ret += self.__folder_size(os.path.join(path, f.name)) else: ...
python
def __folder_size(self, path): """Return the size of the directory given by path path: <string>""" ret = 0 for f in scandir(path): if f.is_dir() and (f.name != '.' or f.name != '..'): ret += self.__folder_size(os.path.join(path, f.name)) else: ...
[ "def", "__folder_size", "(", "self", ",", "path", ")", ":", "ret", "=", "0", "for", "f", "in", "scandir", "(", "path", ")", ":", "if", "f", ".", "is_dir", "(", ")", "and", "(", "f", ".", "name", "!=", "'.'", "or", "f", ".", "name", "!=", "'.....
Return the size of the directory given by path path: <string>
[ "Return", "the", "size", "of", "the", "directory", "given", "by", "path" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/folder_list.py#L132-L147
train
nicolargo/glances
glances/folder_list.py
FolderList.update
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 ...
python
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 ...
[ "def", "update", "(", "self", ")", ":", "# 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", "(", "l...
Update the command result attributed.
[ "Update", "the", "command", "result", "attributed", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/folder_list.py#L149-L168
train
nicolargo/glances
glances/outputs/glances_bars.py
Bar.get
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_...
python
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_...
[ "def", "get", "(", "self", ")", ":", "frac", ",", "whole", "=", "modf", "(", "self", ".", "size", "*", "self", ".", "percent", "/", "100.0", ")", "ret", "=", "curses_bars", "[", "8", "]", "*", "int", "(", "whole", ")", "if", "frac", ">", "0", ...
Return the bars.
[ "Return", "the", "bars", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bars.py#L85-L95
train
nicolargo/glances
glances/exports/glances_zeromq.py
Export.init
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...
python
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...
[ "def", "init", "(", "self", ")", ":", "if", "not", "self", ".", "export_enable", ":", "return", "None", "server_uri", "=", "'tcp://{}:{}'", ".", "format", "(", "self", ".", "host", ",", "self", ".", "port", ")", "try", ":", "self", ".", "context", "=...
Init the connection to the CouchDB server.
[ "Init", "the", "connection", "to", "the", "CouchDB", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_zeromq.py#L58-L75
train
nicolargo/glances
glances/exports/glances_zeromq.py
Export.exit
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()
python
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()
[ "def", "exit", "(", "self", ")", ":", "if", "self", ".", "client", "is", "not", "None", ":", "self", ".", "client", ".", "close", "(", ")", "if", "self", ".", "context", "is", "not", "None", ":", "self", ".", "context", ".", "destroy", "(", ")" ]
Close the socket and context
[ "Close", "the", "socket", "and", "context" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_zeromq.py#L77-L82
train
nicolargo/glances
glances/exports/glances_zeromq.py
Export.export
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 ...
python
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 ...
[ "def", "export", "(", "self", ",", "name", ",", "columns", ",", "points", ")", ":", "logger", ".", "debug", "(", "\"Export {} stats to ZeroMQ\"", ".", "format", "(", "name", ")", ")", "# Create DB input", "data", "=", "dict", "(", "zip", "(", "columns", ...
Write the points to the ZeroMQ server.
[ "Write", "the", "points", "to", "the", "ZeroMQ", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_zeromq.py#L84-L110
train
nicolargo/glances
glances/exports/glances_cassandra.py
Export.init
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...
python
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...
[ "def", "init", "(", "self", ")", ":", "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", ...
Init the connection to the Cassandra server.
[ "Init", "the", "connection", "to", "the", "Cassandra", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_cassandra.py#L68-L107
train
nicolargo/glances
glances/exports/glances_cassandra.py
Export.export
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...
python
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...
[ "def", "export", "(", "self", ",", "name", ",", "columns", ",", "points", ")", ":", "logger", ".", "debug", "(", "\"Export {} stats to Cassandra\"", ".", "format", "(", "name", ")", ")", "# Remove non number stats and convert all to float (for Boolean)", "data", "="...
Write the points to the Cassandra cluster.
[ "Write", "the", "points", "to", "the", "Cassandra", "cluster", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_cassandra.py#L109-L126
train
nicolargo/glances
glances/exports/glances_cassandra.py
Export.exit
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()
python
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()
[ "def", "exit", "(", "self", ")", ":", "# To ensure all connections are properly closed", "self", ".", "session", ".", "shutdown", "(", ")", "self", ".", "cluster", ".", "shutdown", "(", ")", "# Call the father method", "super", "(", "Export", ",", "self", ")", ...
Close the Cassandra export module.
[ "Close", "the", "Cassandra", "export", "module", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_cassandra.py#L128-L134
train
nicolargo/glances
glances/plugins/glances_system.py
_linux_os_release
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 = ''...
python
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 = ''...
[ "def", "_linux_os_release", "(", ")", ":", "pretty_name", "=", "''", "ashtray", "=", "{", "}", "keys", "=", "[", "'NAME'", ",", "'VERSION_ID'", "]", "try", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "'/etc'", ",", "'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.
[ "Try", "to", "determine", "the", "name", "of", "a", "Linux", "distribution", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_system.py#L51-L76
train
nicolargo/glances
glances/plugins/glances_system.py
Plugin.update
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...
python
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...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "self", ".", "input_method", "==", "'local'", ":", "# Update stats using the standard system lib", "stats", "[", "'os_name'", "]", "=", "plat...
Update the host/system info using the input method. Return the stats (dict)
[ "Update", "the", "host", "/", "system", "info", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_system.py#L95-L162
train
nicolargo/glances
glances/plugins/glances_system.py
Plugin.msg_curse
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": ...
python
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": ...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Build the string message", "if", "args", ".", "client", ":", "# Client mode", "if", "args", ".", "cs_sta...
Return the string to display in the curse interface.
[ "Return", "the", "string", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_system.py#L164-L201
train
nicolargo/glances
glances/plugins/glances_memswap.py
Plugin.update
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...
python
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...
[ "def", "update", "(", "self", ")", ":", "# 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", ...
Update swap memory stats using the input method.
[ "Update", "swap", "memory", "stats", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_memswap.py#L60-L128
train
nicolargo/glances
glances/plugins/glances_memswap.py
Plugin.update_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'])
python
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'])
[ "def", "update_views", "(", "self", ")", ":", "# Call the father's method", "super", "(", "Plugin", ",", "self", ")", ".", "update_views", "(", ")", "# Add specifics informations", "# Alert and log", "self", ".", "views", "[", "'used'", "]", "[", "'decoration'", ...
Update stats views.
[ "Update", "stats", "views", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_memswap.py#L130-L137
train
nicolargo/glances
glances/plugins/glances_memswap.py
Plugin.msg_curse
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...
python
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...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Only process if stats exist and plugin not disabled", "if", "not", "self", ".", "stats", "or", "self", ".", ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_memswap.py#L139-L180
train
nicolargo/glances
glances/plugins/glances_amps.py
Plugin.update
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, ...
python
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, ...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "self", ".", "input_method", "==", "'local'", ":", "for", "k", ",", "v", "in", "iteritems", "(", "self", ".", "glances_amps", ".", ...
Update the AMP list.
[ "Update", "the", "AMP", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_amps.py#L45-L67
train
nicolargo/glances
glances/plugins/glances_amps.py
Plugin.get_alert
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...
python
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...
[ "def", "get_alert", "(", "self", ",", "nbprocess", "=", "0", ",", "countmin", "=", "None", ",", "countmax", "=", "None", ",", "header", "=", "\"\"", ",", "log", "=", "False", ")", ":", "if", "nbprocess", "is", "None", ":", "return", "'OK'", "if", "...
Return the alert status relative to the process number.
[ "Return", "the", "alert", "status", "relative", "to", "the", "process", "number", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_amps.py#L69-L86
train
nicolargo/glances
glances/plugins/glances_amps.py
Plugin.msg_curse
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...
python
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...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "# Only process if stats exist and display plugin enable...", "ret", "=", "[", "]", "if", "not", "self", ".", "stats", "or", "args", ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_amps.py#L88-L125
train
nicolargo/glances
glances/plugins/glances_percpu.py
Plugin.update
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...
python
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...
[ "def", "update", "(", "self", ")", ":", "# 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", "==", "'loca...
Update per-CPU stats using the input method.
[ "Update", "per", "-", "CPU", "stats", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_percpu.py#L57-L73
train
nicolargo/glances
glances/plugins/glances_percpu.py
Plugin.msg_curse
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...
python
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...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Only process if stats exist...", "if", "not", "self", ".", "stats", "or", "not", "self", ".", "args", ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_percpu.py#L75-L117
train
nicolargo/glances
glances/plugins/glances_ports.py
Plugin.exit
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()
python
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()
[ "def", "exit", "(", "self", ")", ":", "if", "self", ".", "_thread", "is", "not", "None", ":", "self", ".", "_thread", ".", "stop", "(", ")", "# Call the father class", "super", "(", "Plugin", ",", "self", ")", ".", "exit", "(", ")" ]
Overwrite the exit method to close threads.
[ "Overwrite", "the", "exit", "method", "to", "close", "threads", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L67-L72
train
nicolargo/glances
glances/plugins/glances_ports.py
Plugin.update
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...
python
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...
[ "def", "update", "(", "self", ")", ":", "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", ":"...
Update the ports list.
[ "Update", "the", "ports", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L75-L98
train
nicolargo/glances
glances/plugins/glances_ports.py
Plugin.get_ports_alert
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'], (...
python
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'], (...
[ "def", "get_ports_alert", "(", "self", ",", "port", ",", "header", "=", "\"\"", ",", "log", "=", "False", ")", ":", "ret", "=", "'OK'", "if", "port", "[", "'status'", "]", "is", "None", ":", "ret", "=", "'CAREFUL'", "elif", "port", "[", "'status'", ...
Return the alert status relative to the port scan return value.
[ "Return", "the", "alert", "status", "relative", "to", "the", "port", "scan", "return", "value", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L104-L128
train
nicolargo/glances
glances/plugins/glances_ports.py
Plugin.get_web_alert
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...
python
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...
[ "def", "get_web_alert", "(", "self", ",", "web", ",", "header", "=", "\"\"", ",", "log", "=", "False", ")", ":", "ret", "=", "'OK'", "if", "web", "[", "'status'", "]", "is", "None", ":", "ret", "=", "'CAREFUL'", "elif", "web", "[", "'status'", "]",...
Return the alert status relative to the web/url scan return value.
[ "Return", "the", "alert", "status", "relative", "to", "the", "web", "/", "url", "scan", "return", "value", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L130-L152
train
nicolargo/glances
glances/plugins/glances_ports.py
Plugin.msg_curse
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...
python
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...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "# Only process if stats exist and display plugin enable...", "ret", "=", "[", "]", "if", "not", "self", ".", "stats", "or", "args", ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L154-L211
train
nicolargo/glances
glances/plugins/glances_ports.py
ThreadScanner.run
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...
python
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...
[ "def", "run", "(", "self", ")", ":", "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", "p", ":", "self", ".", "_por...
Grab the stats. Infinite loop, should be stopped by calling the stop() method.
[ "Grab", "the", "stats", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L232-L249
train
nicolargo/glances
glances/plugins/glances_ports.py
ThreadScanner.stop
def stop(self, timeout=None): """Stop the thread.""" logger.debug("ports plugin - Close thread for scan list {}".format(self._stats)) self._stopper.set()
python
def stop(self, timeout=None): """Stop the thread.""" logger.debug("ports plugin - Close thread for scan list {}".format(self._stats)) self._stopper.set()
[ "def", "stop", "(", "self", ",", "timeout", "=", "None", ")", ":", "logger", ".", "debug", "(", "\"ports plugin - Close thread for scan list {}\"", ".", "format", "(", "self", ".", "_stats", ")", ")", "self", ".", "_stopper", ".", "set", "(", ")" ]
Stop the thread.
[ "Stop", "the", "thread", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L261-L264
train
nicolargo/glances
glances/plugins/glances_ports.py
ThreadScanner._web_scan
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'], ...
python
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'], ...
[ "def", "_web_scan", "(", "self", ",", "web", ")", ":", "try", ":", "req", "=", "requests", ".", "head", "(", "web", "[", "'url'", "]", ",", "allow_redirects", "=", "True", ",", "verify", "=", "web", "[", "'ssl_verify'", "]", ",", "proxies", "=", "w...
Scan the Web/URL (dict) and update the status key.
[ "Scan", "the", "Web", "/", "URL", "(", "dict", ")", "and", "update", "the", "status", "key", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L270-L285
train
nicolargo/glances
glances/plugins/glances_ports.py
ThreadScanner._port_scan
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)
python
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)
[ "def", "_port_scan", "(", "self", ",", "port", ")", ":", "if", "int", "(", "port", "[", "'port'", "]", ")", "==", "0", ":", "return", "self", ".", "_port_scan_icmp", "(", "port", ")", "else", ":", "return", "self", ".", "_port_scan_tcp", "(", "port",...
Scan the port structure (dict) and update the status key.
[ "Scan", "the", "port", "structure", "(", "dict", ")", "and", "update", "the", "status", "key", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L287-L292
train
nicolargo/glances
glances/plugins/glances_ports.py
ThreadScanner._resolv_name
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
python
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
[ "def", "_resolv_name", "(", "self", ",", "hostname", ")", ":", "ip", "=", "hostname", "try", ":", "ip", "=", "socket", ".", "gethostbyname", "(", "hostname", ")", "except", "Exception", "as", "e", ":", "logger", ".", "debug", "(", "\"{}: Cannot convert {} ...
Convert hostname to IP address.
[ "Convert", "hostname", "to", "IP", "address", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L294-L301
train
nicolargo/glances
glances/plugins/glances_ports.py
ThreadScanner._port_scan_icmp
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 ...
python
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 ...
[ "def", "_port_scan_icmp", "(", "self", ",", "port", ")", ":", "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", "if", "WINDOWS", ":", "timeout_opt"...
Scan the (ICMP) port structure (dict) and update the status key.
[ "Scan", "the", "(", "ICMP", ")", "port", "structure", "(", "dict", ")", "and", "update", "the", "status", "key", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L303-L341
train
nicolargo/glances
glances/plugins/glances_ports.py
ThreadScanner._port_scan_tcp
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) ...
python
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) ...
[ "def", "_port_scan_tcp", "(", "self", ",", "port", ")", ":", "ret", "=", "None", "# Create and configure the scanning socket", "try", ":", "socket", ".", "setdefaulttimeout", "(", "port", "[", "'timeout'", "]", ")", "_socket", "=", "socket", ".", "socket", "("...
Scan the (TCP) port structure (dict) and update the status key.
[ "Scan", "the", "(", "TCP", ")", "port", "structure", "(", "dict", ")", "and", "update", "the", "status", "key", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L343-L369
train
nicolargo/glances
glances/stats.py
GlancesStats.load_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 ...
python
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 ...
[ "def", "load_modules", "(", "self", ",", "args", ")", ":", "# Init the plugins dict", "# Active plugins dictionnary", "self", ".", "_plugins", "=", "collections", ".", "defaultdict", "(", "dict", ")", "# Load the plugins", "self", ".", "load_plugins", "(", "args", ...
Wrapper to load: plugins and export modules.
[ "Wrapper", "to", "load", ":", "plugins", "and", "export", "modules", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L86-L104
train
nicolargo/glances
glances/stats.py
GlancesStats._load_plugin
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)...
python
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)...
[ "def", "_load_plugin", "(", "self", ",", "plugin_script", ",", "args", "=", "None", ",", "config", "=", "None", ")", ":", "# The key is the plugin name", "# for example, the file glances_xxx.py", "# generate self._plugins_list[\"xxx\"] = ...", "name", "=", "plugin_script", ...
Load the plugin (script), init it and add to the _plugin dict.
[ "Load", "the", "plugin", "(", "script", ")", "init", "it", "and", "add", "to", "the", "_plugin", "dict", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L106-L129
train
nicolargo/glances
glances/stats.py
GlancesStats.load_plugins
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...
python
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...
[ "def", "load_plugins", "(", "self", ",", "args", "=", "None", ")", ":", "for", "item", "in", "os", ".", "listdir", "(", "plugins_path", ")", ":", "if", "(", "item", ".", "startswith", "(", "self", ".", "header", ")", "and", "item", ".", "endswith", ...
Load all plugins in the 'plugins' folder.
[ "Load", "all", "plugins", "in", "the", "plugins", "folder", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L131-L142
train
nicolargo/glances
glances/stats.py
GlancesStats.load_exports
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): ...
python
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): ...
[ "def", "load_exports", "(", "self", ",", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "return", "False", "header", "=", "\"glances_\"", "# Build the export module available list", "args_var", "=", "vars", "(", "locals", "(", ")", "[", "'ar...
Load all export modules in the 'exports' folder.
[ "Load", "all", "export", "modules", "in", "the", "exports", "folder", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L144-L178
train
nicolargo/glances
glances/stats.py
GlancesStats.getPluginsList
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...
python
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...
[ "def", "getPluginsList", "(", "self", ",", "enable", "=", "True", ")", ":", "if", "enable", ":", "return", "[", "p", "for", "p", "in", "self", ".", "_plugins", "if", "self", ".", "_plugins", "[", "p", "]", ".", "is_enable", "(", ")", "]", "else", ...
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
[ "Return", "the", "plugins", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L180-L191
train
nicolargo/glances
glances/stats.py
GlancesStats.getExportsList
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] ...
python
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] ...
[ "def", "getExportsList", "(", "self", ",", "enable", "=", "True", ")", ":", "if", "enable", ":", "return", "[", "e", "for", "e", "in", "self", ".", "_exports", "]", "else", ":", "return", "[", "e", "for", "e", "in", "self", ".", "_exports_all", "]"...
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
[ "Return", "the", "exports", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L193-L204
train
nicolargo/glances
glances/stats.py
GlancesStats.load_limits
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)
python
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)
[ "def", "load_limits", "(", "self", ",", "config", "=", "None", ")", ":", "# For each plugins, call the load_limits method", "for", "p", "in", "self", ".", "_plugins", ":", "self", ".", "_plugins", "[", "p", "]", ".", "load_limits", "(", "config", ")" ]
Load the stats limits (except the one in the exclude list).
[ "Load", "the", "stats", "limits", "(", "except", "the", "one", "in", "the", "exclude", "list", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L206-L210
train
nicolargo/glances
glances/stats.py
GlancesStats.update
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...
python
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...
[ "def", "update", "(", "self", ")", ":", "# For standalone and server modes", "# For each plugins, call the update method", "for", "p", "in", "self", ".", "_plugins", ":", "if", "self", ".", "_plugins", "[", "p", "]", ".", "is_disable", "(", ")", ":", "# If curre...
Wrapper method to update the stats.
[ "Wrapper", "method", "to", "update", "the", "stats", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L212-L226
train
nicolargo/glances
glances/stats.py
GlancesStats.export
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 =...
python
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 =...
[ "def", "export", "(", "self", ",", "input_stats", "=", "None", ")", ":", "# threads = []", "input_stats", "=", "input_stats", "or", "{", "}", "for", "e", "in", "self", ".", "_exports", ":", "logger", ".", "debug", "(", "\"Export stats using the %s module\"", ...
Export all the stats. Each export module is ran in a dedicated thread.
[ "Export", "all", "the", "stats", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L228-L241
train
nicolargo/glances
glances/stats.py
GlancesStats.getAllAsDict
def getAllAsDict(self): """Return all the stats (dict).""" return {p: self._plugins[p].get_raw() for p in self._plugins}
python
def getAllAsDict(self): """Return all the stats (dict).""" return {p: self._plugins[p].get_raw() for p in self._plugins}
[ "def", "getAllAsDict", "(", "self", ")", ":", "return", "{", "p", ":", "self", ".", "_plugins", "[", "p", "]", ".", "get_raw", "(", ")", "for", "p", "in", "self", ".", "_plugins", "}" ]
Return all the stats (dict).
[ "Return", "all", "the", "stats", "(", "dict", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L247-L249
train
nicolargo/glances
glances/stats.py
GlancesStats.getAllExports
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...
python
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...
[ "def", "getAllExports", "(", "self", ",", "plugin_list", "=", "None", ")", ":", "if", "plugin_list", "is", "None", ":", "# All plugins should be exported", "plugin_list", "=", "self", ".", "_plugins", "return", "[", "self", ".", "_plugins", "[", "p", "]", "....
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)
[ "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", ")" ...
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L251-L260
train
nicolargo/glances
glances/stats.py
GlancesStats.getAllExportsAsDict
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 ...
python
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 ...
[ "def", "getAllExportsAsDict", "(", "self", ",", "plugin_list", "=", "None", ")", ":", "if", "plugin_list", "is", "None", ":", "# All plugins should be exported", "plugin_list", "=", "self", ".", "_plugins", "return", "{", "p", ":", "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)
[ "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", ")" ...
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L262-L271
train
nicolargo/glances
glances/stats.py
GlancesStats.getAllLimitsAsDict
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...
python
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...
[ "def", "getAllLimitsAsDict", "(", "self", ",", "plugin_list", "=", "None", ")", ":", "if", "plugin_list", "is", "None", ":", "# All plugins should be exported", "plugin_list", "=", "self", ".", "_plugins", "return", "{", "p", ":", "self", ".", "_plugins", "[",...
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)
[ "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", ")" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L277-L286
train
nicolargo/glances
glances/stats.py
GlancesStats.getAllViewsAsDict
def getAllViewsAsDict(self): """Return all the stats views (dict).""" return {p: self._plugins[p].get_views() for p in self._plugins}
python
def getAllViewsAsDict(self): """Return all the stats views (dict).""" return {p: self._plugins[p].get_views() for p in self._plugins}
[ "def", "getAllViewsAsDict", "(", "self", ")", ":", "return", "{", "p", ":", "self", ".", "_plugins", "[", "p", "]", ".", "get_views", "(", ")", "for", "p", "in", "self", ".", "_plugins", "}" ]
Return all the stats views (dict).
[ "Return", "all", "the", "stats", "views", "(", "dict", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L292-L294
train
nicolargo/glances
glances/stats.py
GlancesStats.end
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()
python
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()
[ "def", "end", "(", "self", ")", ":", "# Close export modules", "for", "e", "in", "self", ".", "_exports", ":", "self", ".", "_exports", "[", "e", "]", ".", "exit", "(", ")", "# Close plugins", "for", "p", "in", "self", ".", "_plugins", ":", "self", "...
End of the Glances stats.
[ "End", "of", "the", "Glances", "stats", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L307-L314
train
nicolargo/glances
glances/plugins/glances_network.py
Plugin.update
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 #...
python
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 #...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "self", ".", "input_method", "==", "'local'", ":", "# Update stats using the standard system lib", "# Grab network interface stat using the psutil net_...
Update network stats using the input method. Stats is a list of dict (one dict per interface)
[ "Update", "network", "stats", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_network.py#L69-L217
train
nicolargo/glances
glances/plugins/glances_network.py
Plugin.update_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 ...
python
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 ...
[ "def", "update_views", "(", "self", ")", ":", "# Call the father's method", "super", "(", "Plugin", ",", "self", ")", ".", "update_views", "(", ")", "# Add specifics informations", "# Alert", "for", "i", "in", "self", ".", "stats", ":", "ifrealname", "=", "i",...
Update stats views.
[ "Update", "stats", "views", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_network.py#L219-L246
train
nicolargo/glances
glances/plugins/glances_network.py
Plugin.msg_curse
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...
python
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...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Only process if stats exist and display plugin enable...", "if", "not", "self", ".", "stats", "or", "self", ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_network.py#L248-L336
train
nicolargo/glances
glances/exports/glances_elasticsearch.py
Export.init
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...
python
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...
[ "def", "init", "(", "self", ")", ":", "if", "not", "self", ".", "export_enable", ":", "return", "None", "self", ".", "index", "=", "'{}-{}'", ".", "format", "(", "self", ".", "index", ",", "datetime", ".", "utcnow", "(", ")", ".", "strftime", "(", ...
Init the connection to the ES server.
[ "Init", "the", "connection", "to", "the", "ES", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_elasticsearch.py#L55-L109
train
nicolargo/glances
glances/exports/glances_elasticsearch.py
Export.export
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...
python
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...
[ "def", "export", "(", "self", ",", "name", ",", "columns", ",", "points", ")", ":", "logger", ".", "debug", "(", "\"Export {} stats to ElasticSearch\"", ".", "format", "(", "name", ")", ")", "# Create DB input", "# https://elasticsearch-py.readthedocs.io/en/master/hel...
Write the points to the ES server.
[ "Write", "the", "points", "to", "the", "ES", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_elasticsearch.py#L111-L138
train
nicolargo/glances
glances/plugins/glances_ip.py
Plugin.update
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...
python
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...
[ "def", "update", "(", "self", ")", ":", "# 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", ":", "d...
Update IP stats using the input method. Stats is dict
[ "Update", "IP", "stats", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L69-L99
train
nicolargo/glances
glances/plugins/glances_ip.py
Plugin.update_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
python
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
[ "def", "update_views", "(", "self", ")", ":", "# Call the father's method", "super", "(", "Plugin", ",", "self", ")", ".", "update_views", "(", ")", "# Add specifics informations", "# Optional", "for", "key", "in", "iterkeys", "(", "self", ".", "stats", ")", "...
Update stats views.
[ "Update", "stats", "views", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L101-L109
train
nicolargo/glances
glances/plugins/glances_ip.py
Plugin.msg_curse
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 ...
python
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 ...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Only process if stats exist and display plugin enable...", "if", "not", "self", ".", "stats", "or", "self", ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L111-L143
train
nicolargo/glances
glances/plugins/glances_ip.py
PublicIpAddress.get
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...
python
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...
[ "def", "get", "(", "self", ")", ":", "q", "=", "queue", ".", "Queue", "(", ")", "for", "u", ",", "j", ",", "k", "in", "urls", ":", "t", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_get_ip_public", ",", "args", "=", "(", ...
Get the first public IP address returned by one of the online services.
[ "Get", "the", "first", "public", "IP", "address", "returned", "by", "one", "of", "the", "online", "services", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L161-L176
train
nicolargo/glances
glances/plugins/glances_ip.py
PublicIpAddress._get_ip_public
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 ...
python
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 ...
[ "def", "_get_ip_public", "(", "self", ",", "queue_target", ",", "url", ",", "json", "=", "False", ",", "key", "=", "None", ")", ":", "try", ":", "response", "=", "urlopen", "(", "url", ",", "timeout", "=", "self", ".", "timeout", ")", ".", "read", ...
Request the url service and put the result in the queue_target.
[ "Request", "the", "url", "service", "and", "put", "the", "result", "in", "the", "queue_target", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L178-L193
train
nicolargo/glances
glances/amps/glances_nginx.py
Amp.update
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 ...
python
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 ...
[ "def", "update", "(", "self", ",", "process_list", ")", ":", "# Get the Nginx status", "logger", ".", "debug", "(", "'{}: Update stats using status URL {}'", ".", "format", "(", "self", ".", "NAME", ",", "self", ".", "get", "(", "'status_url'", ")", ")", ")", ...
Update the AMP
[ "Update", "the", "AMP" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_nginx.py#L76-L87
train
nicolargo/glances
glances/exports/glances_kafka.py
Export.init
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, ...
python
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, ...
[ "def", "init", "(", "self", ")", ":", "if", "not", "self", ".", "export_enable", ":", "return", "None", "# Build the server URI with host and port", "server_uri", "=", "'{}:{}'", ".", "format", "(", "self", ".", "host", ",", "self", ".", "port", ")", "try", ...
Init the connection to the Kafka server.
[ "Init", "the", "connection", "to", "the", "Kafka", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_kafka.py#L56-L74
train
nicolargo/glances
glances/exports/glances_kafka.py
Export.export
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 ...
python
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 ...
[ "def", "export", "(", "self", ",", "name", ",", "columns", ",", "points", ")", ":", "logger", ".", "debug", "(", "\"Export {} stats to Kafka\"", ".", "format", "(", "name", ")", ")", "# Create DB input", "data", "=", "dict", "(", "zip", "(", "columns", "...
Write the points to the kafka server.
[ "Write", "the", "points", "to", "the", "kafka", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_kafka.py#L76-L91
train
nicolargo/glances
glances/exports/glances_kafka.py
Export.exit
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()
python
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()
[ "def", "exit", "(", "self", ")", ":", "# To ensure all connections are properly closed", "self", ".", "client", ".", "flush", "(", ")", "self", ".", "client", ".", "close", "(", ")", "# Call the father method", "super", "(", "Export", ",", "self", ")", ".", ...
Close the Kafka export module.
[ "Close", "the", "Kafka", "export", "module", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_kafka.py#L93-L99
train
nicolargo/glances
glances/processes.py
_sort_io_counters
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]
python
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]
[ "def", "_sort_io_counters", "(", "process", ",", "sortedby", "=", "'io_counters'", ",", "sortedby_secondary", "=", "'memory_percent'", ")", ":", "return", "process", "[", "sortedby", "]", "[", "0", "]", "-", "process", "[", "sortedby", "]", "[", "2", "]", ...
Specific case for io_counters Sum of io_r + io_w
[ "Specific", "case", "for", "io_counters", "Sum", "of", "io_r", "+", "io_w" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L381-L386
train
nicolargo/glances
glances/processes.py
_sort_lambda
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
python
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
[ "def", "_sort_lambda", "(", "sortedby", "=", "'cpu_percent'", ",", "sortedby_secondary", "=", "'memory_percent'", ")", ":", "ret", "=", "None", "if", "sortedby", "==", "'io_counters'", ":", "ret", "=", "_sort_io_counters", "elif", "sortedby", "==", "'cpu_times'", ...
Return a sort lambda function for the sortedbykey
[ "Return", "a", "sort", "lambda", "function", "for", "the", "sortedbykey" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L400-L408
train
nicolargo/glances
glances/processes.py
sort_stats
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 ...
python
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 ...
[ "def", "sort_stats", "(", "stats", ",", "sortedby", "=", "'cpu_percent'", ",", "sortedby_secondary", "=", "'memory_percent'", ",", "reverse", "=", "True", ")", ":", "if", "sortedby", "is", "None", "and", "sortedby_secondary", "is", "None", ":", "# No need to sor...
Return the stats (dict) sorted by (sortedby). Reverse the sort if reverse is True.
[ "Return", "the", "stats", "(", "dict", ")", "sorted", "by", "(", "sortedby", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L411-L447
train
nicolargo/glances
glances/processes.py
GlancesProcesses.update_processcount
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...
python
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...
[ "def", "update_processcount", "(", "self", ",", "plist", ")", ":", "# 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...
Update the global process count from the current processes list
[ "Update", "the", "global", "process", "count", "from", "the", "current", "processes", "list" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L89-L102
train
nicolargo/glances
glances/processes.py
GlancesProcesses.pid_max
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 ...
python
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 ...
[ "def", "pid_max", "(", "self", ")", ":", "if", "LINUX", ":", "# XXX: waiting for https://github.com/giampaolo/psutil/issues/720", "try", ":", "with", "open", "(", "'/proc/sys/kernel/pid_max'", ",", "'rb'", ")", "as", "f", ":", "return", "int", "(", "f", ".", "re...
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 maximum value for pid_max. On 6...
[ "Get", "the", "maximum", "PID", "value", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L123-L153
train
nicolargo/glances
glances/processes.py
GlancesProcesses.reset_max_values
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
python
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
[ "def", "reset_max_values", "(", "self", ")", ":", "self", ".", "_max_values", "=", "{", "}", "for", "k", "in", "self", ".", "_max_values_list", ":", "self", ".", "_max_values", "[", "k", "]", "=", "0.0" ]
Reset the maximum values dict.
[ "Reset", "the", "maximum", "values", "dict", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L214-L218
train
nicolargo/glances
glances/processes.py
GlancesProcesses.update
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...
python
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...
[ "def", "update", "(", "self", ")", ":", "# 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 ...
Update the processes stats.
[ "Update", "the", "processes", "stats", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L220-L355
train
nicolargo/glances
glances/amps/glances_systemv.py
Amp.update
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 ...
python
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 ...
[ "def", "update", "(", "self", ",", "process_list", ")", ":", "# Get the systemctl status", "logger", ".", "debug", "(", "'{}: Update stats using service {}'", ".", "format", "(", "self", ".", "NAME", ",", "self", ".", "get", "(", "'service_cmd'", ")", ")", ")"...
Update the AMP
[ "Update", "the", "AMP" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_systemv.py#L67-L95
train
nicolargo/glances
glances/plugins/glances_processlist.py
seconds_to_hms
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
python
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
[ "def", "seconds_to_hms", "(", "input_seconds", ")", ":", "minutes", ",", "seconds", "=", "divmod", "(", "input_seconds", ",", "60", ")", "hours", ",", "minutes", "=", "divmod", "(", "minutes", ",", "60", ")", "hours", "=", "int", "(", "hours", ")", "mi...
Convert seconds to human-readable time.
[ "Convert", "seconds", "to", "human", "-", "readable", "time", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L34-L43
train
nicolargo/glances
glances/plugins/glances_processlist.py
split_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
python
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
[ "def", "split_cmdline", "(", "cmdline", ")", ":", "path", ",", "cmd", "=", "os", ".", "path", ".", "split", "(", "cmdline", "[", "0", "]", ")", "arguments", "=", "' '", ".", "join", "(", "cmdline", "[", "1", ":", "]", ")", "return", "path", ",", ...
Return path, cmd and arguments for a process cmdline.
[ "Return", "path", "cmd", "and", "arguments", "for", "a", "process", "cmdline", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L46-L50
train
nicolargo/glances
glances/plugins/glances_processlist.py
Plugin.update
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...
python
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...
[ "def", "update", "(", "self", ")", ":", "# 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",...
Update processes stats using the input method.
[ "Update", "processes", "stats", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L124-L146
train
nicolargo/glances
glances/plugins/glances_processlist.py
Plugin.get_nice_alert
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...
python
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...
[ "def", "get_nice_alert", "(", "self", ",", "value", ")", ":", "value", "=", "str", "(", "value", ")", "try", ":", "if", "value", "in", "self", ".", "get_limit", "(", "'nice_critical'", ")", ":", "return", "'CRITICAL'", "except", "KeyError", ":", "pass", ...
Return the alert relative to the Nice configuration list
[ "Return", "the", "alert", "relative", "to", "the", "Nice", "configuration", "list" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L148-L166
train
nicolargo/glances
glances/plugins/glances_processlist.py
Plugin.get_process_curses_data
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...
python
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...
[ "def", "get_process_curses_data", "(", "self", ",", "p", ",", "first", ",", "args", ")", ":", "ret", "=", "[", "self", ".", "curse_new_line", "(", ")", "]", "# CPU", "if", "'cpu_percent'", "in", "p", "and", "p", "[", "'cpu_percent'", "]", "is", "not", ...
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
[ "Get", "curses", "data", "to", "display", "for", "a", "process", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L168-L406
train
nicolargo/glances
glances/plugins/glances_processlist.py
Plugin.msg_curse
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...
python
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...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Only process if stats exist and display plugin enable...", "if", "not", "self", ".", "stats", "or", "args", ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L408-L439
train
nicolargo/glances
glances/plugins/glances_processlist.py
Plugin.__msg_curse_header
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...
python
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...
[ "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", "=", ...
Build the header and add it to the ret dict.
[ "Build", "the", "header", "and", "add", "it", "to", "the", "ret", "dict", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L441-L475
train
nicolargo/glances
glances/plugins/glances_processlist.py
Plugin.__msg_curse_sum
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...
python
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...
[ "def", "__msg_curse_sum", "(", "self", ",", "ret", ",", "sep_char", "=", "'_'", ",", "mmm", "=", "None", ",", "args", "=", "None", ")", ":", "ret", ".", "append", "(", "self", ".", "curse_new_line", "(", ")", ")", "if", "mmm", "is", "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 (if mmm=None) * args: Glances args
[ "Build", "the", "sum", "message", "(", "only", "when", "filter", "is", "on", ")", "and", "add", "it", "to", "the", "ret", "dict", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L477-L565
train