On Sun, Oct 27, 2024 at 10:53:24AM +0100, Alex Holst wrote: > Not sure how to further troubleshoot this problem I've had for months. > -current and 7.6 systems with no glances.conf result in this traceback. I've > also attempted to turn off swap monitoring in the config file or at the > command line. > > Any hints? > > $ glances > Traceback (most recent call last): > File "/usr/local/bin/glances", line 8, in <module> > sys.exit(main()) > ^^^^^^ > File "/usr/local/lib/python3.11/site-packages/glances/__init__.py", line > 179, in main > start(config=core.get_config(), args=core.get_args()) > File "/usr/local/lib/python3.11/site-packages/glances/__init__.py", line > 108, in start > mode = GlancesMode(config=config, args=args) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > File "/usr/local/lib/python3.11/site-packages/glances/standalone.py", line > 71, in __init__ > self.stats.update() > File "/usr/local/lib/python3.11/site-packages/glances/stats.py", line 216, > in update > self._plugins[p].update() > File > "/usr/local/lib/python3.11/site-packages/glances/plugins/glances_plugin.py", > line 1114, in wrapper > ret = fct(self, *args, **kw) > ^^^^^^^^^^^^^^^^^^^^^^ > File > "/usr/local/lib/python3.11/site-packages/glances/plugins/glances_plugin.py", > line 1131, in wrapper > ret = fct(*args, **kw) > ^^^^^^^^^^^^^^^^ > File > "/usr/local/lib/python3.11/site-packages/glances/plugins/glances_quicklook.py", > line 58, in update > stats['swap'] = psutil.swap_memory().percent > ^^^^^^^^^^^^^^^^^^^^ > File "/usr/local/lib/python3.11/site-packages/psutil/__init__.py", line > 2027, in swap_memory > return _psplatform.swap_memory() > ^^^^^^^^^^^^^^^^^^^^^^^^^ > File "/usr/local/lib/python3.11/site-packages/psutil/_psbsd.py", line 231, > in swap_memory > total, used, free, sin, sout = cext.swap_mem() > ^^^^^^^^^^^^^^^ > OSError: [Errno 0] Error
I suspect you're not using a swap partition on your system. I have to deactivate swap to reproduce this. The following patch fixes the fatal error in psutil.swap_memory(). Hopefully the glances codebase can deal with a zero sized total swap space. Tests welcome. Index: Makefile =================================================================== RCS file: /cvs/ports/sysutils/py-psutil/Makefile,v diff -u -p -r1.28 Makefile --- Makefile 21 Jun 2024 08:20:01 -0000 1.28 +++ Makefile 27 Oct 2024 12:38:10 -0000 @@ -1,6 +1,7 @@ COMMENT= library to retrieve system information and utilisation MODPY_EGG_VERSION= 6.0.0 +REVISION= 0 DISTNAME= psutil-${MODPY_EGG_VERSION} PKGNAME= py-psutil-${MODPY_EGG_VERSION} Index: patches/patch-psutil_arch_openbsd_mem_c =================================================================== RCS file: patches/patch-psutil_arch_openbsd_mem_c diff -N patches/patch-psutil_arch_openbsd_mem_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-psutil_arch_openbsd_mem_c 27 Oct 2024 12:38:10 -0000 @@ -0,0 +1,35 @@ +Having no swap partition is not an error. + +Index: psutil/arch/openbsd/mem.c +--- psutil/arch/openbsd/mem.c.orig ++++ psutil/arch/openbsd/mem.c +@@ -75,19 +75,17 @@ psutil_swap_mem(PyObject *self, PyObject *args) { + struct swapent *swdev; + int nswap, i; + +- if ((nswap = swapctl(SWAP_NSWAP, 0, 0)) == 0) { +- PyErr_SetFromErrno(PyExc_OSError); +- return NULL; +- } ++ nswap = swapctl(SWAP_NSWAP, 0, 0); ++ if (nswap != 0) { ++ if ((swdev = calloc(nswap, sizeof(*swdev))) == NULL) { ++ PyErr_NoMemory(); ++ return NULL; ++ } + +- if ((swdev = calloc(nswap, sizeof(*swdev))) == NULL) { +- PyErr_NoMemory(); +- return NULL; +- } +- +- if (swapctl(SWAP_STATS, swdev, nswap) == -1) { +- PyErr_SetFromErrno(PyExc_OSError); +- goto error; ++ if (swapctl(SWAP_STATS, swdev, nswap) == -1) { ++ PyErr_SetFromErrno(PyExc_OSError); ++ goto error; ++ } + } + + // Total things up. -- jca