mirror of
https://github.com/nicolargo/glances.git
synced 2024-10-26 20:26:58 +03:00
Merge branch 'clean-fs-plugin-code' into develop
This commit is contained in:
commit
f5ecbf7a1f
@ -113,11 +113,23 @@ class PluginModel(GlancesPluginModel):
|
|||||||
@GlancesPluginModel._check_decorator
|
@GlancesPluginModel._check_decorator
|
||||||
@GlancesPluginModel._log_result_decorator
|
@GlancesPluginModel._log_result_decorator
|
||||||
def update(self):
|
def update(self):
|
||||||
|
"""Update the FS stats using the input method."""
|
||||||
|
# Update the stats
|
||||||
|
if self.input_method == 'local':
|
||||||
|
stats = self.update_local()
|
||||||
|
else:
|
||||||
|
stats = self.get_init_value()
|
||||||
|
|
||||||
|
# Update the stats
|
||||||
|
self.stats = stats
|
||||||
|
|
||||||
|
return self.stats
|
||||||
|
|
||||||
|
def update_local(self):
|
||||||
"""Update the FS stats using the input method."""
|
"""Update the FS stats using the input method."""
|
||||||
# Init new stats
|
# Init new stats
|
||||||
stats = self.get_init_value()
|
stats = self.get_init_value()
|
||||||
|
|
||||||
if self.input_method == 'local':
|
|
||||||
# Update stats using the standard system lib
|
# Update stats using the standard system lib
|
||||||
|
|
||||||
# Grab the stats using the psutil disk_partitions
|
# Grab the stats using the psutil disk_partitions
|
||||||
@ -127,7 +139,7 @@ class PluginModel(GlancesPluginModel):
|
|||||||
fs_stat = psutil.disk_partitions(all=False)
|
fs_stat = psutil.disk_partitions(all=False)
|
||||||
except (UnicodeDecodeError, PermissionError):
|
except (UnicodeDecodeError, PermissionError):
|
||||||
logger.debug("Plugin - fs: PsUtil fetch failed")
|
logger.debug("Plugin - fs: PsUtil fetch failed")
|
||||||
return self.stats
|
return stats
|
||||||
|
|
||||||
# Optional hack to allow logical mounts points (issue #448)
|
# Optional hack to allow logical mounts points (issue #448)
|
||||||
allowed_fs_types = self.get_conf_value('allow')
|
allowed_fs_types = self.get_conf_value('allow')
|
||||||
@ -150,6 +162,7 @@ class PluginModel(GlancesPluginModel):
|
|||||||
# Loop over fs
|
# Loop over fs
|
||||||
for fs in fs_stat:
|
for fs in fs_stat:
|
||||||
# Hide the stats if the mount point is in the exclude list
|
# Hide the stats if the mount point is in the exclude list
|
||||||
|
# It avoids unnecessary call to PsUtil disk_usage
|
||||||
if not self.is_display(fs.mountpoint):
|
if not self.is_display(fs.mountpoint):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -183,7 +196,13 @@ class PluginModel(GlancesPluginModel):
|
|||||||
|
|
||||||
stats.append(fs_current)
|
stats.append(fs_current)
|
||||||
|
|
||||||
elif self.input_method == 'snmp':
|
return stats
|
||||||
|
|
||||||
|
def update_snmp(self):
|
||||||
|
"""Update the FS stats using the input method."""
|
||||||
|
# Init new stats
|
||||||
|
stats = self.get_init_value()
|
||||||
|
|
||||||
# Update stats using SNMP
|
# Update stats using SNMP
|
||||||
|
|
||||||
# SNMP bulk command to get all file system in one shot
|
# SNMP bulk command to get all file system in one shot
|
||||||
@ -230,10 +249,7 @@ class PluginModel(GlancesPluginModel):
|
|||||||
continue
|
continue
|
||||||
stats.append(fs_current)
|
stats.append(fs_current)
|
||||||
|
|
||||||
# Update the stats
|
return stats
|
||||||
self.stats = stats
|
|
||||||
|
|
||||||
return self.stats
|
|
||||||
|
|
||||||
def update_views(self):
|
def update_views(self):
|
||||||
"""Update stats views."""
|
"""Update stats views."""
|
||||||
|
Loading…
Reference in New Issue
Block a user