summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2020-12-13 16:15:45 +0100
committernicolargo <nicolas@nicolargo.com>2020-12-13 16:15:45 +0100
commitf7f4670302a86f3a2e3073e62f85a6a6dc953c33 (patch)
tree0fbebc312ba585d53e4f57b3a4aafad4dc9c3c86
parent930d5174dd58293ed4ac250922e73836dd48d4a3 (diff)
crash on startup on Illumos when no swap is configured #1767
-rw-r--r--glances/plugins/glances_memswap.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/glances/plugins/glances_memswap.py b/glances/plugins/glances_memswap.py
index 42c367a8..6fa22148 100644
--- a/glances/plugins/glances_memswap.py
+++ b/glances/plugins/glances_memswap.py
@@ -66,20 +66,24 @@ class Plugin(GlancesPlugin):
if self.input_method == 'local':
# Update stats using the standard system lib
# Grab SWAP using the psutil swap_memory method
- sm_stats = psutil.swap_memory()
-
- # Get all the swap stats (copy/paste of the psutil documentation)
- # total: total swap memory in bytes
- # used: used swap memory in bytes
- # free: free swap memory in bytes
- # percent: the percentage usage
- # sin: the number of bytes the system has swapped in from disk (cumulative)
- # sout: the number of bytes the system has swapped out from disk
- # (cumulative)
- for swap in ['total', 'used', 'free', 'percent',
- 'sin', 'sout']:
- if hasattr(sm_stats, swap):
- stats[swap] = getattr(sm_stats, swap)
+ try:
+ sm_stats = psutil.swap_memory()
+ except RuntimeError:
+ # Crash on startup on Illumos when no swap is configured #1767
+ pass
+ else:
+ # Get all the swap stats (copy/paste of the psutil documentation)
+ # total: total swap memory in bytes
+ # used: used swap memory in bytes
+ # free: free swap memory in bytes
+ # percent: the percentage usage
+ # sin: the number of bytes the system has swapped in from disk (cumulative)
+ # sout: the number of bytes the system has swapped out from disk
+ # (cumulative)
+ for swap in ['total', 'used', 'free', 'percent',
+ 'sin', 'sout']:
+ if hasattr(sm_stats, swap):
+ stats[swap] = getattr(sm_stats, swap)
elif self.input_method == 'snmp':
# Update stats using SNMP
if self.short_system_name == 'windows':