Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError when using --export influxdb2 in with latest-full docker image #2665

Closed
bdcarr opened this issue Jan 26, 2024 · 5 comments

Comments

@bdcarr
Copy link

bdcarr commented Jan 26, 2024

Describe the bug
When you try to run the latest-full glances docker image in client mode with --export influxdb2, you get this error and the container exits:

Error while initializing the now plugin ('NoneType' object has no attribute 'strftime_format')
Error while initializing the system plugin ('NoneType' object has no attribute 'time')
Error while initializing the processlist plugin ('NoneType' object has no attribute 'sort_processes_key')
Error while initializing the sensors plugin ('NoneType' object has no attribute 'time')
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/glances/__main__.py", line 18, in <module>
    glances.main()
  File "/app/glances/__init__.py", line 185, in main
    start(config=core.get_config(), args=core.get_args())
  File "/app/glances/__init__.py", line 131, in start
    mode.serve_forever()
  File "/app/glances/client.py", line 234, in serve_forever
    if not self.login():
           ^^^^^^^^^^^^
  File "/app/glances/client.py", line 163, in login
    if not self._login_snmp():
           ^^^^^^^^^^^^^^^^^^
  File "/app/glances/client.py", line 142, in _login_snmp
    self.stats = GlancesStatsClientSNMP(config=self.config, args=self.args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/glances/stats_client_snmp.py", line 47, in __init__
    self.load_modules(self.args)
  File "/app/glances/stats.py", line 90, in load_modules
    self.load_exports(args=args)
  File "/app/glances/stats.py", line 162, in load_exports
    export_module = __import__(self._exports_all[export_name])
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'glances_influxdb2'

To Reproduce
I've got a docker-compose with two instances of glances running, a server and client. I can supply it if you want. But the issue can be reproduced with a single run command:

docker run -e GLANCES_OPT="--client localhost --export influxdb2" nicolargo/glances:latest-full

Expected behavior
The container starts up and begins exporting data to the influxdb defined in the config file (or with the above one-line example, we at least don't get a ModuleNotFoundError).

Environement (please complete the following information)

  • Operating System: Raspberry Pi OS 12 64-bit
  • Glances & psutil versions: Glances v3.4.0.3 with PsUtil v5.9.7
  • How do you install Glances (Pypi package, script, package manager, source): Via docker-compose nicolargo/glances:latest-full
  • Glances test (only available with Glances 3.1.7 or higher):

I grabbed this from the other container, which doesn't have the --export flag and so is able to start:

click to expand
===============================================================================
Glances 3.4.0.3 (/app/glances/__init__.py)
Python 3.11.6 (/venv/bin/python3)
PsUtil 5.9.7 (/venv/lib/python3.11/site-packages/psutil/__init__.py)
===============================================================================
alert         [OK]    0.00003s
[]
amps          [OK]    0.00017s
[]
cloud         [OK]    0.00012s
{}
connections   [OK]    0.16311s
{'ESTABLISHED': 11,
'LISTEN': 69,
'SYN_RECV': 0,
'SYN_SENT': 0,
'initiated': 0,
'net_connections_enabled': True,
'nf_conntrack_count': 632.0,
'nf_conntrack_enabled': True,
'nf_conntrack_max': 65536.0,
'nf_conntrack_percent': 0.96435546875,
'terminated': 0}
containers    [OK]    0.38540s key=name
[{'Command': ['/init'],
 'Created': '2024-01-12T13:51:39.626080575Z',
 'Id': '93e9b05e76382a98a14772e1cfc3edc579f2b7b60cf1f644bf9a473eacbe1885',
 'Image': ['lscr.io/linuxserver/bazarr:latest'],
 'Status': 'running',
 'Uptime': '3 hours',
 'cpu_percent': 0.204079822616408,
 'engine': 'docker',
 'io_r': 0,
 'io_w': 0,
 'key': 'name',
 'memory_usage': None,
 'name': 'bazarr',
 'network_rx': 211,
 'network_tx': 234}, ...]
core          [OK]    0.00203s
{'log': 4, 'phys': 4}
cpu           [OK]    0.00129s
{'cpucore': 4,
'ctx_switches': 25734,
'guest': 0.0,
'guest_nice': 0.0,
'idle': 81.4,
'interrupts': 13638,
'iowait': 0.2,
'irq': 0.0,
'nice': 0.0,
'soft_interrupts': 3743,
'softirq': 0.1,
'steal': 0.0,
'syscalls': 0,
'system': 6.4,
'time_since_update': 3.1857519149780273,
'total': 21.1,
'user': 11.8}
diskio        [OK]    0.00217s key=disk_name
[{'disk_name': 'loop0',
 'key': 'disk_name',
 'read_bytes': 0,
 'read_count': 0,
 'time_since_update': 2.5759873390197754,
 'write_bytes': 0,
 'write_count': 0}, ...]
folders       [OK]    0.00013s
[]
fs            [OK]    0.00174s key=mnt_point
[{'device_name': '/dev/mmcblk0p2',
 'free': 94169124864,
 'fs_type': 'ext4',
 'key': 'mnt_point',
 'mnt_point': '/etc/os-release',
 'percent': 20.8,
 'size': 125229076480,
 'used': 24678719488}, ...]
gpu           [OK]    0.00012s
[]
help          [OK]    0.00001s
None
ip            [OK]    0.00241s
{'address': '***',
'gateway': '***',
'mask': '***',
'mask_cidr': '***',
'public_address': '***',
'public_info_human': '***'}
irq           [OK]    0.00161s key=irq_line
[{'irq_line': '11_arch_timer', 'irq_rate': 8948, 'key': 'irq_line', 'time_since_update': 3.1986007690429688}, ...]
load          [OK]    0.00013s
{'cpucore': 4, 'min1': 0.69384765625, 'min15': 0.88525390625, 'min5': 0.884765625}
mem           [OK]    0.00080s
{'active': 1264648192,
'available': 1797869568,
'buffers': 18862080,
'cached': 1800753152,
'free': 1797869568,
'inactive': 1535139840,
'percent': 54.8,
'shared': 65761280,
'total': 3977527296,
'used': 2179657728}
memswap       [OK]    0.00107s
{'free': 1716133888,
'percent': 20.1,
'sin': 148045824,
'sout': 565411840,
'time_since_update': 4.142237424850464,
'total': 2147479552,
'used': 431345664}
network       [OK]    0.00638s key=interface_name
[{'alias': None,
 'cumulative_cx': 234142,
 'cumulative_rx': 117071,
 'cumulative_tx': 117071,
 'cx': 0,
 'interface_name': 'lo',
 'is_up': True,
 'key': 'interface_name',
 'rx': 0,
 'speed': 0,
 'time_since_update': 2.586322546005249,
 'tx': 0}, ...]
now           [OK]    0.00011s
'2024-01-26 20:20:30 AEDT'
percpu        [OK]    0.00122s key=cpu_number
[{'cpu_number': 0,
 'guest': 0.0,
 'guest_nice': 0.0,
 'idle': 88.0,
 'iowait': 0.2,
 'irq': 0.0,
 'key': 'cpu_number',
 'nice': 0.0,
 'softirq': 0.2,
 'steal': 0.0,
 'system': 4.6,
 'total': 12.0,
 'user': 6.8}, ...]
ports         [OK]    0.00095s
[]
processcount  [OK]    0.71337s
{'pid_max': 0, 'running': 1, 'sleeping': 480, 'thread': 1954, 'total': 551}
processlist   [OK]    0.00191s key=pid
[{'cmdline': ['/venv/bin/python3', '-m', 'glances', '--issue'],
 'cpu_percent': 45.4,
 'cpu_times': pcputimes(user=3.48, system=1.56, children_user=0.31, children_system=0.73, iowait=0.0),
 'gids': pgids(real=0, effective=0, saved=0),
 'io_counters': [1826816, 143360, 1814528, 135168, 1],
 'key': 'pid',
 'memory_info': pmem(rss=46878720, vms=109756416, shared=12713984, text=4096, lib=0, data=89169920, dirty=0),
 'memory_percent': 1.1785895233740717,
 'name': 'python3',
 'nice': 0,
 'num_threads': 26,
 'pid': 170494,
 'status': 'R',
 'time_since_update': 4.138080596923828,
 'username': 'root'}, ...]
psutilversion [OK]    0.00011s
(5, 9, 7)
quicklook     [OK]    0.00208s
{'cpu': 21.1,
'cpu_hz': 1500000000.0,
'cpu_hz_current': 1500000000.0,
'cpu_name': '8',
'mem': 54.8,
'percpu': [{...}, {...}, {...}, {...}],
'swap': 20.1}
raid          [OK]    0.00037s
{}
sensors       [OK]    0.00002s key=label
[{'critical': 110,
 'key': 'label',
 'label': 'cpu_thermal 0',
 'type': 'temperature_core',
 'unit': 'C',
 'value': 58,
 'warning': 110}, ...]
smart         [OK]    1.08650s
[{'1': {...},
 '10': {...},
 '12': {...},
 '192': {...},
 '193': {...},
 '194': {...},
 '196': {...},
 '197': {...},
 '198': {...},
 '199': {...},
 '2': {...},
 '3': {...},
 '4': {...},
 '5': {...},
 '7': {...},
 '8': {...},
 '9': {...},
 'DeviceName': 'sda WDC WD80EDAZ-11TA3A0'}]
system        [OK]    0.00009s
{'hostname': 'raspberrypi',
'hr_name': 'Debian GNU/Linux 12 64bit',
'linux_distro': 'Debian GNU/Linux 12',
'os_name': 'Linux',
'os_version': '6.1.0-rpi7-rpi-v8',
'platform': '64bit'}
uptime        [OK]    0.00073s
{'seconds': 13655}
wifi          [OK]    0.00013s
[]
===============================================================================
Total time to update all stats: 2.40434s
===============================================================================
@nicolargo
Copy link
Owner

Hi @bdcarr

why do you run two Glances instances (server and client) ?

To export to InfluxDB, one single standalone instance should make the job.

Nicolas

@bdcarr
Copy link
Author

bdcarr commented Jan 27, 2024

Hi mate, it says export is only available in standalone or client mode. Standalone doesn't seem to work in docker:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/glances/__main__.py", line 18, in <module>
    glances.main()
  File "/app/glances/__init__.py", line 185, in main
    start(config=core.get_config(), args=core.get_args())
  File "/app/glances/__init__.py", line 108, in start
    mode = GlancesMode(config=config, args=args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/glances/standalone.py", line 106, in __init__
    self.screen = GlancesCursesStandalone(config=config, args=args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/glances/outputs/glances_curses.py", line 143, in __init__
    self.screen = curses.initscr()
                  ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/curses/__init__.py", line 29, in initscr
    setupterm(term=_os.environ.get("TERM", "unknown"),
_curses.error: setupterm: could not find terminal

@bdcarr
Copy link
Author

bdcarr commented Jan 27, 2024

I'd be stoked to be able to do this with one instance, as I'm running it on a Pi so resources are a bit precious.

@nicolargo
Copy link
Owner

Add the "-it" option to your Docker run command line in order to allow the local console from the container.

@bdcarr
Copy link
Author

bdcarr commented Jan 27, 2024

Oh beauty, I thought I already tried that but must've mucked it up. Adding interactive: true to my docker-compose has made it work in standalone mode. Thanks, that solves my use case at least 🙌

Repository owner locked and limited conversation to collaborators Jan 28, 2024
@nicolargo nicolargo converted this issue into discussion #2668 Jan 28, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants