parent
c67f14167c
commit
63b9e57ba4
|
@ -81,6 +81,7 @@ class Gadget(e.Gadget):
|
|||
|
||||
in_perc = int(kb_in / 1000 * 100) # TODO CONFIGURABLE MAX
|
||||
out_perc = int(kb_out / 1000 * 100) # TODO CONFIGURABLE MAX
|
||||
|
||||
for obj in self._instances:
|
||||
obj.message_send(1, (0, in_perc, 0, 0, out_perc, 0))
|
||||
|
||||
|
@ -91,25 +92,21 @@ class Gadget(e.Gadget):
|
|||
return ecore.ECORE_CALLBACK_RENEW
|
||||
|
||||
def parse_proc(self):
|
||||
tot_in = 0
|
||||
tot_out = 0
|
||||
for line in open("/proc/net/dev", "r").readlines()[2:]:
|
||||
vals = line.split(None, 3)
|
||||
tot_in += int(vals[1])
|
||||
tot_out += int(vals[2])
|
||||
|
||||
tot_in = tot_out = indiff = outdiff = 0
|
||||
for line in open("/proc/net/dev", "r").readlines():
|
||||
if ':' in line:
|
||||
vals = line.split()
|
||||
tot_in += int(vals[1])
|
||||
tot_out += int(vals[9])
|
||||
|
||||
curtime = time.time()
|
||||
timediff = curtime - self.last_time
|
||||
self.last_time = curtime
|
||||
|
||||
|
||||
indiff = 0
|
||||
if self.last_in > 0:
|
||||
indiff = tot_in - self.last_in
|
||||
self.last_in = tot_in
|
||||
|
||||
outdiff = 0
|
||||
if self.last_out > 0:
|
||||
outdiff = tot_out - self.last_out
|
||||
self.last_out = tot_out
|
||||
|
@ -122,6 +119,3 @@ class Gadget(e.Gadget):
|
|||
byte_per_second_out = outdiff / timediff
|
||||
|
||||
return byte_per_second_in, byte_per_second_out
|
||||
|
||||
# def format_mb(self, val):
|
||||
# return '{0:.0f} MB'.format(val / 1048576)
|
||||
|
|
Loading…
Reference in New Issue