Link Layer stats
Combiner for link layer stats. It uses the results of
the netstat -i
parser and the ip -s link
parser to determine the
network stats of link layer. ip -s link
is the preferred source
of data and return object which can be used to access group_by_iface
.
Examples
>>> type(nstat)
<class 'insights.combiners.netstat.NetworkStats'>
>>> stats = nstat.group_by_iface
>>> stats["lo"]
{'RX-OK': 98, 'TX-OK': 100, 'MTU': 65536, 'RX-ERR': 0, 'TX-DRP': 0, 'TX-ERR': 0, 'RX-DRP': 0, 'RX-OVR': 0, 'Flg': 'LRU'}
>>> stats["enp0s8"]
{'RX-OK': 6, 'TX-DRP': 0, 'TX-OK': 4, 'MTU': 1500, 'RX-ERR': 0, 'TX-ERR': 0, 'RX-DRP': 0, 'RX-OVR': 0, 'Flg': 'BMRU'}
>>> print nstat.data[0]['Iface']
enp0s8
>>> for dev_item in nstat.data:
>>> print dev_item
{'RX-OK': '842447', 'TX-OVR': '0', 'Iface': 'bond1', 'TX-OK': '4233', 'MTU': '1500', 'Met': '0', 'RX-ERR': '0', 'TX-DRP': '0', 'TX-ERR': '0', 'RX-DRP': '0', 'RX-OVR': '0', 'Flg': 'BMmRU'}
{'RX-OK': '422518', 'TX-OVR': '0', 'Iface': 'eth0', 'TX-OK': '1703', 'MTU': '1500', 'Met': '0', 'RX-ERR': '0', 'TX-DRP': '0', 'TX-ERR': '0', 'RX-DRP': '0', 'RX-OVR': '0', 'Flg': 'BMsRU'}
...
...
- class insights.combiners.netstat.NetworkStats(net_stats, ip_stats)[source]
Bases:
object
A combiner for working with both
netstat -i
andip -s link
That is ifnetstat -i
gets deprecated then we can continue withip -s link
.This interface closely follow interface Netstat_I it has following Attributes:
- group_by_iface
This property returns network stats organised per interface in dict format.
- Type:
dict
- data
List of network stats as per devices.
- Type:
list