nicolargo / glances

Glances an Eye on your system. A top/htop alternative for GNU/Linux, BSD, Mac OS and Windows operating systems.
http://nicolargo.github.io/glances/
Other
26.77k stars 1.53k forks source link

No module named 'influxdb' on the snap version of glances #1738

Closed gbonazzoli closed 5 months ago

gbonazzoli commented 4 years ago

Description

I'm using the snap version of glances on Oracle Linux 8.2, in order to keep the operating system as clean as possible from package installation.

glances goes like a charm but I can not load an influxdb database withe the metrics collected.

[root@dblinux 902]# glances -C/root/glances.conf --export influxdb
Traceback (most recent call last):
  File "/snap/glances/902/bin/glances", line 33, in <module>
    sys.exit(load_entry_point('Glances==3.1.5', 'console_scripts', 'glances')())
  File "/snap/glances/902/lib/python3.5/site-packages/glances/__init__.py", line 143, in main
    start(config=config, args=args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/__init__.py", line 108, in start
    mode = GlancesMode(config=config, args=args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/standalone.py", line 51, in __init__
    self.stats = GlancesStats(config=config, args=args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/stats.py", line 48, in __init__
    self.load_modules(self.args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/stats.py", line 103, in load_modules
    self.load_exports(args=args)
  File "/snap/glances/902/lib/python3.5/site-packages/glances/stats.py", line 178, in load_exports
    export_module = __import__(self._exports_all[export_name])
  File "/snap/glances/902/lib/python3.5/site-packages/glances/exports/glances_influxdb.py", line 27, in <module>
    from influxdb import InfluxDBClient
ImportError: No module named 'influxdb'

I think it is only a problem on how the snap package is fullfilled.

Any chance to have an official snap with the functionality on board ?

Versions

[root@dblinux 902]# snap list
Name      Version        Rev    Tracking       Publisher    Notes
glances   3.1.5          902    latest/stable  nicolargo    -

[root@dblinux 902]# glances -V
Glances v3.1.5 with PsUtil v5.7.2
Log file: /root/snap/glances/902/.cache/glances/glances.log
nicolargo commented 4 years ago

@Lin-Buo-Ren What do you think of this request ? Is there a simple and good way to include Glances extra module in the default Snap ? Or is it better to create a new "Glances-Full" Snap ?

brlin-tw commented 4 years ago

I'd say we bundle all deps in one package. Will check it out.

gbonazzoli commented 4 years ago

@Lin-Buo-Ren In my opinion "bundle all deps in one snap package" is the right way.

No confusion at all for end users, also for those that want only to give "glances" a try before doing a full installation sorting out the extra-weight of the snap.

nicolargo commented 4 years ago

Ok...

@Lin-Buo-Ren any availability to contribute to this issue ?

akrea commented 3 years ago

Hello everybody

I have the same problem. It was working fine until the "latest version" of the docker-image was pulled on January, 24 2021. Following all the details:

docker-compose

glancesEXPORT:
        image: nicolargo/glances:latest
        container_name: glancesEXPORT
        restart: unless-stopped
        privileged: true
        networks:
            - t2_proxy
            - socket_proxy
        depends_on:
            - socket-proxy
        security_opt:
            - no-new-privileges:true
        pid: host
        volumes:
            - $USERDIR/glances/conf:/glances/conf/ # Use this if you want to add a glances.conf file
        environment:
          GLANCES_OPT: "-C /glances/conf/glances.conf --quiet --export influxdb"
          DOCKER_HOST: tcp://socket-proxy:2375

Since 24th same error message as above:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/glances/__main__.py", line 29, in <module>
    glances.main()
  File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 145, in main
    start(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 110, in start
    mode = GlancesMode(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/standalone.py", line 51, in __init__
    self.stats = GlancesStats(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 48, in __init__
    self.load_modules(self.args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 103, in load_modules
    self.load_exports(args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 178, in load_exports
    export_module = __import__(self._exports_all[export_name])
  File "/usr/local/lib/python3.9/site-packages/glances/exports/glances_influxdb.py", line 27, in <module>
    from influxdb import InfluxDBClient
ModuleNotFoundError: No module named 'influxdb'

Versions differ though:

root@835ce63e4375:/glances# glances -V
Glances v3.1.6.1 with PsUtil v5.8.0
akrea commented 3 years ago

its me again.

I also tried to change the glances.conf to:

[influxdb]
host=localhost
port=8086
protocol=http
org=nicolargo
bucket=glances
token=EjFUTWe8U-MIseEAkaVIgVnej_TrnbdvEcRkaB1imstW7gapSqy6_6-8XD-yd51V0zUUpDy-kAdVD1purDLuxA==
# Prefix will be added for all measurement name
# Ex: prefix=foo
#     => foo.cpu
#     => foo.mem
# You can also use dynamic values
#prefix=`hostname`
prefix=localhost
# Tags will be added for all measurements
#tags=foo:bar,spam:eggs
# You can also use dynamic values
#tags=system:`uname -s`

as given in the documenation. I do have

X-Influxdb-Build: OSS
X-Influxdb-Version: 1.8.3

but then I get:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/glances/__main__.py", line 29, in <module>
    glances.main()
  File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 145, in main
    start(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/__init__.py", line 110, in start
    mode = GlancesMode(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/standalone.py", line 51, in __init__
    self.stats = GlancesStats(config=config, args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 48, in __init__
    self.load_modules(self.args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 103, in load_modules
    self.load_exports(args=args)
  File "/usr/local/lib/python3.9/site-packages/glances/stats.py", line 178, in load_exports
    export_module = __import__(self._exports_all[export_name])
  File "/usr/local/lib/python3.9/site-packages/glances/exports/glances_influxdb2.py", line 27, in <module>
    from influxdb_client import InfluxDBClient, WriteOptions
ModuleNotFoundError: No module named 'influxdb_client?'
nicolargo commented 1 year ago

@gbonazzoli Can you give a chance to the latest Glances version 3.4.0.1 available in SNAP,

gbonazzoli commented 1 year ago

@nicolargo

Installation OK on Ubuntu 22.04:

root@empire:~# snap list
Name     Version       Rev    Tracking         Publisher   Notes
glances  3.4.0.1       1497   latest/stable    nicolargo   -
snapd    2.59.2        19122  latest/stable    canonical✓  snapd

Still have some problems with influxdb:

root@empire:~# glances --export influxdb
Traceback (most recent call last):
  File "/snap/glances/1497/bin/glances", line 8, in <module>
    sys.exit(main())
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/__init__.py", line 180, in main
    start(config=core.get_config(), args=core.get_args())
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/__init__.py", line 108, in start
    mode = GlancesMode(config=config, args=args)
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/standalone.py", line 44, in __init__
    self.stats = GlancesStats(config=config, args=args)
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/stats.py", line 39, in __init__
    self.load_modules(self.args)
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/stats.py", line 90, in load_modules
    self.load_exports(args=args)
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/stats.py", line 162, in load_exports
    export_module = __import__(self._exports_all[export_name])
  File "/snap/glances/1497/lib/python3.8/site-packages/glances/exports/glances_influxdb.py", line 18, in <module>
    from influxdb import InfluxDBClient
ModuleNotFoundError: No module named 'influxdb'
nicolargo commented 1 year ago

Related issue: https://github.com/nicolargo/glances/issues/2413

nicolargo commented 6 months ago

For the moment package only include requirements.txt, not optional-requirements.txt: https://github.com/nicolargo/glances/blob/develop/snap/snapcraft.yaml#L49