def output(self): """Print out the current status of this monitor object This will print the current traffic to stdout. """ util.clear() entries = sorted(self.entries.get_traffic()) for bytes_in, bytes_out, cmd in entries: if bytes_in or bytes_out: if len(cmd) > 60: cmd = cmd[:57] + '...' print '%10d / %10d -- %s' % (bytes_in, bytes_out, cmd) sys.stdout.flush()
def output(self): """Print the current bandwidth usage to the console The output is (by default) grouped by apps. The columns in the output: BYTES_IN, BYTES_OUT, APP NAME """ util.clear() for (cmd, (bytes_in, bytes_out)) in self.apps.iteritems(): if bytes_in > 1024. or bytes_out > 1024.: if len(cmd) > 60: cmd = cmd[:57] + '...' print '%10.2f KiB / %10.2f KiB -- %s' % (bytes_in/1024., bytes_out/1024., cmd) sys.stdout.flush()
def output(self, mode=TRAFFIC): """Print the current status to standard output @param mode: Monitoring mode (BANDWIDTH or TRAFFIC [=default]) """ util.clear() if mode == TRAFFIC: entries = sorted(self.entries.get_traffic()) else: entries = sorted(self.entries.get_usage()) for bytes_in, bytes_out, cmd in entries: if bytes_in or bytes_out: if len(cmd) > 60: cmd = cmd[:57] + '...' print '%10d / %10d -- %s' % (bytes_in, bytes_out, cmd) sys.stdout.flush()