Commit 27895ee0 authored by Mario Hock's avatar Mario Hock
Browse files

--nics now accepts nics that are not there

for scenarios where nics come and go, e.g. autologging
parent 020c5f3a
...@@ -243,7 +243,7 @@ if __name__ == "__main__": ...@@ -243,7 +243,7 @@ if __name__ == "__main__":
## NICs ## NICs
monitored_nics = nics monitored_nics = nics
if ( args.nics ): if ( args.nics ):
assert( set(nics).issuperset(args.nics) ) #assert( set(nics).issuperset(args.nics) )
monitored_nics = args.nics monitored_nics = args.nics
## --autologging implies --logging ## --autologging implies --logging
......
...@@ -172,11 +172,14 @@ class MeasurementLogger: ...@@ -172,11 +172,14 @@ class MeasurementLogger:
def _log_nics(self, measurement, out_vector): def _log_nics(self, measurement, out_vector):
for nic in self.nics: for nic in self.nics:
try:
values = measurement.net_io[nic] values = measurement.net_io[nic]
out_vector.extend( [values.ratio["bytes_sent"] * 8, # Bits/s out_vector.extend( [values.ratio["bytes_sent"] * 8, # Bits/s
values.ratio["bytes_recv"] * 8] ) # Bits/s values.ratio["bytes_recv"] * 8] ) # Bits/s
except KeyError:
## TODO: is 0 a good value to log, in this case?
out_vector.extend( (0, 0) )
def log(self, measurement): def log(self, measurement):
...@@ -370,10 +373,13 @@ class LoggingManager: ...@@ -370,10 +373,13 @@ class LoggingManager:
def _is_activity_on_nics(self, measurement): def _is_activity_on_nics(self, measurement):
for nic in self.nics: for nic in self.nics:
try:
values = measurement.net_io[nic] values = measurement.net_io[nic]
if ( values.ratio["bytes_sent"] > 0 or values.ratio["bytes_recv"] > 0 ): if ( values.ratio["bytes_sent"] > 0 or values.ratio["bytes_recv"] > 0 ):
return True return True
except KeyError:
pass
return False return False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment