MCPcopy Create free account
hub / github.com/OpenSN-Library/OpenSN-Library / GetInstanceLinkResourceInfo

Function GetInstanceLinkResourceInfo

daemon/utils/monitor.go:212–234  ·  view source on GitHub ↗
(pid int)

Source from the content-addressed store, hash-verified

210}
211
212func GetInstanceLinkResourceInfo(pid int) (map[string]*LinkResourceRaw, error) {
213 ret := make(map[string]*LinkResourceRaw)
214 filePath := fmt.Sprintf("/proc/%d/net/dev", pid)
215 devStat, err := net.IOCountersByFile(true, filePath)
216 if err != nil {
217 errMsg := fmt.Sprintf("Get Instance Link Resource Error: %s", err.Error())
218 logrus.Warn(errMsg)
219 return ret, err
220 }
221 for _, v := range devStat {
222 ret[v.Name] = &LinkResourceRaw{
223 RecvByte: v.BytesRecv,
224 SendByte: v.BytesSent,
225 RecvPack: v.PacketsRecv,
226 SendPack: v.PacketsSent,
227 SendErrPack: v.Errout,
228 RecvErrPack: v.Errin,
229 RecvDropPack: v.Dropin,
230 SendDropPack: v.Dropout,
231 }
232 }
233 return ret, nil
234}
235
236func GetAllLinkResourceInfo() (map[string]*LinkResourceRaw, error) {
237 ret := make(map[string]*LinkResourceRaw)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected