partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | FolderList.update | Update the command result attributed. | glances/folder_list.py | 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):
"""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
... | [
"Update",
"the",
"command",
"result",
"attributed",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/folder_list.py#L149-L168 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Bar.get | Return the bars. | glances/outputs/glances_bars.py | 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):
"""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_... | [
"Return",
"the",
"bars",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bars.py#L85-L95 | [
"def",
"get",
"(",
"self",
")",
":",
"frac",
",",
"whole",
"=",
"modf",
"(",
"self",
".",
"size",
"*",
"self",
".",
"percent",
"/",
"100.0",
")",
"ret",
"=",
"curses_bars",
"[",
"8",
"]",
"*",
"int",
"(",
"whole",
")",
"if",
"frac",
">",
"0",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.init | Init the connection to the CouchDB server. | glances/exports/glances_zeromq.py | 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):
"""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... | [
"Init",
"the",
"connection",
"to",
"the",
"CouchDB",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_zeromq.py#L58-L75 | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"server_uri",
"=",
"'tcp://{}:{}'",
".",
"format",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
"try",
":",
"self",
".",
"context",
"=... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.exit | Close the socket and context | glances/exports/glances_zeromq.py | 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):
"""Close the socket and context"""
if self.client is not None:
self.client.close()
if self.context is not None:
self.context.destroy() | [
"Close",
"the",
"socket",
"and",
"context"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_zeromq.py#L77-L82 | [
"def",
"exit",
"(",
"self",
")",
":",
"if",
"self",
".",
"client",
"is",
"not",
"None",
":",
"self",
".",
"client",
".",
"close",
"(",
")",
"if",
"self",
".",
"context",
"is",
"not",
"None",
":",
"self",
".",
"context",
".",
"destroy",
"(",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.export | Write the points to the ZeroMQ server. | glances/exports/glances_zeromq.py | 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):
"""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
... | [
"Write",
"the",
"points",
"to",
"the",
"ZeroMQ",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_zeromq.py#L84-L110 | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"logger",
".",
"debug",
"(",
"\"Export {} stats to ZeroMQ\"",
".",
"format",
"(",
"name",
")",
")",
"# Create DB input",
"data",
"=",
"dict",
"(",
"zip",
"(",
"columns",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.init | Init the connection to the Cassandra server. | glances/exports/glances_cassandra.py | 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):
"""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... | [
"Init",
"the",
"connection",
"to",
"the",
"Cassandra",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_cassandra.py#L68-L107 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.export | Write the points to the Cassandra cluster. | glances/exports/glances_cassandra.py | 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):
"""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... | [
"Write",
"the",
"points",
"to",
"the",
"Cassandra",
"cluster",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_cassandra.py#L109-L126 | [
"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",
"="... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.exit | Close the Cassandra export module. | glances/exports/glances_cassandra.py | 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):
"""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() | [
"Close",
"the",
"Cassandra",
"export",
"module",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_cassandra.py#L128-L134 | [
"def",
"exit",
"(",
"self",
")",
":",
"# To ensure all connections are properly closed",
"self",
".",
"session",
".",
"shutdown",
"(",
")",
"self",
".",
"cluster",
".",
"shutdown",
"(",
")",
"# Call the father method",
"super",
"(",
"Export",
",",
"self",
")",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _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. | glances/plugins/glances_system.py | 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():
"""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 = ''... | [
"Try",
"to",
"determine",
"the",
"name",
"of",
"a",
"Linux",
"distribution",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_system.py#L51-L76 | [
"def",
"_linux_os_release",
"(",
")",
":",
"pretty_name",
"=",
"''",
"ashtray",
"=",
"{",
"}",
"keys",
"=",
"[",
"'NAME'",
",",
"'VERSION_ID'",
"]",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'/etc'",
",",
"'os-release'",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update the host/system info using the input method.
Return the stats (dict) | glances/plugins/glances_system.py | 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):
"""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... | [
"Update",
"the",
"host",
"/",
"system",
"info",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_system.py#L95-L162 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the string to display in the curse interface. | glances/plugins/glances_system.py | 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):
"""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":
... | [
"Return",
"the",
"string",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_system.py#L164-L201 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update swap memory stats using the input method. | glances/plugins/glances_memswap.py | 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):
"""Update swap memory stats using the input method."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
# Grab SWAP using the psutil swap_memory method
sm_st... | [
"Update",
"swap",
"memory",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_memswap.py#L60-L128 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update_views | Update stats views. | glances/plugins/glances_memswap.py | 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):
"""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']) | [
"Update",
"stats",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_memswap.py#L130-L137 | [
"def",
"update_views",
"(",
"self",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Alert and log",
"self",
".",
"views",
"[",
"'used'",
"]",
"[",
"'decoration'",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_memswap.py | 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):
"""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... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_memswap.py#L139-L180 | [
"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",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update the AMP list. | glances/plugins/glances_amps.py | 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):
"""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,
... | [
"Update",
"the",
"AMP",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_amps.py#L45-L67 | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"self",
".",
"glances_amps",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_alert | Return the alert status relative to the process number. | glances/plugins/glances_amps.py | 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):
"""Return the alert status relative to the process number."""
if nbprocess is None:
return 'OK'
if countmin is None:
countmin = nbprocess
if countmax is None:
countma... | [
"Return",
"the",
"alert",
"status",
"relative",
"to",
"the",
"process",
"number",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_amps.py#L69-L86 | [
"def",
"get_alert",
"(",
"self",
",",
"nbprocess",
"=",
"0",
",",
"countmin",
"=",
"None",
",",
"countmax",
"=",
"None",
",",
"header",
"=",
"\"\"",
",",
"log",
"=",
"False",
")",
":",
"if",
"nbprocess",
"is",
"None",
":",
"return",
"'OK'",
"if",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_amps.py | 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):
"""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... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_amps.py#L88-L125 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update per-CPU stats using the input method. | glances/plugins/glances_percpu.py | 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):
"""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... | [
"Update",
"per",
"-",
"CPU",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_percpu.py#L57-L73 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_percpu.py | 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):
"""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... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_percpu.py#L75-L117 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.exit | Overwrite the exit method to close threads. | glances/plugins/glances_ports.py | 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):
"""Overwrite the exit method to close threads."""
if self._thread is not None:
self._thread.stop()
# Call the father class
super(Plugin, self).exit() | [
"Overwrite",
"the",
"exit",
"method",
"to",
"close",
"threads",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L67-L72 | [
"def",
"exit",
"(",
"self",
")",
":",
"if",
"self",
".",
"_thread",
"is",
"not",
"None",
":",
"self",
".",
"_thread",
".",
"stop",
"(",
")",
"# Call the father class",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"exit",
"(",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update the ports list. | glances/plugins/glances_ports.py | 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):
"""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... | [
"Update",
"the",
"ports",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L75-L98 | [
"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",
":"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_ports_alert | Return the alert status relative to the port scan return value. | glances/plugins/glances_ports.py | 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):
"""Return the alert status relative to the port scan return value."""
ret = 'OK'
if port['status'] is None:
ret = 'CAREFUL'
elif port['status'] == 0:
ret = 'CRITICAL'
elif (isinstance(port['status'], (... | [
"Return",
"the",
"alert",
"status",
"relative",
"to",
"the",
"port",
"scan",
"return",
"value",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L104-L128 | [
"def",
"get_ports_alert",
"(",
"self",
",",
"port",
",",
"header",
"=",
"\"\"",
",",
"log",
"=",
"False",
")",
":",
"ret",
"=",
"'OK'",
"if",
"port",
"[",
"'status'",
"]",
"is",
"None",
":",
"ret",
"=",
"'CAREFUL'",
"elif",
"port",
"[",
"'status'",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_web_alert | Return the alert status relative to the web/url scan return value. | glances/plugins/glances_ports.py | 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):
"""Return the alert status relative to the web/url scan return value."""
ret = 'OK'
if web['status'] is None:
ret = 'CAREFUL'
elif web['status'] not in [200, 301, 302]:
ret = 'CRITICAL'
elif web['rtt_warn... | [
"Return",
"the",
"alert",
"status",
"relative",
"to",
"the",
"web",
"/",
"url",
"scan",
"return",
"value",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L130-L152 | [
"def",
"get_web_alert",
"(",
"self",
",",
"web",
",",
"header",
"=",
"\"\"",
",",
"log",
"=",
"False",
")",
":",
"ret",
"=",
"'OK'",
"if",
"web",
"[",
"'status'",
"]",
"is",
"None",
":",
"ret",
"=",
"'CAREFUL'",
"elif",
"web",
"[",
"'status'",
"]",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_ports.py | 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):
"""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... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L154-L211 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadScanner.run | Grab the stats.
Infinite loop, should be stopped by calling the stop() method. | glances/plugins/glances_ports.py | 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):
"""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... | [
"Grab",
"the",
"stats",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L232-L249 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadScanner.stop | Stop the thread. | glances/plugins/glances_ports.py | 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):
"""Stop the thread."""
logger.debug("ports plugin - Close thread for scan list {}".format(self._stats))
self._stopper.set() | [
"Stop",
"the",
"thread",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L261-L264 | [
"def",
"stop",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"ports plugin - Close thread for scan list {}\"",
".",
"format",
"(",
"self",
".",
"_stats",
")",
")",
"self",
".",
"_stopper",
".",
"set",
"(",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadScanner._web_scan | Scan the Web/URL (dict) and update the status key. | glances/plugins/glances_ports.py | 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):
"""Scan the Web/URL (dict) and update the status key."""
try:
req = requests.head(web['url'],
allow_redirects=True,
verify=web['ssl_verify'],
proxies=web['proxies'],
... | [
"Scan",
"the",
"Web",
"/",
"URL",
"(",
"dict",
")",
"and",
"update",
"the",
"status",
"key",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L270-L285 | [
"def",
"_web_scan",
"(",
"self",
",",
"web",
")",
":",
"try",
":",
"req",
"=",
"requests",
".",
"head",
"(",
"web",
"[",
"'url'",
"]",
",",
"allow_redirects",
"=",
"True",
",",
"verify",
"=",
"web",
"[",
"'ssl_verify'",
"]",
",",
"proxies",
"=",
"w... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadScanner._port_scan | Scan the port structure (dict) and update the status key. | glances/plugins/glances_ports.py | 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):
"""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) | [
"Scan",
"the",
"port",
"structure",
"(",
"dict",
")",
"and",
"update",
"the",
"status",
"key",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L287-L292 | [
"def",
"_port_scan",
"(",
"self",
",",
"port",
")",
":",
"if",
"int",
"(",
"port",
"[",
"'port'",
"]",
")",
"==",
"0",
":",
"return",
"self",
".",
"_port_scan_icmp",
"(",
"port",
")",
"else",
":",
"return",
"self",
".",
"_port_scan_tcp",
"(",
"port",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadScanner._resolv_name | Convert hostname to IP address. | glances/plugins/glances_ports.py | 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):
"""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 | [
"Convert",
"hostname",
"to",
"IP",
"address",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L294-L301 | [
"def",
"_resolv_name",
"(",
"self",
",",
"hostname",
")",
":",
"ip",
"=",
"hostname",
"try",
":",
"ip",
"=",
"socket",
".",
"gethostbyname",
"(",
"hostname",
")",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",
"debug",
"(",
"\"{}: Cannot convert {} ... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadScanner._port_scan_icmp | Scan the (ICMP) port structure (dict) and update the status key. | glances/plugins/glances_ports.py | 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):
"""Scan the (ICMP) port structure (dict) and update the status key."""
ret = None
# Create the ping command
# Use the system ping command because it already have the steacky bit set
# Python can not create ICMP packet with non root right
... | [
"Scan",
"the",
"(",
"ICMP",
")",
"port",
"structure",
"(",
"dict",
")",
"and",
"update",
"the",
"status",
"key",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L303-L341 | [
"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"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadScanner._port_scan_tcp | Scan the (TCP) port structure (dict) and update the status key. | glances/plugins/glances_ports.py | 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):
"""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)
... | [
"Scan",
"the",
"(",
"TCP",
")",
"port",
"structure",
"(",
"dict",
")",
"and",
"update",
"the",
"status",
"key",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ports.py#L343-L369 | [
"def",
"_port_scan_tcp",
"(",
"self",
",",
"port",
")",
":",
"ret",
"=",
"None",
"# Create and configure the scanning socket",
"try",
":",
"socket",
".",
"setdefaulttimeout",
"(",
"port",
"[",
"'timeout'",
"]",
")",
"_socket",
"=",
"socket",
".",
"socket",
"("... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.load_modules | Wrapper to load: plugins and export modules. | glances/stats.py | 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):
"""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
... | [
"Wrapper",
"to",
"load",
":",
"plugins",
"and",
"export",
"modules",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L86-L104 | [
"def",
"load_modules",
"(",
"self",
",",
"args",
")",
":",
"# Init the plugins dict",
"# Active plugins dictionnary",
"self",
".",
"_plugins",
"=",
"collections",
".",
"defaultdict",
"(",
"dict",
")",
"# Load the plugins",
"self",
".",
"load_plugins",
"(",
"args",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats._load_plugin | Load the plugin (script), init it and add to the _plugin dict. | glances/stats.py | 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):
"""Load the plugin (script), init it and add to the _plugin dict."""
# The key is the plugin name
# for example, the file glances_xxx.py
# generate self._plugins_list["xxx"] = ...
name = plugin_script[len(self.header)... | [
"Load",
"the",
"plugin",
"(",
"script",
")",
"init",
"it",
"and",
"add",
"to",
"the",
"_plugin",
"dict",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L106-L129 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.load_plugins | Load all plugins in the 'plugins' folder. | glances/stats.py | 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):
"""Load all plugins in the 'plugins' folder."""
for item in os.listdir(plugins_path):
if (item.startswith(self.header) and
item.endswith(".py") and
item != (self.header + "plugin.py")):
# Load the plug... | [
"Load",
"all",
"plugins",
"in",
"the",
"plugins",
"folder",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L131-L142 | [
"def",
"load_plugins",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"for",
"item",
"in",
"os",
".",
"listdir",
"(",
"plugins_path",
")",
":",
"if",
"(",
"item",
".",
"startswith",
"(",
"self",
".",
"header",
")",
"and",
"item",
".",
"endswith",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.load_exports | Load all export modules in the 'exports' folder. | glances/stats.py | 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):
"""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):
... | [
"Load",
"all",
"export",
"modules",
"in",
"the",
"exports",
"folder",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L144-L178 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.getPluginsList | 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 | glances/stats.py | 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):
"""Return the plugins list.
if enable is True, only return the active plugins (default)
if enable is False, return all the plugins
Return: list of plugin name
"""
if enable:
return [p for p in self._plugins if self._plu... | [
"Return",
"the",
"plugins",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L180-L191 | [
"def",
"getPluginsList",
"(",
"self",
",",
"enable",
"=",
"True",
")",
":",
"if",
"enable",
":",
"return",
"[",
"p",
"for",
"p",
"in",
"self",
".",
"_plugins",
"if",
"self",
".",
"_plugins",
"[",
"p",
"]",
".",
"is_enable",
"(",
")",
"]",
"else",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.getExportsList | 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 | glances/stats.py | 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):
"""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]
... | [
"Return",
"the",
"exports",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L193-L204 | [
"def",
"getExportsList",
"(",
"self",
",",
"enable",
"=",
"True",
")",
":",
"if",
"enable",
":",
"return",
"[",
"e",
"for",
"e",
"in",
"self",
".",
"_exports",
"]",
"else",
":",
"return",
"[",
"e",
"for",
"e",
"in",
"self",
".",
"_exports_all",
"]"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.load_limits | Load the stats limits (except the one in the exclude list). | glances/stats.py | 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):
"""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) | [
"Load",
"the",
"stats",
"limits",
"(",
"except",
"the",
"one",
"in",
"the",
"exclude",
"list",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L206-L210 | [
"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",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.update | Wrapper method to update the stats. | glances/stats.py | 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):
"""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... | [
"Wrapper",
"method",
"to",
"update",
"the",
"stats",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L212-L226 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.export | Export all the stats.
Each export module is ran in a dedicated thread. | glances/stats.py | 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):
"""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 =... | [
"Export",
"all",
"the",
"stats",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L228-L241 | [
"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\"",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.getAllAsDict | Return all the stats (dict). | glances/stats.py | def getAllAsDict(self):
"""Return all the stats (dict)."""
return {p: self._plugins[p].get_raw() for p in self._plugins} | def getAllAsDict(self):
"""Return all the stats (dict)."""
return {p: self._plugins[p].get_raw() for p in self._plugins} | [
"Return",
"all",
"the",
"stats",
"(",
"dict",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L247-L249 | [
"def",
"getAllAsDict",
"(",
"self",
")",
":",
"return",
"{",
"p",
":",
"self",
".",
"_plugins",
"[",
"p",
"]",
".",
"get_raw",
"(",
")",
"for",
"p",
"in",
"self",
".",
"_plugins",
"}"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.getAllExports | 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) | glances/stats.py | 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):
"""
Return all the stats to be exported (list).
Default behavor is to export all the stat
if plugin_list is provided, only export stats of given plugin (list)
"""
if plugin_list is None:
# All plugins should be export... | [
"Return",
"all",
"the",
"stats",
"to",
"be",
"exported",
"(",
"list",
")",
".",
"Default",
"behavor",
"is",
"to",
"export",
"all",
"the",
"stat",
"if",
"plugin_list",
"is",
"provided",
"only",
"export",
"stats",
"of",
"given",
"plugin",
"(",
"list",
")"
... | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L251-L260 | [
"def",
"getAllExports",
"(",
"self",
",",
"plugin_list",
"=",
"None",
")",
":",
"if",
"plugin_list",
"is",
"None",
":",
"# All plugins should be exported",
"plugin_list",
"=",
"self",
".",
"_plugins",
"return",
"[",
"self",
".",
"_plugins",
"[",
"p",
"]",
".... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.getAllExportsAsDict | 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) | glances/stats.py | 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):
"""
Return all the stats to be exported (list).
Default behavor is to export all the stat
if plugin_list is provided, only export stats of given plugin (list)
"""
if plugin_list is None:
# All plugins should be ... | [
"Return",
"all",
"the",
"stats",
"to",
"be",
"exported",
"(",
"list",
")",
".",
"Default",
"behavor",
"is",
"to",
"export",
"all",
"the",
"stat",
"if",
"plugin_list",
"is",
"provided",
"only",
"export",
"stats",
"of",
"given",
"plugin",
"(",
"list",
")"
... | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L262-L271 | [
"def",
"getAllExportsAsDict",
"(",
"self",
",",
"plugin_list",
"=",
"None",
")",
":",
"if",
"plugin_list",
"is",
"None",
":",
"# All plugins should be exported",
"plugin_list",
"=",
"self",
".",
"_plugins",
"return",
"{",
"p",
":",
"self",
".",
"_plugins",
"["... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.getAllLimitsAsDict | 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) | glances/stats.py | 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):
"""
Return all the stats limits (dict).
Default behavor is to export all the limits
if plugin_list is provided, only export limits of given plugin (list)
"""
if plugin_list is None:
# All plugins should be export... | [
"Return",
"all",
"the",
"stats",
"limits",
"(",
"dict",
")",
".",
"Default",
"behavor",
"is",
"to",
"export",
"all",
"the",
"limits",
"if",
"plugin_list",
"is",
"provided",
"only",
"export",
"limits",
"of",
"given",
"plugin",
"(",
"list",
")"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L277-L286 | [
"def",
"getAllLimitsAsDict",
"(",
"self",
",",
"plugin_list",
"=",
"None",
")",
":",
"if",
"plugin_list",
"is",
"None",
":",
"# All plugins should be exported",
"plugin_list",
"=",
"self",
".",
"_plugins",
"return",
"{",
"p",
":",
"self",
".",
"_plugins",
"[",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.getAllViewsAsDict | Return all the stats views (dict). | glances/stats.py | 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 all the stats views (dict)."""
return {p: self._plugins[p].get_views() for p in self._plugins} | [
"Return",
"all",
"the",
"stats",
"views",
"(",
"dict",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L292-L294 | [
"def",
"getAllViewsAsDict",
"(",
"self",
")",
":",
"return",
"{",
"p",
":",
"self",
".",
"_plugins",
"[",
"p",
"]",
".",
"get_views",
"(",
")",
"for",
"p",
"in",
"self",
".",
"_plugins",
"}"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStats.end | End of the Glances stats. | glances/stats.py | 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):
"""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() | [
"End",
"of",
"the",
"Glances",
"stats",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats.py#L307-L314 | [
"def",
"end",
"(",
"self",
")",
":",
"# Close export modules",
"for",
"e",
"in",
"self",
".",
"_exports",
":",
"self",
".",
"_exports",
"[",
"e",
"]",
".",
"exit",
"(",
")",
"# Close plugins",
"for",
"p",
"in",
"self",
".",
"_plugins",
":",
"self",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update network stats using the input method.
Stats is a list of dict (one dict per interface) | glances/plugins/glances_network.py | 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):
"""Update network stats using the input method.
Stats is a list of dict (one dict per interface)
"""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
#... | [
"Update",
"network",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_network.py#L69-L217 | [
"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_... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update_views | Update stats views. | glances/plugins/glances_network.py | 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):
"""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 ... | [
"Update",
"stats",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_network.py#L219-L246 | [
"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",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_network.py | 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):
"""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... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_network.py#L248-L336 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.init | Init the connection to the ES server. | glances/exports/glances_elasticsearch.py | 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):
"""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... | [
"Init",
"the",
"connection",
"to",
"the",
"ES",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_elasticsearch.py#L55-L109 | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"self",
".",
"index",
"=",
"'{}-{}'",
".",
"format",
"(",
"self",
".",
"index",
",",
"datetime",
".",
"utcnow",
"(",
")",
".",
"strftime",
"(",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.export | Write the points to the ES server. | glances/exports/glances_elasticsearch.py | 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):
"""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... | [
"Write",
"the",
"points",
"to",
"the",
"ES",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_elasticsearch.py#L111-L138 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update IP stats using the input method.
Stats is dict | glances/plugins/glances_ip.py | 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):
"""Update IP stats using the input method.
Stats is dict
"""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local' and not import_error_tag:
# Update stats using the netifaces lib
try:
de... | [
"Update",
"IP",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L69-L99 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update_views | Update stats views. | glances/plugins/glances_ip.py | 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):
"""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 | [
"Update",
"stats",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L101-L109 | [
"def",
"update_views",
"(",
"self",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Optional",
"for",
"key",
"in",
"iterkeys",
"(",
"self",
".",
"stats",
")",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_ip.py | 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):
"""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 ... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L111-L143 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | PublicIpAddress.get | Get the first public IP address returned by one of the online services. | glances/plugins/glances_ip.py | 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):
"""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... | [
"Get",
"the",
"first",
"public",
"IP",
"address",
"returned",
"by",
"one",
"of",
"the",
"online",
"services",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L161-L176 | [
"def",
"get",
"(",
"self",
")",
":",
"q",
"=",
"queue",
".",
"Queue",
"(",
")",
"for",
"u",
",",
"j",
",",
"k",
"in",
"urls",
":",
"t",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"_get_ip_public",
",",
"args",
"=",
"(",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | PublicIpAddress._get_ip_public | Request the url service and put the result in the queue_target. | glances/plugins/glances_ip.py | 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):
"""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 ... | [
"Request",
"the",
"url",
"service",
"and",
"put",
"the",
"result",
"in",
"the",
"queue_target",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_ip.py#L178-L193 | [
"def",
"_get_ip_public",
"(",
"self",
",",
"queue_target",
",",
"url",
",",
"json",
"=",
"False",
",",
"key",
"=",
"None",
")",
":",
"try",
":",
"response",
"=",
"urlopen",
"(",
"url",
",",
"timeout",
"=",
"self",
".",
"timeout",
")",
".",
"read",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Amp.update | Update the AMP | glances/amps/glances_nginx.py | 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):
"""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 ... | [
"Update",
"the",
"AMP"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_nginx.py#L76-L87 | [
"def",
"update",
"(",
"self",
",",
"process_list",
")",
":",
"# Get the Nginx status",
"logger",
".",
"debug",
"(",
"'{}: Update stats using status URL {}'",
".",
"format",
"(",
"self",
".",
"NAME",
",",
"self",
".",
"get",
"(",
"'status_url'",
")",
")",
")",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.init | Init the connection to the Kafka server. | glances/exports/glances_kafka.py | 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):
"""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,
... | [
"Init",
"the",
"connection",
"to",
"the",
"Kafka",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_kafka.py#L56-L74 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.export | Write the points to the kafka server. | glances/exports/glances_kafka.py | 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):
"""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
... | [
"Write",
"the",
"points",
"to",
"the",
"kafka",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_kafka.py#L76-L91 | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"logger",
".",
"debug",
"(",
"\"Export {} stats to Kafka\"",
".",
"format",
"(",
"name",
")",
")",
"# Create DB input",
"data",
"=",
"dict",
"(",
"zip",
"(",
"columns",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.exit | Close the Kafka export module. | glances/exports/glances_kafka.py | 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):
"""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() | [
"Close",
"the",
"Kafka",
"export",
"module",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_kafka.py#L93-L99 | [
"def",
"exit",
"(",
"self",
")",
":",
"# To ensure all connections are properly closed",
"self",
".",
"client",
".",
"flush",
"(",
")",
"self",
".",
"client",
".",
"close",
"(",
")",
"# Call the father method",
"super",
"(",
"Export",
",",
"self",
")",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _sort_io_counters | Specific case for io_counters
Sum of io_r + io_w | glances/processes.py | 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'):
"""Specific case for io_counters
Sum of io_r + io_w"""
return process[sortedby][0] - process[sortedby][2] + process[sortedby][1] - process[sortedby][3] | [
"Specific",
"case",
"for",
"io_counters",
"Sum",
"of",
"io_r",
"+",
"io_w"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L381-L386 | [
"def",
"_sort_io_counters",
"(",
"process",
",",
"sortedby",
"=",
"'io_counters'",
",",
"sortedby_secondary",
"=",
"'memory_percent'",
")",
":",
"return",
"process",
"[",
"sortedby",
"]",
"[",
"0",
"]",
"-",
"process",
"[",
"sortedby",
"]",
"[",
"2",
"]",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _sort_lambda | Return a sort lambda function for the sortedbykey | glances/processes.py | 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'):
"""Return a sort lambda function for the sortedbykey"""
ret = None
if sortedby == 'io_counters':
ret = _sort_io_counters
elif sortedby == 'cpu_times':
ret = _sort_cpu_times
return ret | [
"Return",
"a",
"sort",
"lambda",
"function",
"for",
"the",
"sortedbykey"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L400-L408 | [
"def",
"_sort_lambda",
"(",
"sortedby",
"=",
"'cpu_percent'",
",",
"sortedby_secondary",
"=",
"'memory_percent'",
")",
":",
"ret",
"=",
"None",
"if",
"sortedby",
"==",
"'io_counters'",
":",
"ret",
"=",
"_sort_io_counters",
"elif",
"sortedby",
"==",
"'cpu_times'",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | sort_stats | Return the stats (dict) sorted by (sortedby).
Reverse the sort if reverse is True. | glances/processes.py | 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):
"""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 ... | [
"Return",
"the",
"stats",
"(",
"dict",
")",
"sorted",
"by",
"(",
"sortedby",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L411-L447 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesProcesses.update_processcount | Update the global process count from the current processes list | glances/processes.py | 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 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... | [
"Update",
"the",
"global",
"process",
"count",
"from",
"the",
"current",
"processes",
"list"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L89-L102 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesProcesses.pid_max | 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... | glances/processes.py | 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):
"""
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 ... | [
"Get",
"the",
"maximum",
"PID",
"value",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L123-L153 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesProcesses.reset_max_values | Reset the maximum values dict. | glances/processes.py | 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):
"""Reset the maximum values dict."""
self._max_values = {}
for k in self._max_values_list:
self._max_values[k] = 0.0 | [
"Reset",
"the",
"maximum",
"values",
"dict",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L214-L218 | [
"def",
"reset_max_values",
"(",
"self",
")",
":",
"self",
".",
"_max_values",
"=",
"{",
"}",
"for",
"k",
"in",
"self",
".",
"_max_values_list",
":",
"self",
".",
"_max_values",
"[",
"k",
"]",
"=",
"0.0"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesProcesses.update | Update the processes stats. | glances/processes.py | 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):
"""Update the processes stats."""
# Reset the stats
self.processlist = []
self.reset_processcount()
# Do not process if disable tag is set
if self.disable_tag:
return
# Time since last update (for disk_io rate computation)
t... | [
"Update",
"the",
"processes",
"stats",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/processes.py#L220-L355 | [
"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 ... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Amp.update | Update the AMP | glances/amps/glances_systemv.py | 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):
"""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 ... | [
"Update",
"the",
"AMP"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_systemv.py#L67-L95 | [
"def",
"update",
"(",
"self",
",",
"process_list",
")",
":",
"# Get the systemctl status",
"logger",
".",
"debug",
"(",
"'{}: Update stats using service {}'",
".",
"format",
"(",
"self",
".",
"NAME",
",",
"self",
".",
"get",
"(",
"'service_cmd'",
")",
")",
")"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | seconds_to_hms | Convert seconds to human-readable time. | glances/plugins/glances_processlist.py | 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):
"""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 | [
"Convert",
"seconds",
"to",
"human",
"-",
"readable",
"time",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L34-L43 | [
"def",
"seconds_to_hms",
"(",
"input_seconds",
")",
":",
"minutes",
",",
"seconds",
"=",
"divmod",
"(",
"input_seconds",
",",
"60",
")",
"hours",
",",
"minutes",
"=",
"divmod",
"(",
"minutes",
",",
"60",
")",
"hours",
"=",
"int",
"(",
"hours",
")",
"mi... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | split_cmdline | Return path, cmd and arguments for a process cmdline. | glances/plugins/glances_processlist.py | 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):
"""Return path, cmd and arguments for a process cmdline."""
path, cmd = os.path.split(cmdline[0])
arguments = ' '.join(cmdline[1:])
return path, cmd, arguments | [
"Return",
"path",
"cmd",
"and",
"arguments",
"for",
"a",
"process",
"cmdline",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L46-L50 | [
"def",
"split_cmdline",
"(",
"cmdline",
")",
":",
"path",
",",
"cmd",
"=",
"os",
".",
"path",
".",
"split",
"(",
"cmdline",
"[",
"0",
"]",
")",
"arguments",
"=",
"' '",
".",
"join",
"(",
"cmdline",
"[",
"1",
":",
"]",
")",
"return",
"path",
",",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update processes stats using the input method. | glances/plugins/glances_processlist.py | 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):
"""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... | [
"Update",
"processes",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L124-L146 | [
"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",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_nice_alert | Return the alert relative to the Nice configuration list | glances/plugins/glances_processlist.py | 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):
"""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... | [
"Return",
"the",
"alert",
"relative",
"to",
"the",
"Nice",
"configuration",
"list"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L148-L166 | [
"def",
"get_nice_alert",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"try",
":",
"if",
"value",
"in",
"self",
".",
"get_limit",
"(",
"'nice_critical'",
")",
":",
"return",
"'CRITICAL'",
"except",
"KeyError",
":",
"pass",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_process_curses_data | Get curses data to display for a process.
- p is the process to display
- first is a tag=True if the process is the first on the list | glances/plugins/glances_processlist.py | 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):
"""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... | [
"Get",
"curses",
"data",
"to",
"display",
"for",
"a",
"process",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L168-L406 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_processlist.py | 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):
"""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... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L408-L439 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.__msg_curse_header | Build the header and add it to the ret dict. | glances/plugins/glances_processlist.py | 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):
"""Build the header and add it to the ret dict."""
sort_style = 'SORT'
if args.disable_irix and 0 < self.nb_log_core < 10:
msg = self.layout_header['cpu'].format('CPU%/' + str(self.nb_log_core))
elif args.disabl... | [
"Build",
"the",
"header",
"and",
"add",
"it",
"to",
"the",
"ret",
"dict",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L441-L475 | [
"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",
"=",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.__msg_curse_sum | 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 | glances/plugins/glances_processlist.py | 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):
"""
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... | [
"Build",
"the",
"sum",
"message",
"(",
"only",
"when",
"filter",
"is",
"on",
")",
"and",
"add",
"it",
"to",
"the",
"ret",
"dict",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L477-L565 | [
"def",
"__msg_curse_sum",
"(",
"self",
",",
"ret",
",",
"sep_char",
"=",
"'_'",
",",
"mmm",
"=",
"None",
",",
"args",
"=",
"None",
")",
":",
"ret",
".",
"append",
"(",
"self",
".",
"curse_new_line",
"(",
")",
")",
"if",
"mmm",
"is",
"None",
":",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.__sum_stats | Return the sum of the stats value for the given key.
* indice: If indice is set, get the p[key][indice]
* mmm: display min, max, mean or current (if mmm=None) | glances/plugins/glances_processlist.py | def __sum_stats(self, key, indice=None, mmm=None):
"""Return the sum of the stats value for the given key.
* indice: If indice is set, get the p[key][indice]
* mmm: display min, max, mean or current (if mmm=None)
"""
# Compute stats summary
ret = 0
for p in self.... | def __sum_stats(self, key, indice=None, mmm=None):
"""Return the sum of the stats value for the given key.
* indice: If indice is set, get the p[key][indice]
* mmm: display min, max, mean or current (if mmm=None)
"""
# Compute stats summary
ret = 0
for p in self.... | [
"Return",
"the",
"sum",
"of",
"the",
"stats",
"value",
"for",
"the",
"given",
"key",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L579-L622 | [
"def",
"__sum_stats",
"(",
"self",
",",
"key",
",",
"indice",
"=",
"None",
",",
"mmm",
"=",
"None",
")",
":",
"# Compute stats summary",
"ret",
"=",
"0",
"for",
"p",
"in",
"self",
".",
"stats",
":",
"if",
"key",
"not",
"in",
"p",
":",
"# Correct issu... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.__sort_stats | Return the stats (dict) sorted by (sortedby). | glances/plugins/glances_processlist.py | def __sort_stats(self, sortedby=None):
"""Return the stats (dict) sorted by (sortedby)."""
return sort_stats(self.stats, sortedby,
reverse=glances_processes.sort_reverse) | def __sort_stats(self, sortedby=None):
"""Return the stats (dict) sorted by (sortedby)."""
return sort_stats(self.stats, sortedby,
reverse=glances_processes.sort_reverse) | [
"Return",
"the",
"stats",
"(",
"dict",
")",
"sorted",
"by",
"(",
"sortedby",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L630-L633 | [
"def",
"__sort_stats",
"(",
"self",
",",
"sortedby",
"=",
"None",
")",
":",
"return",
"sort_stats",
"(",
"self",
".",
"stats",
",",
"sortedby",
",",
"reverse",
"=",
"glances_processes",
".",
"sort_reverse",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStdoutCsv.build_header | Build and return the header line | glances/outputs/glances_stdout_csv.py | def build_header(self, plugin, attribute, stat):
"""Build and return the header line"""
line = ''
if attribute is not None:
line += '{}.{}{}'.format(plugin, attribute, self.separator)
else:
if isinstance(stat, dict):
for k in stat.keys():
... | def build_header(self, plugin, attribute, stat):
"""Build and return the header line"""
line = ''
if attribute is not None:
line += '{}.{}{}'.format(plugin, attribute, self.separator)
else:
if isinstance(stat, dict):
for k in stat.keys():
... | [
"Build",
"and",
"return",
"the",
"header",
"line"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_stdout_csv.py#L63-L86 | [
"def",
"build_header",
"(",
"self",
",",
"plugin",
",",
"attribute",
",",
"stat",
")",
":",
"line",
"=",
"''",
"if",
"attribute",
"is",
"not",
"None",
":",
"line",
"+=",
"'{}.{}{}'",
".",
"format",
"(",
"plugin",
",",
"attribute",
",",
"self",
".",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStdoutCsv.build_data | Build and return the data line | glances/outputs/glances_stdout_csv.py | def build_data(self, plugin, attribute, stat):
"""Build and return the data line"""
line = ''
if attribute is not None:
line += '{}{}'.format(str(stat.get(attribute, self.na)),
self.separator)
else:
if isinstance(stat, dict):
... | def build_data(self, plugin, attribute, stat):
"""Build and return the data line"""
line = ''
if attribute is not None:
line += '{}{}'.format(str(stat.get(attribute, self.na)),
self.separator)
else:
if isinstance(stat, dict):
... | [
"Build",
"and",
"return",
"the",
"data",
"line"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_stdout_csv.py#L88-L107 | [
"def",
"build_data",
"(",
"self",
",",
"plugin",
",",
"attribute",
",",
"stat",
")",
":",
"line",
"=",
"''",
"if",
"attribute",
"is",
"not",
"None",
":",
"line",
"+=",
"'{}{}'",
".",
"format",
"(",
"str",
"(",
"stat",
".",
"get",
"(",
"attribute",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStdoutCsv.update | Display stats to stdout.
Refresh every duration second. | glances/outputs/glances_stdout_csv.py | def update(self,
stats,
duration=3):
"""Display stats to stdout.
Refresh every duration second.
"""
# Build the stats list
line = ''
for plugin, attribute in self.plugins_list:
# Check if the plugin exist and is enable
... | def update(self,
stats,
duration=3):
"""Display stats to stdout.
Refresh every duration second.
"""
# Build the stats list
line = ''
for plugin, attribute in self.plugins_list:
# Check if the plugin exist and is enable
... | [
"Display",
"stats",
"to",
"stdout",
".",
"Refresh",
"every",
"duration",
"second",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_stdout_csv.py#L109-L139 | [
"def",
"update",
"(",
"self",
",",
"stats",
",",
"duration",
"=",
"3",
")",
":",
"# Build the stats list",
"line",
"=",
"''",
"for",
"plugin",
",",
"attribute",
"in",
"self",
".",
"plugins_list",
":",
"# Check if the plugin exist and is enable",
"if",
"plugin",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.init | Init the connection to the Riemann server. | glances/exports/glances_riemann.py | def init(self):
"""Init the connection to the Riemann server."""
if not self.export_enable:
return None
try:
client = bernhard.Client(host=self.host, port=self.port)
return client
except Exception as e:
logger.critical("Connection to Rieman... | def init(self):
"""Init the connection to the Riemann server."""
if not self.export_enable:
return None
try:
client = bernhard.Client(host=self.host, port=self.port)
return client
except Exception as e:
logger.critical("Connection to Rieman... | [
"Init",
"the",
"connection",
"to",
"the",
"Riemann",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_riemann.py#L61-L70 | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"try",
":",
"client",
"=",
"bernhard",
".",
"Client",
"(",
"host",
"=",
"self",
".",
"host",
",",
"port",
"=",
"self",
".",
"port",
")",
"return... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.export | Write the points in Riemann. | glances/exports/glances_riemann.py | def export(self, name, columns, points):
"""Write the points in Riemann."""
for i in range(len(columns)):
if not isinstance(points[i], Number):
continue
else:
data = {'host': self.hostname, 'service': name + " " + columns[i], 'metric': points[i]}
... | def export(self, name, columns, points):
"""Write the points in Riemann."""
for i in range(len(columns)):
if not isinstance(points[i], Number):
continue
else:
data = {'host': self.hostname, 'service': name + " " + columns[i], 'metric': points[i]}
... | [
"Write",
"the",
"points",
"in",
"Riemann",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_riemann.py#L72-L83 | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"columns",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"points",
"[",
"i",
"]",
",",
"Number",
")",
":",
"continue"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | getTimeSinceLastUpdate | Return the elapsed time since last update. | glances/timer.py | def getTimeSinceLastUpdate(IOType):
"""Return the elapsed time since last update."""
global last_update_times
# assert(IOType in ['net', 'disk', 'process_disk'])
current_time = time()
last_time = last_update_times.get(IOType)
if not last_time:
time_since_update = 1
else:
time... | def getTimeSinceLastUpdate(IOType):
"""Return the elapsed time since last update."""
global last_update_times
# assert(IOType in ['net', 'disk', 'process_disk'])
current_time = time()
last_time = last_update_times.get(IOType)
if not last_time:
time_since_update = 1
else:
time... | [
"Return",
"the",
"elapsed",
"time",
"since",
"last",
"update",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/timer.py#L29-L40 | [
"def",
"getTimeSinceLastUpdate",
"(",
"IOType",
")",
":",
"global",
"last_update_times",
"# assert(IOType in ['net', 'disk', 'process_disk'])",
"current_time",
"=",
"time",
"(",
")",
"last_time",
"=",
"last_update_times",
".",
"get",
"(",
"IOType",
")",
"if",
"not",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | subsample | Compute a simple mean subsampling.
Data should be a list of numerical itervalues
Return a subsampled list of sampling lenght | glances/compat.py | def subsample(data, sampling):
"""Compute a simple mean subsampling.
Data should be a list of numerical itervalues
Return a subsampled list of sampling lenght
"""
if len(data) <= sampling:
return data
sampling_length = int(round(len(data) / float(sampling)))
return [mean(data[s * s... | def subsample(data, sampling):
"""Compute a simple mean subsampling.
Data should be a list of numerical itervalues
Return a subsampled list of sampling lenght
"""
if len(data) <= sampling:
return data
sampling_length = int(round(len(data) / float(sampling)))
return [mean(data[s * s... | [
"Compute",
"a",
"simple",
"mean",
"subsampling",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/compat.py#L209-L219 | [
"def",
"subsample",
"(",
"data",
",",
"sampling",
")",
":",
"if",
"len",
"(",
"data",
")",
"<=",
"sampling",
":",
"return",
"data",
"sampling_length",
"=",
"int",
"(",
"round",
"(",
"len",
"(",
"data",
")",
"/",
"float",
"(",
"sampling",
")",
")",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | time_serie_subsample | Compute a simple mean subsampling.
Data should be a list of set (time, value)
Return a subsampled list of sampling lenght | glances/compat.py | def time_serie_subsample(data, sampling):
"""Compute a simple mean subsampling.
Data should be a list of set (time, value)
Return a subsampled list of sampling lenght
"""
if len(data) <= sampling:
return data
t = [t[0] for t in data]
v = [t[1] for t in data]
sampling_length = i... | def time_serie_subsample(data, sampling):
"""Compute a simple mean subsampling.
Data should be a list of set (time, value)
Return a subsampled list of sampling lenght
"""
if len(data) <= sampling:
return data
t = [t[0] for t in data]
v = [t[1] for t in data]
sampling_length = i... | [
"Compute",
"a",
"simple",
"mean",
"subsampling",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/compat.py#L222-L236 | [
"def",
"time_serie_subsample",
"(",
"data",
",",
"sampling",
")",
":",
"if",
"len",
"(",
"data",
")",
"<=",
"sampling",
":",
"return",
"data",
"t",
"=",
"[",
"t",
"[",
"0",
"]",
"for",
"t",
"in",
"data",
"]",
"v",
"=",
"[",
"t",
"[",
"1",
"]",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.init | Init the connection to the CouchDB server. | glances/exports/glances_couchdb.py | def init(self):
"""Init the connection to the CouchDB server."""
if not self.export_enable:
return None
if self.user is None:
server_uri = 'http://{}:{}/'.format(self.host,
self.port)
else:
server_uri = ... | def init(self):
"""Init the connection to the CouchDB server."""
if not self.export_enable:
return None
if self.user is None:
server_uri = 'http://{}:{}/'.format(self.host,
self.port)
else:
server_uri = ... | [
"Init",
"the",
"connection",
"to",
"the",
"CouchDB",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_couchdb.py#L57-L88 | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"if",
"self",
".",
"user",
"is",
"None",
":",
"server_uri",
"=",
"'http://{}:{}/'",
".",
"format",
"(",
"self",
".",
"host",
",",
"self",
".",
"po... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.export | Write the points to the CouchDB server. | glances/exports/glances_couchdb.py | def export(self, name, columns, points):
"""Write the points to the CouchDB server."""
logger.debug("Export {} stats to CouchDB".format(name))
# Create DB input
data = dict(zip(columns, points))
# Set the type to the current stat name
data['type'] = name
data['t... | def export(self, name, columns, points):
"""Write the points to the CouchDB server."""
logger.debug("Export {} stats to CouchDB".format(name))
# Create DB input
data = dict(zip(columns, points))
# Set the type to the current stat name
data['type'] = name
data['t... | [
"Write",
"the",
"points",
"to",
"the",
"CouchDB",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_couchdb.py#L94-L110 | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"logger",
".",
"debug",
"(",
"\"Export {} stats to CouchDB\"",
".",
"format",
"(",
"name",
")",
")",
"# Create DB input",
"data",
"=",
"dict",
"(",
"zip",
"(",
"columns",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update core stats.
Stats is a dict (with both physical and log cpu number) instead of a integer. | glances/plugins/glances_core.py | def update(self):
"""Update core stats.
Stats is a dict (with both physical and log cpu number) instead of a integer.
"""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
... | def update(self):
"""Update core stats.
Stats is a dict (with both physical and log cpu number) instead of a integer.
"""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
... | [
"Update",
"core",
"stats",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_core.py#L43-L73 | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats using the standard system lib",
"# The psutil 2.0 include psutil.cpu_count() and psu... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.is_theme | Return True if the theme *name* should be used. | glances/outputs/glances_curses.py | def is_theme(self, name):
"""Return True if the theme *name* should be used."""
return getattr(self.args, 'theme_' + name) or self.theme['name'] == name | def is_theme(self, name):
"""Return True if the theme *name* should be used."""
return getattr(self.args, 'theme_' + name) or self.theme['name'] == name | [
"Return",
"True",
"if",
"the",
"theme",
"*",
"name",
"*",
"should",
"be",
"used",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L164-L166 | [
"def",
"is_theme",
"(",
"self",
",",
"name",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"args",
",",
"'theme_'",
"+",
"name",
")",
"or",
"self",
".",
"theme",
"[",
"'name'",
"]",
"==",
"name"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses._init_cursor | Init cursors. | glances/outputs/glances_curses.py | def _init_cursor(self):
"""Init cursors."""
if hasattr(curses, 'noecho'):
curses.noecho()
if hasattr(curses, 'cbreak'):
curses.cbreak()
self.set_cursor(0) | def _init_cursor(self):
"""Init cursors."""
if hasattr(curses, 'noecho'):
curses.noecho()
if hasattr(curses, 'cbreak'):
curses.cbreak()
self.set_cursor(0) | [
"Init",
"cursors",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L173-L180 | [
"def",
"_init_cursor",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"curses",
",",
"'noecho'",
")",
":",
"curses",
".",
"noecho",
"(",
")",
"if",
"hasattr",
"(",
"curses",
",",
"'cbreak'",
")",
":",
"curses",
".",
"cbreak",
"(",
")",
"self",
".",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses._init_colors | Init the Curses color layout. | glances/outputs/glances_curses.py | def _init_colors(self):
"""Init the Curses color layout."""
# Set curses options
try:
if hasattr(curses, 'start_color'):
curses.start_color()
if hasattr(curses, 'use_default_colors'):
curses.use_default_colors()
except Exception as... | def _init_colors(self):
"""Init the Curses color layout."""
# Set curses options
try:
if hasattr(curses, 'start_color'):
curses.start_color()
if hasattr(curses, 'use_default_colors'):
curses.use_default_colors()
except Exception as... | [
"Init",
"the",
"Curses",
"color",
"layout",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L182-L295 | [
"def",
"_init_colors",
"(",
"self",
")",
":",
"# Set curses options",
"try",
":",
"if",
"hasattr",
"(",
"curses",
",",
"'start_color'",
")",
":",
"curses",
".",
"start_color",
"(",
")",
"if",
"hasattr",
"(",
"curses",
",",
"'use_default_colors'",
")",
":",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.loop_position | Return the current sort in the loop | glances/outputs/glances_curses.py | def loop_position(self):
"""Return the current sort in the loop"""
for i, v in enumerate(self._sort_loop):
if v == glances_processes.sort_key:
return i
return 0 | def loop_position(self):
"""Return the current sort in the loop"""
for i, v in enumerate(self._sort_loop):
if v == glances_processes.sort_key:
return i
return 0 | [
"Return",
"the",
"current",
"sort",
"in",
"the",
"loop"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L414-L419 | [
"def",
"loop_position",
"(",
"self",
")",
":",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"self",
".",
"_sort_loop",
")",
":",
"if",
"v",
"==",
"glances_processes",
".",
"sort_key",
":",
"return",
"i",
"return",
"0"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.enable_fullquicklook | Disable the full quicklook mode | glances/outputs/glances_curses.py | def enable_fullquicklook(self):
"""Disable the full quicklook mode"""
self.args.disable_quicklook = False
for p in ['cpu', 'gpu', 'mem', 'memswap']:
setattr(self.args, 'disable_' + p, True) | def enable_fullquicklook(self):
"""Disable the full quicklook mode"""
self.args.disable_quicklook = False
for p in ['cpu', 'gpu', 'mem', 'memswap']:
setattr(self.args, 'disable_' + p, True) | [
"Disable",
"the",
"full",
"quicklook",
"mode"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L436-L440 | [
"def",
"enable_fullquicklook",
"(",
"self",
")",
":",
"self",
".",
"args",
".",
"disable_quicklook",
"=",
"False",
"for",
"p",
"in",
"[",
"'cpu'",
",",
"'gpu'",
",",
"'mem'",
",",
"'memswap'",
"]",
":",
"setattr",
"(",
"self",
".",
"args",
",",
"'disab... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.end | Shutdown the curses window. | glances/outputs/glances_curses.py | def end(self):
"""Shutdown the curses window."""
if hasattr(curses, 'echo'):
curses.echo()
if hasattr(curses, 'nocbreak'):
curses.nocbreak()
if hasattr(curses, 'curs_set'):
try:
curses.curs_set(1)
except Exception:
... | def end(self):
"""Shutdown the curses window."""
if hasattr(curses, 'echo'):
curses.echo()
if hasattr(curses, 'nocbreak'):
curses.nocbreak()
if hasattr(curses, 'curs_set'):
try:
curses.curs_set(1)
except Exception:
... | [
"Shutdown",
"the",
"curses",
"window",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L442-L453 | [
"def",
"end",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"curses",
",",
"'echo'",
")",
":",
"curses",
".",
"echo",
"(",
")",
"if",
"hasattr",
"(",
"curses",
",",
"'nocbreak'",
")",
":",
"curses",
".",
"nocbreak",
"(",
")",
"if",
"hasattr",
"(",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.__get_stat_display | Return a dict of dict with all the stats display.
stats: Global stats dict
layer: ~ cs_status
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a SNMP server
"Disconnected": Client is disc... | glances/outputs/glances_curses.py | def __get_stat_display(self, stats, layer):
"""Return a dict of dict with all the stats display.
stats: Global stats dict
layer: ~ cs_status
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a... | def __get_stat_display(self, stats, layer):
"""Return a dict of dict with all the stats display.
stats: Global stats dict
layer: ~ cs_status
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a... | [
"Return",
"a",
"dict",
"of",
"dict",
"with",
"all",
"the",
"stats",
"display",
".",
"stats",
":",
"Global",
"stats",
"dict",
"layer",
":",
"~",
"cs_status",
"None",
":",
"standalone",
"or",
"server",
"mode",
"Connected",
":",
"Client",
"is",
"connected",
... | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L478-L511 | [
"def",
"__get_stat_display",
"(",
"self",
",",
"stats",
",",
"layer",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"p",
"in",
"stats",
".",
"getPluginsList",
"(",
"enable",
"=",
"False",
")",
":",
"if",
"p",
"==",
"'quicklook'",
"or",
"p",
"==",
"'processl... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.display | Display stats on the screen.
stats: Stats database to display
cs_status:
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a SNMP server
"Disconnected": Client is disconnected from the se... | glances/outputs/glances_curses.py | def display(self, stats, cs_status=None):
"""Display stats on the screen.
stats: Stats database to display
cs_status:
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a SNMP server
... | def display(self, stats, cs_status=None):
"""Display stats on the screen.
stats: Stats database to display
cs_status:
"None": standalone or server mode
"Connected": Client is connected to a Glances server
"SNMP": Client is connected to a SNMP server
... | [
"Display",
"stats",
"on",
"the",
"screen",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L513-L625 | [
"def",
"display",
"(",
"self",
",",
"stats",
",",
"cs_status",
"=",
"None",
")",
":",
"# Init the internal line/column for Glances Curses",
"self",
".",
"init_line_column",
"(",
")",
"# Update the stats messages",
"###########################",
"# Get all the plugins but quic... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.__display_header | Display the firsts lines (header) in the Curses interface.
system + ip + uptime
(cloud) | glances/outputs/glances_curses.py | def __display_header(self, stat_display):
"""Display the firsts lines (header) in the Curses interface.
system + ip + uptime
(cloud)
"""
# First line
self.new_line()
self.space_between_column = 0
l_uptime = (self.get_stats_display_width(stat_display["syst... | def __display_header(self, stat_display):
"""Display the firsts lines (header) in the Curses interface.
system + ip + uptime
(cloud)
"""
# First line
self.new_line()
self.space_between_column = 0
l_uptime = (self.get_stats_display_width(stat_display["syst... | [
"Display",
"the",
"firsts",
"lines",
"(",
"header",
")",
"in",
"the",
"Curses",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L627-L652 | [
"def",
"__display_header",
"(",
"self",
",",
"stat_display",
")",
":",
"# First line",
"self",
".",
"new_line",
"(",
")",
"self",
".",
"space_between_column",
"=",
"0",
"l_uptime",
"=",
"(",
"self",
".",
"get_stats_display_width",
"(",
"stat_display",
"[",
"\"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.__display_top | Display the second line in the Curses interface.
<QUICKLOOK> + CPU|PERCPU + <GPU> + MEM + SWAP + LOAD | glances/outputs/glances_curses.py | def __display_top(self, stat_display, stats):
"""Display the second line in the Curses interface.
<QUICKLOOK> + CPU|PERCPU + <GPU> + MEM + SWAP + LOAD
"""
self.init_column()
self.new_line()
# Init quicklook
stat_display['quicklook'] = {'msgdict': []}
# ... | def __display_top(self, stat_display, stats):
"""Display the second line in the Curses interface.
<QUICKLOOK> + CPU|PERCPU + <GPU> + MEM + SWAP + LOAD
"""
self.init_column()
self.new_line()
# Init quicklook
stat_display['quicklook'] = {'msgdict': []}
# ... | [
"Display",
"the",
"second",
"line",
"in",
"the",
"Curses",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L654-L727 | [
"def",
"__display_top",
"(",
"self",
",",
"stat_display",
",",
"stats",
")",
":",
"self",
".",
"init_column",
"(",
")",
"self",
".",
"new_line",
"(",
")",
"# Init quicklook",
"stat_display",
"[",
"'quicklook'",
"]",
"=",
"{",
"'msgdict'",
":",
"[",
"]",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.__display_left | Display the left sidebar in the Curses interface. | glances/outputs/glances_curses.py | def __display_left(self, stat_display):
"""Display the left sidebar in the Curses interface."""
self.init_column()
if self.args.disable_left_sidebar:
return
for s in self._left_sidebar:
if ((hasattr(self.args, 'enable_' + s) or
hasattr(self.args... | def __display_left(self, stat_display):
"""Display the left sidebar in the Curses interface."""
self.init_column()
if self.args.disable_left_sidebar:
return
for s in self._left_sidebar:
if ((hasattr(self.args, 'enable_' + s) or
hasattr(self.args... | [
"Display",
"the",
"left",
"sidebar",
"in",
"the",
"Curses",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L729-L740 | [
"def",
"__display_left",
"(",
"self",
",",
"stat_display",
")",
":",
"self",
".",
"init_column",
"(",
")",
"if",
"self",
".",
"args",
".",
"disable_left_sidebar",
":",
"return",
"for",
"s",
"in",
"self",
".",
"_left_sidebar",
":",
"if",
"(",
"(",
"hasatt... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.