summaryrefslogtreecommitdiffstats
path: root/glances/ports_list.py
diff options
context:
space:
mode:
authorAlessio Sergi <al3hex@gmail.com>2017-03-06 16:23:56 +0100
committerAlessio Sergi <al3hex@gmail.com>2017-03-06 16:23:56 +0100
commitf3429c5e0593706466eea3d639a508c004dc9251 (patch)
treeb3f7ee06f5e1880b456dc541cd2180a622f4585f /glances/ports_list.py
parent177c534254a52a3c5d6db176bc49701a030fb4f1 (diff)
Handle crash when no gateway is available (offline machines)
Diffstat (limited to 'glances/ports_list.py')
-rw-r--r--glances/ports_list.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/glances/ports_list.py b/glances/ports_list.py
index 77f7ec87..a97f8a30 100644
--- a/glances/ports_list.py
+++ b/glances/ports_list.py
@@ -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'