~therve/landscape-client/network-plugin-reboot

« back to all changes in this revision

Viewing changes to landscape/monitor/networkactivity.py

  • Committer: Thomas Hervé
  • Date: 2010-08-16 13:47:37 UTC
  • Revision ID: thomas@canonical.com-20100816134737-23zjnw8adxp89246
Put back safeguard, handle packet rollover

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
                delta_in = traffic["recv_bytes"] - previous_in
69
69
                if not delta_out and not delta_in:
70
70
                    continue
 
71
                if delta_out < 0:
 
72
                    delta_out += self._rolloverunit
 
73
                if delta_in < 0:
 
74
                    delta_in += self._rolloverunit
71
75
                packets_delta_out = (
72
76
                    traffic["send_packets"] - previous_packet_out)
 
77
                if packets_delta_out < 0:
 
78
                    packets_delta_out += self._rolloverunit
73
79
                # 28 bytes is the minimum packet size, roughly
74
80
                if packets_delta_out * 28 > delta_out:
75
81
                    delta_out += self._rolloverunit
76
82
                packets_delta_in = (
77
83
                    traffic["recv_packets"] - previous_packet_in)
 
84
                if packets_delta_in < 0:
 
85
                    packets_delta_in += self._rolloverunit
78
86
                if packets_delta_in * 28 > delta_in:
79
87
                    delta_in += self._rolloverunit
80
88