#!/usr/bin/env python3

import re
import sys

if len(sys.argv) < 2:
    print('Usage: python script.py <input>')
    sys.exit(1)

input_arg = sys.argv[1]

with open(input_arg, 'r') as f:
    content = f.read()

print("========================")
print("file : %s" % (input_arg))


rx_pattern = r'enp(\S+)\s+\S+\s+:\s+RX\s+(\d+\.\d+)\s+Gbps'
rx_rates = re.findall(rx_pattern, content)

for i in range(len(rx_rates) // 2):
    bond_name, rx1 = rx_rates[i * 2]
    _, rx2 = rx_rates[i * 2 + 1]
    rx_diff = float(rx2) - float(rx1)
    if abs(rx_diff) > 2 :
        print("%s: RX bandwidth difference = %.2f Gbps" %(bond_name, rx_diff))
