aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/monitor.py4
-rwxr-xr-xsrc/net_monitor8
2 files changed, 9 insertions, 3 deletions
diff --git a/src/monitor.py b/src/monitor.py
index 45464f0..5a2bcfe 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -208,17 +208,19 @@ class Monitor:
def get_traffic(self, iface, net=None):
"""Get traffic information"""
+ device_exists=False
if not net:
if not self.net:
self.readnet()
net = self.net
if iface in net:
+ device_exists=True
bytes_in = int(net[iface][0])
bytes_out = int(net[iface][8])
else:
bytes_in = 0
bytes_out = 0
- return bytes_in, bytes_out
+ return device_exists, bytes_in, bytes_out
def format_size(self, size, opt=""):
"""Pretty-Formats size"""
diff --git a/src/net_monitor b/src/net_monitor
index 5385fd3..650af0b 100755
--- a/src/net_monitor
+++ b/src/net_monitor
@@ -308,7 +308,7 @@ class MonitorGui:
net=self.monitor.readnet()
select_page=0
for iface in sorted_ifaces:
- data_in, data_out = self.monitor.get_traffic(iface,net)
+ device_exists, data_in, data_out = self.monitor.get_traffic(iface,net)
self.ifaces[iface] = {'data_in': 0,
'data_out': 0,
'total_in': 0,
@@ -384,7 +384,7 @@ class MonitorGui:
old_data_out = self.ifaces[iface]['data_out']
total_in = self.ifaces[iface]['total_in']
total_out = self.ifaces[iface]['total_out']
- data_in, data_out = self.monitor.get_traffic(iface, net)
+ device_exists, data_in, data_out = self.monitor.get_traffic(iface, net)
# is it a wireless interface?
if iface in self.wireless_ifaces:
essid = self.monitor.wifi_get_essid(iface)
@@ -411,6 +411,10 @@ class MonitorGui:
if old_data_in == 0 and old_data_out == 0:
old_data_in = data_in
old_data_out = data_out
+ # check if device exists
+ if not device_exists:
+ old_data_in = data_in
+ old_data_out = data_out
# check total download
diff_in = data_in - old_data_in
diff_out = data_out - old_data_out