MCPcopy Create free account
hub / github.com/prometheus/procfs / NetClass

Method NetClass

sysfs/net_class.go:112–130  ·  view source on GitHub ↗

NetClass returns info for all net interfaces (iface) read from /sys/class/net/ .

()

Source from the content-addressed store, hash-verified

110
111// NetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
112func (fs FS) NetClass() (NetClass, error) {
113 devices, err := fs.NetClassDevices()
114 if err != nil {
115 return nil, err
116 }
117
118 path := fs.sys.Path(netclassPath)
119 netClass := NetClass{}
120 for _, devicePath := range devices {
121 interfaceClass, err := parseNetClassIface(filepath.Join(path, devicePath))
122 if err != nil {
123 return nil, err
124 }
125 interfaceClass.Name = devicePath
126 netClass[devicePath] = *interfaceClass
127 }
128
129 return netClass, nil
130}
131
132// canIgnoreError returns true if the error is non-fatal and can be ignored.
133// Some kernels and some devices don't expose specific attributes or return

Callers 1

TestNetClassFunction · 0.95

Calls 3

NetClassDevicesMethod · 0.95
parseNetClassIfaceFunction · 0.85
PathMethod · 0.45

Tested by 1

TestNetClassFunction · 0.76