瀏覽代碼

Merge pull request #2276 from amoghe/amoghe_dest_stats

Add destination stats extraction to IPVS library
Christopher Adam Telfer 6 年之前
父節點
當前提交
466225b792
共有 2 個文件被更改,包括 10 次插入0 次删除
  1. 4 0
      libnetwork/ipvs/ipvs.go
  2. 6 0
      libnetwork/ipvs/netlink.go

+ 4 - 0
libnetwork/ipvs/ipvs.go

@@ -62,8 +62,12 @@ type Destination struct {
 	LowerThreshold      uint32
 	ActiveConnections   int
 	InactiveConnections int
+	Stats               DstStats
 }
 
+// DstStats defines IPVS destination (real server) statistics
+type DstStats SvcStats
+
 // Handle provides a namespace specific ipvs handle to program ipvs
 // rules.
 type Handle struct {

+ 6 - 0
libnetwork/ipvs/netlink.go

@@ -443,6 +443,12 @@ func assembleDestination(attrs []syscall.NetlinkRouteAttr) (*Destination, error)
 			d.ActiveConnections = int(native.Uint16(attr.Value))
 		case ipvsDestAttrInactiveConnections:
 			d.InactiveConnections = int(native.Uint16(attr.Value))
+		case ipvsSvcAttrStats:
+			stats, err := assembleStats(attr.Value)
+			if err != nil {
+				return nil, err
+			}
+			d.Stats = DstStats(stats)
 		}
 	}
 	return &d, nil