提交 f3429c5e 编写于 作者: A Alessio Sergi

Handle crash when no gateway is available (offline machines)

上级 177c5342
......@@ -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'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册