network monitoring

Monitor and collect network interface statistics, bandwidth usage, and connection information.

source

get_network_info

 get_network_info ()

Get network interface information and statistics.

get_network_info()
{'interfaces': [{'name': 'enp7s0',
   'ip_addresses': ['192.168.2.41'],
   'bytes_sent': 111225724,
   'bytes_recv': 1464784754,
   'packets_sent': 337446,
   'packets_recv': 1368159,
   'bytes_sent_per_sec': 0,
   'bytes_recv_per_sec': 0,
   'errors_in': 0,
   'errors_out': 0,
   'drops_in': 0,
   'drops_out': 0},
  {'name': 'enp8s0',
   'ip_addresses': [],
   'bytes_sent': 0,
   'bytes_recv': 0,
   'packets_sent': 0,
   'packets_recv': 0,
   'bytes_sent_per_sec': 0,
   'bytes_recv_per_sec': 0,
   'errors_in': 0,
   'errors_out': 0,
   'drops_in': 0,
   'drops_out': 0},
  {'name': 'wlp15s0',
   'ip_addresses': [],
   'bytes_sent': 0,
   'bytes_recv': 0,
   'packets_sent': 0,
   'packets_recv': 0,
   'bytes_sent_per_sec': 0,
   'bytes_recv_per_sec': 0,
   'errors_in': 0,
   'errors_out': 0,
   'drops_in': 0,
   'drops_out': 0},
  {'name': 'docker0',
   'ip_addresses': ['172.17.0.1'],
   'bytes_sent': 0,
   'bytes_recv': 0,
   'packets_sent': 0,
   'packets_recv': 0,
   'bytes_sent_per_sec': 0,
   'bytes_recv_per_sec': 0,
   'errors_in': 0,
   'errors_out': 0,
   'drops_in': 0,
   'drops_out': 52}],
 'connections': {'total': 313,
  'established': 199,
  'listen': 80,
  'time_wait': 24,
  'close_wait': 3}}
NETWORK_STATS_CACHE
{'enp7s0': {'bytes_sent': 111225724,
  'bytes_recv': 1464784754,
  'time': 1759281450.9512415},
 'enp8s0': {'bytes_sent': 0, 'bytes_recv': 0, 'time': 1759281450.9512415},
 'wlp15s0': {'bytes_sent': 0, 'bytes_recv': 0, 'time': 1759281450.9512415},
 'docker0': {'bytes_sent': 0, 'bytes_recv': 0, 'time': 1759281450.9512415}}