mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-03 15:15:02 +03:00
Handle crash when no gateway is available (offline machines)
This commit is contained in:
parent
177c534254
commit
f3429c5e05
@ -118,7 +118,9 @@ class Plugin(GlancesPlugin):
|
||||
|
||||
# Build the string message
|
||||
for p in self.stats:
|
||||
if p['status'] is None:
|
||||
if p['host'] is None:
|
||||
status = 'None'
|
||||
elif p['status'] is None:
|
||||
status = 'Scanning'
|
||||
elif isinstance(p['status'], bool_type) and p['status'] is True:
|
||||
status = 'Open'
|
||||
|
@ -68,7 +68,10 @@ class GlancesPortsList(object):
|
||||
default_gateway = config.get_value(self._section, 'port_default_gateway', default='False')
|
||||
if default_gateway.lower().startswith('true') and netifaces_tag:
|
||||
new_port = {}
|
||||
new_port['host'] = netifaces.gateways()['default'][netifaces.AF_INET][0]
|
||||
try:
|
||||
new_port['host'] = netifaces.gateways()['default'][netifaces.AF_INET][0]
|
||||
except KeyError:
|
||||
new_port['host'] = None
|
||||
# ICMP
|
||||
new_port['port'] = 0
|
||||
new_port['description'] = 'DefaultGateway'
|
||||
|
Loading…
Reference in New Issue
Block a user