mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-04 07:34:49 +03:00
Do not return values from setters
A setter method always takes a parameter and does not return a value. Rename 'set_stats_snmp' method to 'get_stats_snmp'.
This commit is contained in:
parent
d98d6c3b55
commit
0f083d215a
@ -91,7 +91,6 @@ class GlancesClient(object):
|
||||
- 'snmp' = SNMP (fallback)
|
||||
"""
|
||||
self.mode = mode
|
||||
return self.mode
|
||||
|
||||
def get_mode(self):
|
||||
"""Get the client mode.
|
||||
|
@ -89,8 +89,6 @@ class GlancesLogs(object):
|
||||
process_auto_by = 'cpu_percent'
|
||||
glances_processes.setautosortkey(process_auto_by)
|
||||
|
||||
return process_auto_by
|
||||
|
||||
def reset_process_sort(self):
|
||||
"""Reset the process_auto_by variable."""
|
||||
# Default sort is...
|
||||
@ -98,8 +96,6 @@ class GlancesLogs(object):
|
||||
glances_processes.setautosortkey(process_auto_by)
|
||||
glances_processes.setmanualsortkey(None)
|
||||
|
||||
return process_auto_by
|
||||
|
||||
def add(self, item_state, item_type, item_value,
|
||||
proc_list=None, proc_desc="", peak_time=3):
|
||||
"""Add a new item to the logs list.
|
||||
|
@ -295,7 +295,6 @@ class GlancesProcesses(object):
|
||||
def set_max_processes(self, value):
|
||||
"""Set the maximum number of processes showed in the UI interfaces"""
|
||||
self.max_processes = value
|
||||
return self.max_processes
|
||||
|
||||
def get_max_processes(self):
|
||||
"""Get the maximum number of processes showed in the UI interfaces"""
|
||||
@ -316,7 +315,6 @@ class GlancesProcesses(object):
|
||||
self.process_filter_re = None
|
||||
else:
|
||||
self.process_filter_re = None
|
||||
return self.process_filter
|
||||
|
||||
def get_process_filter(self):
|
||||
"""Get the process filter"""
|
||||
@ -709,12 +707,10 @@ class GlancesProcesses(object):
|
||||
self.processmanualsort = sortedby
|
||||
if self._enable_tree and (self.process_tree is not None):
|
||||
self.process_tree.set_sorting(sortedby, sortedby != "name")
|
||||
return self.processmanualsort
|
||||
|
||||
def setautosortkey(self, sortedby):
|
||||
"""Set the current sort key for automatic sort."""
|
||||
self.processautosort = sortedby
|
||||
return self.processautosort
|
||||
|
||||
def resetsort(self):
|
||||
"""Set the default sort: Auto"""
|
||||
|
@ -64,7 +64,6 @@ class Bar(object):
|
||||
|
||||
def set_size(self, size):
|
||||
self.__size = size
|
||||
return self.__size
|
||||
|
||||
def get_percent(self):
|
||||
return self.__percent
|
||||
@ -73,7 +72,6 @@ class Bar(object):
|
||||
assert percent >= 0
|
||||
assert percent <= 100
|
||||
self.__percent = percent
|
||||
return self.__percent
|
||||
|
||||
def __str__(self):
|
||||
"""Return the bars"""
|
||||
|
@ -944,7 +944,6 @@ class GlancesCursesBrowser(_GlancesCurses):
|
||||
def set_active(self, index=None):
|
||||
"""Set the active server or None if no server selected"""
|
||||
self.active_server = index
|
||||
return self.active_server
|
||||
|
||||
def get_active(self):
|
||||
"""Return the active server (the one display in front) or None if it is the browser list"""
|
||||
@ -957,7 +956,6 @@ class GlancesCursesBrowser(_GlancesCurses):
|
||||
def cursor_set(self, pos):
|
||||
"""Set the cursor position and return it"""
|
||||
self.cursor_position = pos
|
||||
return self.cursor_position
|
||||
|
||||
def cursor_get(self):
|
||||
"""Return the cursor position"""
|
||||
@ -969,7 +967,6 @@ class GlancesCursesBrowser(_GlancesCurses):
|
||||
self.cursor_position -= 1
|
||||
else:
|
||||
self.cursor_position = len(servers_list) - 1
|
||||
return self.cursor_position
|
||||
|
||||
def cursor_down(self, servers_list):
|
||||
"""Set the cursor to position N-1 in the list"""
|
||||
@ -977,7 +974,6 @@ class GlancesCursesBrowser(_GlancesCurses):
|
||||
self.cursor_position += 1
|
||||
else:
|
||||
self.cursor_position = 0
|
||||
return self.cursor_position
|
||||
|
||||
def __catch_key(self, servers_list):
|
||||
# Catch the browser pressed key
|
||||
|
@ -96,7 +96,7 @@ class Plugin(GlancesPlugin):
|
||||
# You can find the CPU utilization of windows system by querying the oid
|
||||
# Give also the number of core (number of element in the table)
|
||||
try:
|
||||
cpu_stats = self.set_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
cpu_stats = self.get_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
bulk=True)
|
||||
except KeyError:
|
||||
self.reset()
|
||||
@ -117,10 +117,10 @@ class Plugin(GlancesPlugin):
|
||||
else:
|
||||
# Default behavor
|
||||
try:
|
||||
self.stats = self.set_stats_snmp(
|
||||
self.stats = self.get_stats_snmp(
|
||||
snmp_oid=snmp_oid[self.get_short_system_name()])
|
||||
except KeyError:
|
||||
self.stats = self.set_stats_snmp(
|
||||
self.stats = self.get_stats_snmp(
|
||||
snmp_oid=snmp_oid['default'])
|
||||
|
||||
if self.stats['idle'] == '':
|
||||
|
@ -138,10 +138,10 @@ class Plugin(GlancesPlugin):
|
||||
|
||||
# SNMP bulk command to get all file system in one shot
|
||||
try:
|
||||
fs_stat = self.set_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
bulk=True)
|
||||
except KeyError:
|
||||
fs_stat = self.set_stats_snmp(snmp_oid=snmp_oid['default'],
|
||||
fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid['default'],
|
||||
bulk=True)
|
||||
|
||||
# Loop over fs
|
||||
|
@ -91,7 +91,7 @@ class Plugin(GlancesPlugin):
|
||||
'cpucore': self.nb_log_core}
|
||||
elif self.get_input() == 'snmp':
|
||||
# Update stats using SNMP
|
||||
self.stats = self.set_stats_snmp(snmp_oid=snmp_oid)
|
||||
self.stats = self.get_stats_snmp(snmp_oid=snmp_oid)
|
||||
|
||||
if self.stats['min1'] == '':
|
||||
self.reset()
|
||||
|
@ -117,7 +117,7 @@ class Plugin(GlancesPlugin):
|
||||
if self.get_short_system_name() in ('windows', 'esxi'):
|
||||
# Mem stats for Windows|Vmware Esxi are stored in the FS table
|
||||
try:
|
||||
fs_stat = self.set_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
bulk=True)
|
||||
except KeyError:
|
||||
self.reset()
|
||||
@ -133,7 +133,7 @@ class Plugin(GlancesPlugin):
|
||||
break
|
||||
else:
|
||||
# Default behavor for others OS
|
||||
self.stats = self.set_stats_snmp(snmp_oid=snmp_oid['default'])
|
||||
self.stats = self.get_stats_snmp(snmp_oid=snmp_oid['default'])
|
||||
|
||||
if self.stats['total'] == '':
|
||||
self.reset()
|
||||
|
@ -89,7 +89,7 @@ class Plugin(GlancesPlugin):
|
||||
if self.get_short_system_name() == 'windows':
|
||||
# Mem stats for Windows OS are stored in the FS table
|
||||
try:
|
||||
fs_stat = self.set_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
bulk=True)
|
||||
except KeyError:
|
||||
self.reset()
|
||||
@ -109,7 +109,7 @@ class Plugin(GlancesPlugin):
|
||||
'total'] - self.stats['used']
|
||||
break
|
||||
else:
|
||||
self.stats = self.set_stats_snmp(snmp_oid=snmp_oid['default'])
|
||||
self.stats = self.get_stats_snmp(snmp_oid=snmp_oid['default'])
|
||||
|
||||
if self.stats['total'] == '':
|
||||
self.reset()
|
||||
|
@ -128,10 +128,10 @@ class Plugin(GlancesPlugin):
|
||||
|
||||
# SNMP bulk command to get all network interface in one shot
|
||||
try:
|
||||
netiocounters = self.set_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
netiocounters = self.get_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
|
||||
bulk=True)
|
||||
except KeyError:
|
||||
netiocounters = self.set_stats_snmp(snmp_oid=snmp_oid['default'],
|
||||
netiocounters = self.get_stats_snmp(snmp_oid=snmp_oid['default'],
|
||||
bulk=True)
|
||||
|
||||
# Previous network interface stats are stored in the network_old variable
|
||||
|
@ -107,7 +107,6 @@ class GlancesPlugin(object):
|
||||
logger.debug("Reset history for plugin {0} (items: {0})".format(
|
||||
self.plugin_name, reset_list))
|
||||
self.stats_history = {}
|
||||
return self.stats_history
|
||||
|
||||
def update_stats_history(self, item_name=''):
|
||||
"""Update stats history"""
|
||||
@ -127,7 +126,6 @@ class GlancesPlugin(object):
|
||||
# Stats is not a list
|
||||
# Add the item to the history directly
|
||||
self.add_item_history(i['name'], self.stats[i['name']])
|
||||
return self.stats_history
|
||||
|
||||
def get_stats_history(self):
|
||||
"""Return the stats history"""
|
||||
@ -148,7 +146,6 @@ class GlancesPlugin(object):
|
||||
"""
|
||||
self.input_method = input_method
|
||||
self.short_system_name = short_system_name
|
||||
return self.input_method
|
||||
|
||||
def get_input(self):
|
||||
"""Get the input method."""
|
||||
@ -161,9 +158,8 @@ class GlancesPlugin(object):
|
||||
def set_stats(self, input_stats):
|
||||
"""Set the stats to input_stats."""
|
||||
self.stats = input_stats
|
||||
return self.stats
|
||||
|
||||
def set_stats_snmp(self, bulk=False, snmp_oid=None):
|
||||
def get_stats_snmp(self, bulk=False, snmp_oid=None):
|
||||
"""Update stats using SNMP.
|
||||
|
||||
If bulk=True, use a bulk request instead of a get request.
|
||||
@ -303,7 +299,6 @@ class GlancesPlugin(object):
|
||||
def set_views(self, input_views):
|
||||
"""Set the views to input_views."""
|
||||
self.views = input_views
|
||||
return self.views
|
||||
|
||||
def get_views(self, item=None, key=None, option=None):
|
||||
"""Return the views object.
|
||||
@ -344,7 +339,6 @@ class GlancesPlugin(object):
|
||||
def set_limits(self, input_limits):
|
||||
"""Set the limits to input_limits."""
|
||||
self.limits = input_limits
|
||||
return self.limits
|
||||
|
||||
def get_limits(self):
|
||||
"""Return the limits object."""
|
||||
|
@ -139,10 +139,10 @@ class Plugin(GlancesPlugin):
|
||||
elif self.get_input() == 'snmp':
|
||||
# Update stats using SNMP
|
||||
try:
|
||||
self.stats = self.set_stats_snmp(
|
||||
self.stats = self.get_stats_snmp(
|
||||
snmp_oid=snmp_oid[self.get_short_system_name()])
|
||||
except KeyError:
|
||||
self.stats = self.set_stats_snmp(snmp_oid=snmp_oid['default'])
|
||||
self.stats = self.get_stats_snmp(snmp_oid=snmp_oid['default'])
|
||||
# Default behavor: display all the information
|
||||
self.stats['os_name'] = self.stats['system_name']
|
||||
# Windows OS tips
|
||||
|
@ -70,7 +70,7 @@ class Plugin(GlancesPlugin):
|
||||
self.stats = str(uptime).split('.')[0]
|
||||
elif self.get_input() == 'snmp':
|
||||
# Update stats using SNMP
|
||||
uptime = self.set_stats_snmp(snmp_oid=snmp_oid)['_uptime']
|
||||
uptime = self.get_stats_snmp(snmp_oid=snmp_oid)['_uptime']
|
||||
try:
|
||||
# In hundredths of seconds
|
||||
self.stats = str(timedelta(seconds=int(uptime) / 100))
|
||||
|
Loading…
Reference in New Issue
Block a user