Skip to content

Commit

Permalink
Merge branch 'issue3055' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolargo committed Dec 30, 2024
2 parents dd93371 + c027005 commit 1588375
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Optional dependencies:
- ``influxdb-client`` (for the InfluxDB version 2 export module)
- ``jinja2`` (for templating, used under the hood by FastAPI)
- ``kafka-python`` (for the Kafka export module)
- ``netifaces-plus`` (for the IP plugin)
- ``netifaces2`` (for the IP plugin)
- ``nvidia-ml-py`` (for the GPU plugin)
- ``pycouchdb`` (for the CouchDB export module)
- ``pika`` (for the RabbitMQ/ActiveMQ export module)
Expand Down
5 changes: 1 addition & 4 deletions docker-files/alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
# WARNING: the Alpine image version and Python version should be set.
# Alpine 3.18 tag is a link to the latest 3.18.x version.
# Be aware that if you change the Alpine version, you may have to change the Python version.

# Netifaces (and Netifaces-plus) are not compliant with GCC embeded in Alpine 3.21
# See: https://github.com/tsukumijima/netifaces-plus/issues/9
ARG IMAGE_VERSION=3.20
ARG IMAGE_VERSION=3.21
ARG PYTHON_VERSION=3.12

##############################################################################
Expand Down
4 changes: 2 additions & 2 deletions glances/plugins/ip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, args=None, config=None):
def get_private_ip(self, stats, stop=False):
# Get the default gateway thanks to the netifaces lib
try:
default_gw = netifaces.gateways()['default'][netifaces.AF_INET]
default_gw = netifaces.gateways()[netifaces.AF_INET][0]
except (KeyError, AttributeError) as e:
logger.debug(f"Cannot grab default gateway IP address ({e})")
stop = True
Expand All @@ -99,7 +99,7 @@ def get_private_ip(self, stats, stop=False):

def get_first_ip(self, stats, stop=False):
try:
default_gw = netifaces.gateways()['default'][netifaces.AF_INET]
default_gw = netifaces.gateways()[netifaces.AF_INET][0]
address = netifaces.ifaddresses(default_gw[1])[netifaces.AF_INET][0]['addr']
mask = netifaces.ifaddresses(default_gw[1])[netifaces.AF_INET][0]['netmask']
except (KeyError, AttributeError) as e:
Expand Down
2 changes: 1 addition & 1 deletion glances/ports_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def load(self, config):
if default_gateway.lower().startswith('true') and netifaces_tag:
new_port = {}
try:
new_port['host'] = netifaces.gateways()['default'][netifaces.AF_INET][0]
new_port['host'] = netifaces.gateways()[netifaces.AF_INET][0][0]
except KeyError:
new_port['host'] = None
# ICMP
Expand Down
2 changes: 1 addition & 1 deletion glances/servers_list_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def find_active_ip_address():
import netifaces

# Interface of the default gateway
gateway_itf = netifaces.gateways()['default'][netifaces.AF_INET][1]
gateway_itf = netifaces.gateways()[netifaces.AF_INET][0][1]
# IP address for the interface
return netifaces.ifaddresses(gateway_itf)[netifaces.AF_INET][0]['addr']

Expand Down
2 changes: 1 addition & 1 deletion optional-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ influxdb>=1.0.0 # For InfluxDB < 1.8
influxdb-client # For InfluxDB >= 1.8
jinja2
kafka-python
netifaces-plus
netifaces2
nvidia-ml-py
orjson
paho-mqtt
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export = [
]
gpu = ["nvidia-ml-py"]
graph = ["pygal"]
ip = ["netifaces-plus"]
ip = ["netifaces2"]
raid = ["pymdstat"]
sensors = ["batinfo; platform_system == 'Linux'"]
smart = ["pySMART.smartx"]
Expand Down

0 comments on commit 1588375

Please sign in to comment.