Selaa lähdekoodia

Merge pull request #2258 from Lion-Wei/master

Support getting active/inactive IPVS connection counts
Christopher Adam Telfer 7 vuotta sitten
vanhempi
commit
556f9f1348
2 muutettua tiedostoa jossa 13 lisäystä ja 7 poistoa
  1. 9 7
      libnetwork/ipvs/ipvs.go
  2. 4 0
      libnetwork/ipvs/netlink.go

+ 9 - 7
libnetwork/ipvs/ipvs.go

@@ -53,13 +53,15 @@ type SvcStats struct {
 // Destination defines an IPVS destination (real server) in its
 // entirety.
 type Destination struct {
-	Address         net.IP
-	Port            uint16
-	Weight          int
-	ConnectionFlags uint32
-	AddressFamily   uint16
-	UpperThreshold  uint32
-	LowerThreshold  uint32
+	Address             net.IP
+	Port                uint16
+	Weight              int
+	ConnectionFlags     uint32
+	AddressFamily       uint16
+	UpperThreshold      uint32
+	LowerThreshold      uint32
+	ActiveConnections   int
+	InactiveConnections int
 }
 
 // Handle provides a namespace specific ipvs handle to program ipvs

+ 4 - 0
libnetwork/ipvs/netlink.go

@@ -439,6 +439,10 @@ func assembleDestination(attrs []syscall.NetlinkRouteAttr) (*Destination, error)
 			d.LowerThreshold = native.Uint32(attr.Value)
 		case ipvsDestAttrAddressFamily:
 			d.AddressFamily = native.Uint16(attr.Value)
+		case ipvsDestAttrActiveConnections:
+			d.ActiveConnections = int(native.Uint16(attr.Value))
+		case ipvsDestAttrInactiveConnections:
+			d.InactiveConnections = int(native.Uint16(attr.Value))
 		}
 	}
 	return &d, nil