mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
B #1566: Support new predictable NIC names in KVM host net monitoring
This commit is contained in:
parent
9489286fe4
commit
94f26ce0f2
@ -67,7 +67,27 @@ $free_memory = $total_memory - $used_memory
|
||||
######
|
||||
# INTERFACE
|
||||
######
|
||||
NETINTERFACE = "eth|bond|em|enp|p[0-9]+p[0-9]+"
|
||||
|
||||
NETINTERFACE = [
|
||||
'eth[0-9]+',
|
||||
'ib[0-9]+',
|
||||
|
||||
# --- BIOS derived names:
|
||||
'em[0-9]+(_[0-9]+)?',
|
||||
'p[0-9]+p[0-9]+(_[0-9]+)?',
|
||||
|
||||
# --- Systemd naming - type of names for en*:
|
||||
# o<index>[n<phys_port_name>|d<dev_port>] — on-board device index number
|
||||
# s<slot>[f<function>][n<phys_port_name>|d<dev_port>] — hotplug slot index number
|
||||
# x<MAC> — MAC address
|
||||
# [P<domain>]p<bus>s<slot>[f<function>][n<phys_port_name>|d<dev_port>] — PCI geographical location
|
||||
# a<vendor><model>i<instance> — Platform bus ACPI instance id
|
||||
'eno[0-9]+(n[0-9a-zA-Z]+|d[0-9]+)?',
|
||||
'ens[0-9]+(f[0-9]+)?(n[0-9a-zA-Z]+|d[0-9]+)?',
|
||||
'enx[0-9a-fA-F]{12}',
|
||||
'en(P[0-9]+)?p[0-9]+s[0-9]+(f[0-9]+)?(n[0-9a-zA-Z]+|d[0-9]+)?',
|
||||
'ena[0-9a-zA-Z]+i[0-9]+',
|
||||
].join('|')
|
||||
|
||||
net_text=`cat /proc/net/dev`
|
||||
exit(-1) if $?.exitstatus != 0
|
||||
@ -76,7 +96,7 @@ $netrx = 0
|
||||
$nettx = 0
|
||||
|
||||
net_text.split(/\n/).each{|line|
|
||||
if line.match("^ *#{NETINTERFACE}")
|
||||
if line.match("^ *(#{NETINTERFACE}):")
|
||||
arr = line.split(":")[1].split(" ")
|
||||
$netrx += arr[0].to_i
|
||||
$nettx += arr[8].to_i
|
||||
|
Loading…
x
Reference in New Issue
Block a user