Merge pull request #22 from LK4D4/stats_add
Initial implementation of stats
This commit is contained in:
commit
daa13e48b1
9 changed files with 895 additions and 58 deletions
|
@ -233,3 +233,39 @@ func (s *apiServer) Events(r *types.EventsRequest, stream types.API_EventsServer
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *apiServer) GetStats(r *types.StatsRequest, stream types.API_GetStatsServer) error {
|
||||
e := containerd.NewEvent(containerd.StatsEventType)
|
||||
e.ID = r.Id
|
||||
s.sv.SendEvent(e)
|
||||
if err := <-e.Err; err != nil {
|
||||
if err == containerd.ErrContainerNotFound {
|
||||
return grpc.Errorf(codes.NotFound, err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
ue := containerd.NewEvent(containerd.UnsubscribeStatsEventType)
|
||||
ue.ID = e.ID
|
||||
ue.Stats = e.Stats
|
||||
s.sv.SendEvent(ue)
|
||||
if err := <-ue.Err; err != nil {
|
||||
logrus.Errorf("Error unsubscribing %s: %v", r.Id, err)
|
||||
}
|
||||
}()
|
||||
for {
|
||||
select {
|
||||
case st := <-e.Stats:
|
||||
pbSt, ok := st.(*types.Stats)
|
||||
if !ok {
|
||||
panic("invalid stats type from collector")
|
||||
}
|
||||
if err := stream.Send(pbSt); err != nil {
|
||||
return err
|
||||
}
|
||||
case <-stream.Context().Done():
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -33,6 +33,18 @@ It has these top-level messages:
|
|||
UpdateContainerResponse
|
||||
EventsRequest
|
||||
Event
|
||||
NetworkStats
|
||||
CpuUsage
|
||||
ThrottlingData
|
||||
CpuStats
|
||||
MemoryData
|
||||
MemoryStats
|
||||
BlkioStatsEntry
|
||||
BlkioStats
|
||||
HugetlbStats
|
||||
CgroupStats
|
||||
Stats
|
||||
StatsRequest
|
||||
*/
|
||||
package types
|
||||
|
||||
|
@ -373,6 +385,291 @@ func (m *Event) GetCheckpoint() *Checkpoint {
|
|||
return nil
|
||||
}
|
||||
|
||||
type NetworkStats struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
||||
RxBytes uint64 `protobuf:"varint,2,opt,name=rx_bytes" json:"rx_bytes,omitempty"`
|
||||
Rx_Packets uint64 `protobuf:"varint,3,opt,name=rx_Packets" json:"rx_Packets,omitempty"`
|
||||
RxErrors uint64 `protobuf:"varint,4,opt,name=Rx_errors" json:"Rx_errors,omitempty"`
|
||||
RxDropped uint64 `protobuf:"varint,5,opt,name=Rx_dropped" json:"Rx_dropped,omitempty"`
|
||||
TxBytes uint64 `protobuf:"varint,6,opt,name=Tx_bytes" json:"Tx_bytes,omitempty"`
|
||||
TxPackets uint64 `protobuf:"varint,7,opt,name=Tx_packets" json:"Tx_packets,omitempty"`
|
||||
TxErrors uint64 `protobuf:"varint,8,opt,name=Tx_errors" json:"Tx_errors,omitempty"`
|
||||
TxDropped uint64 `protobuf:"varint,9,opt,name=Tx_dropped" json:"Tx_dropped,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NetworkStats) Reset() { *m = NetworkStats{} }
|
||||
func (m *NetworkStats) String() string { return proto.CompactTextString(m) }
|
||||
func (*NetworkStats) ProtoMessage() {}
|
||||
func (*NetworkStats) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{24} }
|
||||
|
||||
type CpuUsage struct {
|
||||
TotalUsage uint64 `protobuf:"varint,1,opt,name=total_usage" json:"total_usage,omitempty"`
|
||||
PercpuUsage []uint64 `protobuf:"varint,2,rep,name=percpu_usage" json:"percpu_usage,omitempty"`
|
||||
UsageInKernelmode uint64 `protobuf:"varint,3,opt,name=usage_in_kernelmode" json:"usage_in_kernelmode,omitempty"`
|
||||
UsageInUsermode uint64 `protobuf:"varint,4,opt,name=usage_in_usermode" json:"usage_in_usermode,omitempty"`
|
||||
}
|
||||
|
||||
func (m *CpuUsage) Reset() { *m = CpuUsage{} }
|
||||
func (m *CpuUsage) String() string { return proto.CompactTextString(m) }
|
||||
func (*CpuUsage) ProtoMessage() {}
|
||||
func (*CpuUsage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{25} }
|
||||
|
||||
type ThrottlingData struct {
|
||||
Periods uint64 `protobuf:"varint,1,opt,name=periods" json:"periods,omitempty"`
|
||||
ThrottledPeriods uint64 `protobuf:"varint,2,opt,name=throttled_periods" json:"throttled_periods,omitempty"`
|
||||
ThrottledTime uint64 `protobuf:"varint,3,opt,name=throttled_time" json:"throttled_time,omitempty"`
|
||||
}
|
||||
|
||||
func (m *ThrottlingData) Reset() { *m = ThrottlingData{} }
|
||||
func (m *ThrottlingData) String() string { return proto.CompactTextString(m) }
|
||||
func (*ThrottlingData) ProtoMessage() {}
|
||||
func (*ThrottlingData) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{26} }
|
||||
|
||||
type CpuStats struct {
|
||||
CpuUsage *CpuUsage `protobuf:"bytes,1,opt,name=cpu_usage" json:"cpu_usage,omitempty"`
|
||||
ThrottlingData *ThrottlingData `protobuf:"bytes,2,opt,name=throttling_data" json:"throttling_data,omitempty"`
|
||||
}
|
||||
|
||||
func (m *CpuStats) Reset() { *m = CpuStats{} }
|
||||
func (m *CpuStats) String() string { return proto.CompactTextString(m) }
|
||||
func (*CpuStats) ProtoMessage() {}
|
||||
func (*CpuStats) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{27} }
|
||||
|
||||
func (m *CpuStats) GetCpuUsage() *CpuUsage {
|
||||
if m != nil {
|
||||
return m.CpuUsage
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CpuStats) GetThrottlingData() *ThrottlingData {
|
||||
if m != nil {
|
||||
return m.ThrottlingData
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MemoryData struct {
|
||||
Usage uint64 `protobuf:"varint,1,opt,name=usage" json:"usage,omitempty"`
|
||||
MaxUsage uint64 `protobuf:"varint,2,opt,name=max_usage" json:"max_usage,omitempty"`
|
||||
Failcnt uint64 `protobuf:"varint,3,opt,name=failcnt" json:"failcnt,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MemoryData) Reset() { *m = MemoryData{} }
|
||||
func (m *MemoryData) String() string { return proto.CompactTextString(m) }
|
||||
func (*MemoryData) ProtoMessage() {}
|
||||
func (*MemoryData) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{28} }
|
||||
|
||||
type MemoryStats struct {
|
||||
Cache uint64 `protobuf:"varint,1,opt,name=cache" json:"cache,omitempty"`
|
||||
Usage *MemoryData `protobuf:"bytes,2,opt,name=usage" json:"usage,omitempty"`
|
||||
SwapUsage *MemoryData `protobuf:"bytes,3,opt,name=swap_usage" json:"swap_usage,omitempty"`
|
||||
KernelUsage *MemoryData `protobuf:"bytes,4,opt,name=kernel_usage" json:"kernel_usage,omitempty"`
|
||||
Stats map[string]uint64 `protobuf:"bytes,5,rep,name=stats" json:"stats,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
}
|
||||
|
||||
func (m *MemoryStats) Reset() { *m = MemoryStats{} }
|
||||
func (m *MemoryStats) String() string { return proto.CompactTextString(m) }
|
||||
func (*MemoryStats) ProtoMessage() {}
|
||||
func (*MemoryStats) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{29} }
|
||||
|
||||
func (m *MemoryStats) GetUsage() *MemoryData {
|
||||
if m != nil {
|
||||
return m.Usage
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MemoryStats) GetSwapUsage() *MemoryData {
|
||||
if m != nil {
|
||||
return m.SwapUsage
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MemoryStats) GetKernelUsage() *MemoryData {
|
||||
if m != nil {
|
||||
return m.KernelUsage
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MemoryStats) GetStats() map[string]uint64 {
|
||||
if m != nil {
|
||||
return m.Stats
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type BlkioStatsEntry struct {
|
||||
Major uint64 `protobuf:"varint,1,opt,name=major" json:"major,omitempty"`
|
||||
Minor uint64 `protobuf:"varint,2,opt,name=minor" json:"minor,omitempty"`
|
||||
Op string `protobuf:"bytes,3,opt,name=op" json:"op,omitempty"`
|
||||
Value uint64 `protobuf:"varint,4,opt,name=value" json:"value,omitempty"`
|
||||
}
|
||||
|
||||
func (m *BlkioStatsEntry) Reset() { *m = BlkioStatsEntry{} }
|
||||
func (m *BlkioStatsEntry) String() string { return proto.CompactTextString(m) }
|
||||
func (*BlkioStatsEntry) ProtoMessage() {}
|
||||
func (*BlkioStatsEntry) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{30} }
|
||||
|
||||
type BlkioStats struct {
|
||||
IoServiceBytesRecursive []*BlkioStatsEntry `protobuf:"bytes,1,rep,name=io_service_bytes_recursive" json:"io_service_bytes_recursive,omitempty"`
|
||||
IoServicedRecursive []*BlkioStatsEntry `protobuf:"bytes,2,rep,name=io_serviced_recursive" json:"io_serviced_recursive,omitempty"`
|
||||
IoQueuedRecursive []*BlkioStatsEntry `protobuf:"bytes,3,rep,name=io_queued_recursive" json:"io_queued_recursive,omitempty"`
|
||||
IoServiceTimeRecursive []*BlkioStatsEntry `protobuf:"bytes,4,rep,name=io_service_time_recursive" json:"io_service_time_recursive,omitempty"`
|
||||
IoWaitTimeRecursive []*BlkioStatsEntry `protobuf:"bytes,5,rep,name=io_wait_time_recursive" json:"io_wait_time_recursive,omitempty"`
|
||||
IoMergedRecursive []*BlkioStatsEntry `protobuf:"bytes,6,rep,name=io_merged_recursive" json:"io_merged_recursive,omitempty"`
|
||||
IoTimeRecursive []*BlkioStatsEntry `protobuf:"bytes,7,rep,name=io_time_recursive" json:"io_time_recursive,omitempty"`
|
||||
SectorsRecursive []*BlkioStatsEntry `protobuf:"bytes,8,rep,name=sectors_recursive" json:"sectors_recursive,omitempty"`
|
||||
}
|
||||
|
||||
func (m *BlkioStats) Reset() { *m = BlkioStats{} }
|
||||
func (m *BlkioStats) String() string { return proto.CompactTextString(m) }
|
||||
func (*BlkioStats) ProtoMessage() {}
|
||||
func (*BlkioStats) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{31} }
|
||||
|
||||
func (m *BlkioStats) GetIoServiceBytesRecursive() []*BlkioStatsEntry {
|
||||
if m != nil {
|
||||
return m.IoServiceBytesRecursive
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BlkioStats) GetIoServicedRecursive() []*BlkioStatsEntry {
|
||||
if m != nil {
|
||||
return m.IoServicedRecursive
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BlkioStats) GetIoQueuedRecursive() []*BlkioStatsEntry {
|
||||
if m != nil {
|
||||
return m.IoQueuedRecursive
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BlkioStats) GetIoServiceTimeRecursive() []*BlkioStatsEntry {
|
||||
if m != nil {
|
||||
return m.IoServiceTimeRecursive
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BlkioStats) GetIoWaitTimeRecursive() []*BlkioStatsEntry {
|
||||
if m != nil {
|
||||
return m.IoWaitTimeRecursive
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BlkioStats) GetIoMergedRecursive() []*BlkioStatsEntry {
|
||||
if m != nil {
|
||||
return m.IoMergedRecursive
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BlkioStats) GetIoTimeRecursive() []*BlkioStatsEntry {
|
||||
if m != nil {
|
||||
return m.IoTimeRecursive
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BlkioStats) GetSectorsRecursive() []*BlkioStatsEntry {
|
||||
if m != nil {
|
||||
return m.SectorsRecursive
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type HugetlbStats struct {
|
||||
Usage uint64 `protobuf:"varint,1,opt,name=usage" json:"usage,omitempty"`
|
||||
MaxUsage uint64 `protobuf:"varint,2,opt,name=max_usage" json:"max_usage,omitempty"`
|
||||
Failcnt uint64 `protobuf:"varint,3,opt,name=failcnt" json:"failcnt,omitempty"`
|
||||
}
|
||||
|
||||
func (m *HugetlbStats) Reset() { *m = HugetlbStats{} }
|
||||
func (m *HugetlbStats) String() string { return proto.CompactTextString(m) }
|
||||
func (*HugetlbStats) ProtoMessage() {}
|
||||
func (*HugetlbStats) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{32} }
|
||||
|
||||
type CgroupStats struct {
|
||||
CpuStats *CpuStats `protobuf:"bytes,1,opt,name=cpu_stats" json:"cpu_stats,omitempty"`
|
||||
MemoryStats *MemoryStats `protobuf:"bytes,2,opt,name=memory_stats" json:"memory_stats,omitempty"`
|
||||
BlkioStats *BlkioStats `protobuf:"bytes,3,opt,name=blkio_stats" json:"blkio_stats,omitempty"`
|
||||
HugetlbStats map[string]*HugetlbStats `protobuf:"bytes,4,rep,name=hugetlb_stats" json:"hugetlb_stats,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
}
|
||||
|
||||
func (m *CgroupStats) Reset() { *m = CgroupStats{} }
|
||||
func (m *CgroupStats) String() string { return proto.CompactTextString(m) }
|
||||
func (*CgroupStats) ProtoMessage() {}
|
||||
func (*CgroupStats) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{33} }
|
||||
|
||||
func (m *CgroupStats) GetCpuStats() *CpuStats {
|
||||
if m != nil {
|
||||
return m.CpuStats
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CgroupStats) GetMemoryStats() *MemoryStats {
|
||||
if m != nil {
|
||||
return m.MemoryStats
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CgroupStats) GetBlkioStats() *BlkioStats {
|
||||
if m != nil {
|
||||
return m.BlkioStats
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CgroupStats) GetHugetlbStats() map[string]*HugetlbStats {
|
||||
if m != nil {
|
||||
return m.HugetlbStats
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Stats struct {
|
||||
NetworkStats []*NetworkStats `protobuf:"bytes,1,rep,name=network_stats" json:"network_stats,omitempty"`
|
||||
CgroupStats *CgroupStats `protobuf:"bytes,2,opt,name=cgroup_stats" json:"cgroup_stats,omitempty"`
|
||||
Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp" json:"timestamp,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Stats) Reset() { *m = Stats{} }
|
||||
func (m *Stats) String() string { return proto.CompactTextString(m) }
|
||||
func (*Stats) ProtoMessage() {}
|
||||
func (*Stats) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{34} }
|
||||
|
||||
func (m *Stats) GetNetworkStats() []*NetworkStats {
|
||||
if m != nil {
|
||||
return m.NetworkStats
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Stats) GetCgroupStats() *CgroupStats {
|
||||
if m != nil {
|
||||
return m.CgroupStats
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type StatsRequest struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
||||
}
|
||||
|
||||
func (m *StatsRequest) Reset() { *m = StatsRequest{} }
|
||||
func (m *StatsRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*StatsRequest) ProtoMessage() {}
|
||||
func (*StatsRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{35} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*CreateContainerRequest)(nil), "types.CreateContainerRequest")
|
||||
proto.RegisterType((*CreateContainerResponse)(nil), "types.CreateContainerResponse")
|
||||
|
@ -398,6 +695,18 @@ func init() {
|
|||
proto.RegisterType((*UpdateContainerResponse)(nil), "types.UpdateContainerResponse")
|
||||
proto.RegisterType((*EventsRequest)(nil), "types.EventsRequest")
|
||||
proto.RegisterType((*Event)(nil), "types.Event")
|
||||
proto.RegisterType((*NetworkStats)(nil), "types.NetworkStats")
|
||||
proto.RegisterType((*CpuUsage)(nil), "types.CpuUsage")
|
||||
proto.RegisterType((*ThrottlingData)(nil), "types.ThrottlingData")
|
||||
proto.RegisterType((*CpuStats)(nil), "types.CpuStats")
|
||||
proto.RegisterType((*MemoryData)(nil), "types.MemoryData")
|
||||
proto.RegisterType((*MemoryStats)(nil), "types.MemoryStats")
|
||||
proto.RegisterType((*BlkioStatsEntry)(nil), "types.BlkioStatsEntry")
|
||||
proto.RegisterType((*BlkioStats)(nil), "types.BlkioStats")
|
||||
proto.RegisterType((*HugetlbStats)(nil), "types.HugetlbStats")
|
||||
proto.RegisterType((*CgroupStats)(nil), "types.CgroupStats")
|
||||
proto.RegisterType((*Stats)(nil), "types.Stats")
|
||||
proto.RegisterType((*StatsRequest)(nil), "types.StatsRequest")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
@ -416,6 +725,7 @@ type APIClient interface {
|
|||
ListCheckpoint(ctx context.Context, in *ListCheckpointRequest, opts ...grpc.CallOption) (*ListCheckpointResponse, error)
|
||||
State(ctx context.Context, in *StateRequest, opts ...grpc.CallOption) (*StateResponse, error)
|
||||
Events(ctx context.Context, in *EventsRequest, opts ...grpc.CallOption) (API_EventsClient, error)
|
||||
GetStats(ctx context.Context, in *StatsRequest, opts ...grpc.CallOption) (API_GetStatsClient, error)
|
||||
}
|
||||
|
||||
type aPIClient struct {
|
||||
|
@ -530,6 +840,38 @@ func (x *aPIEventsClient) Recv() (*Event, error) {
|
|||
return m, nil
|
||||
}
|
||||
|
||||
func (c *aPIClient) GetStats(ctx context.Context, in *StatsRequest, opts ...grpc.CallOption) (API_GetStatsClient, error) {
|
||||
stream, err := grpc.NewClientStream(ctx, &_API_serviceDesc.Streams[1], c.cc, "/types.API/GetStats", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &aPIGetStatsClient{stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type API_GetStatsClient interface {
|
||||
Recv() (*Stats, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type aPIGetStatsClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *aPIGetStatsClient) Recv() (*Stats, error) {
|
||||
m := new(Stats)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Server API for API service
|
||||
|
||||
type APIServer interface {
|
||||
|
@ -542,6 +884,7 @@ type APIServer interface {
|
|||
ListCheckpoint(context.Context, *ListCheckpointRequest) (*ListCheckpointResponse, error)
|
||||
State(context.Context, *StateRequest) (*StateResponse, error)
|
||||
Events(*EventsRequest, API_EventsServer) error
|
||||
GetStats(*StatsRequest, API_GetStatsServer) error
|
||||
}
|
||||
|
||||
func RegisterAPIServer(s *grpc.Server, srv APIServer) {
|
||||
|
@ -665,6 +1008,27 @@ func (x *aPIEventsServer) Send(m *Event) error {
|
|||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func _API_GetStats_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(StatsRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(APIServer).GetStats(m, &aPIGetStatsServer{stream})
|
||||
}
|
||||
|
||||
type API_GetStatsServer interface {
|
||||
Send(*Stats) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type aPIGetStatsServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *aPIGetStatsServer) Send(m *Stats) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
var _API_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "types.API",
|
||||
HandlerType: (*APIServer)(nil),
|
||||
|
@ -708,58 +1072,104 @@ var _API_serviceDesc = grpc.ServiceDesc{
|
|||
Handler: _API_Events_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "GetStats",
|
||||
Handler: _API_GetStats_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 782 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x56, 0x5f, 0x4f, 0xdb, 0x3e,
|
||||
0x14, 0x6d, 0x9b, 0xa6, 0x7f, 0x6e, 0x49, 0x28, 0x06, 0x4a, 0x88, 0x7e, 0xfc, 0x80, 0xec, 0x8f,
|
||||
0xf6, 0x84, 0x10, 0x4c, 0x1a, 0x8f, 0x43, 0x30, 0x4d, 0x93, 0x98, 0x86, 0x40, 0x4c, 0xda, 0x63,
|
||||
0x48, 0x2c, 0x1a, 0xd1, 0x26, 0x59, 0xec, 0x30, 0xd0, 0xbe, 0xc5, 0x3e, 0xd9, 0x3e, 0xd2, 0x1c,
|
||||
0xdb, 0x71, 0x9a, 0x34, 0x19, 0x4f, 0x7b, 0xf4, 0xb5, 0x7d, 0xee, 0x3d, 0xe7, 0x5e, 0x9f, 0x04,
|
||||
0x86, 0x6e, 0x1c, 0x1c, 0xc4, 0x49, 0x44, 0x23, 0xa4, 0xd3, 0xa7, 0x18, 0x13, 0xe7, 0x27, 0x4c,
|
||||
0xce, 0x12, 0xec, 0x52, 0x7c, 0x16, 0x85, 0xd4, 0x0d, 0x42, 0x9c, 0x5c, 0xe1, 0xef, 0x29, 0x26,
|
||||
0x14, 0x01, 0x74, 0x02, 0xdf, 0x6a, 0xef, 0xb5, 0xdf, 0x0c, 0x11, 0x5b, 0xdc, 0xa6, 0xa1, 0x3f,
|
||||
0xc3, 0x97, 0x2e, 0x9d, 0x5a, 0x1d, 0x1e, 0x33, 0x40, 0x27, 0xd4, 0x0f, 0x42, 0x4b, 0xe3, 0x4b,
|
||||
0x13, 0x7a, 0x6c, 0x19, 0xa5, 0xd4, 0xea, 0x2e, 0xac, 0x71, 0x92, 0x58, 0x7a, 0x0e, 0xe1, 0x4d,
|
||||
0xb1, 0x77, 0x1f, 0x47, 0x41, 0x48, 0xad, 0x7e, 0x16, 0x73, 0xb6, 0x61, 0x6b, 0x29, 0x39, 0x89,
|
||||
0xa3, 0x90, 0x60, 0xe7, 0x04, 0x8c, 0xeb, 0xe0, 0x2e, 0x74, 0x67, 0x75, 0xe5, 0x8c, 0x40, 0x8b,
|
||||
0xd9, 0x22, 0xab, 0xc3, 0xe0, 0x89, 0xf8, 0x49, 0x5e, 0x88, 0xe1, 0x8c, 0xc1, 0xcc, 0x6f, 0x4a,
|
||||
0x2c, 0x0a, 0x6b, 0xa7, 0xbe, 0x7f, 0x99, 0x44, 0x1e, 0x26, 0xa4, 0x0e, 0x6f, 0x0c, 0x03, 0x8a,
|
||||
0x93, 0x79, 0x90, 0x81, 0x64, 0xa0, 0x03, 0xb4, 0x0d, 0xdd, 0x94, 0xe0, 0x84, 0x43, 0x8e, 0x8e,
|
||||
0x46, 0x07, 0x5c, 0xac, 0x83, 0x1b, 0x16, 0x42, 0x2b, 0xd0, 0x75, 0x93, 0x3b, 0xc2, 0x68, 0x6a,
|
||||
0xa2, 0x14, 0x1c, 0x3e, 0x30, 0x8e, 0x72, 0xe1, 0xfd, 0xf0, 0xad, 0x1e, 0x27, 0x77, 0x02, 0x5d,
|
||||
0x7e, 0x9e, 0x05, 0x53, 0x99, 0xc9, 0xc8, 0x16, 0x77, 0xaa, 0xf2, 0x09, 0x98, 0xae, 0xef, 0x07,
|
||||
0x34, 0x88, 0x58, 0xe2, 0x8f, 0x81, 0x4f, 0x58, 0x3a, 0x8d, 0x31, 0xd8, 0x07, 0xb4, 0x58, 0xaf,
|
||||
0x60, 0x91, 0x93, 0xe6, 0x38, 0xce, 0x85, 0x52, 0x4e, 0x69, 0x5a, 0x47, 0xec, 0x55, 0x49, 0xf4,
|
||||
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 0x2e, 0x9e,
|
||||
0x01, 0x14, 0x3e, 0x8b, 0x2c, 0x79, 0x6c, 0xe9, 0x53, 0x61, 0x6f, 0xd7, 0xec, 0x28, 0x90, 0x1b,
|
||||
0x18, 0x57, 0xbd, 0x13, 0x55, 0x74, 0xa8, 0x3a, 0x9d, 0xbd, 0xdb, 0xb8, 0xbf, 0x08, 0x5b, 0x75,
|
||||
0x50, 0x05, 0xdb, 0xe0, 0xc7, 0x0a, 0xb6, 0xd1, 0x7a, 0x5b, 0xe8, 0x0b, 0x98, 0x65, 0xf3, 0x43,
|
||||
0xff, 0xc9, 0x4b, 0xb5, 0x9e, 0x6c, 0xef, 0x34, 0xec, 0x2a, 0xc0, 0xb7, 0xa0, 0x0b, 0xcb, 0x5b,
|
||||
0xcf, 0x55, 0x5e, 0x70, 0x46, 0x7b, 0xa3, 0x1c, 0x54, 0xb7, 0x0e, 0xa1, 0x27, 0x9e, 0x91, 0x6a,
|
||||
0x59, 0xe9, 0x55, 0xd9, 0x2b, 0x8b, 0x51, 0xa7, 0x75, 0xd8, 0xbe, 0xed, 0xf1, 0xbf, 0x96, 0xe3,
|
||||
0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x36, 0x89, 0xf8, 0xbd, 0xc2, 0x08, 0x00, 0x00,
|
||||
// 1426 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x57, 0xd9, 0x6e, 0x1c, 0x55,
|
||||
0x13, 0xf6, 0xcc, 0xf4, 0x6c, 0x35, 0x8b, 0xed, 0x76, 0xec, 0x8c, 0xe7, 0xff, 0x43, 0x92, 0x26,
|
||||
0x40, 0x84, 0x22, 0x2b, 0x38, 0x2c, 0x21, 0x5c, 0x40, 0x70, 0xa2, 0x04, 0x94, 0x80, 0x95, 0xd8,
|
||||
0x48, 0xdc, 0x30, 0x6a, 0x77, 0x1f, 0x66, 0x0e, 0xd3, 0x1b, 0xdd, 0xa7, 0xbd, 0x88, 0x37, 0xe0,
|
||||
0x81, 0x78, 0x00, 0x24, 0xee, 0x79, 0x0e, 0x9e, 0x82, 0x3a, 0x4b, 0x9f, 0x5e, 0x66, 0x09, 0x5c,
|
||||
0x70, 0x33, 0xd2, 0xa9, 0xae, 0xfa, 0xaa, 0xea, 0xab, 0x65, 0xce, 0x81, 0xae, 0x1d, 0xd1, 0x83,
|
||||
0x28, 0x0e, 0x59, 0x68, 0x36, 0xd9, 0x55, 0x44, 0x12, 0xeb, 0x17, 0xd8, 0x3b, 0x8a, 0x89, 0xcd,
|
||||
0xc8, 0x51, 0x18, 0x30, 0x9b, 0x06, 0x24, 0x7e, 0x45, 0x7e, 0x4e, 0x49, 0xc2, 0x4c, 0x80, 0x3a,
|
||||
0x75, 0x47, 0xb5, 0x5b, 0xb5, 0xbb, 0x5d, 0x13, 0x0f, 0x67, 0x69, 0xe0, 0x7a, 0xe4, 0xd8, 0x66,
|
||||
0xb3, 0x51, 0x5d, 0xc8, 0x06, 0xd0, 0x4c, 0x98, 0x4b, 0x83, 0x51, 0x43, 0x1c, 0x87, 0xd0, 0xc2,
|
||||
0x63, 0x98, 0xb2, 0x91, 0x51, 0x38, 0x93, 0x38, 0x1e, 0x35, 0x33, 0x08, 0x67, 0x46, 0x9c, 0x79,
|
||||
0x14, 0xd2, 0x80, 0x8d, 0xda, 0x5c, 0x66, 0xed, 0xc3, 0xf5, 0x05, 0xe7, 0x49, 0x14, 0x06, 0x09,
|
||||
0xb1, 0x1e, 0xc2, 0xe0, 0x35, 0x9d, 0x06, 0xb6, 0xb7, 0x2c, 0x9c, 0x1e, 0x34, 0x22, 0x3c, 0xf0,
|
||||
0x38, 0x06, 0xc2, 0x91, 0xd0, 0x14, 0x81, 0x0c, 0xac, 0x2d, 0x18, 0x66, 0x96, 0x0a, 0x8b, 0xc1,
|
||||
0xf6, 0x63, 0xd7, 0x3d, 0x8e, 0x43, 0x87, 0x24, 0xc9, 0x32, 0xbc, 0x2d, 0xe8, 0x30, 0x12, 0xfb,
|
||||
0x94, 0x83, 0x70, 0xd0, 0x8e, 0xb9, 0x0f, 0x46, 0x9a, 0x90, 0x58, 0x40, 0xf6, 0x0e, 0x7b, 0x07,
|
||||
0x82, 0xac, 0x83, 0x53, 0x14, 0x99, 0x7d, 0x30, 0xec, 0x78, 0x9a, 0x60, 0x9a, 0x0d, 0x19, 0x0a,
|
||||
0x09, 0xce, 0x31, 0x47, 0x75, 0x70, 0x2e, 0xdc, 0x51, 0x4b, 0x24, 0xf7, 0x10, 0x0c, 0xa1, 0x8f,
|
||||
0xc2, 0x54, 0x79, 0x1a, 0xf0, 0xc3, 0x54, 0x47, 0xbe, 0x07, 0x43, 0xdb, 0x75, 0x29, 0xa3, 0x21,
|
||||
0x3a, 0x7e, 0x46, 0xdd, 0x04, 0xdd, 0x35, 0x30, 0x83, 0xdb, 0x60, 0x16, 0xe3, 0x95, 0x59, 0x64,
|
||||
0x49, 0x0b, 0x1c, 0xeb, 0x85, 0x66, 0x4e, 0x73, 0xba, 0x2c, 0xb1, 0x77, 0x4a, 0xa4, 0xd7, 0x45,
|
||||
0x32, 0xdb, 0x2a, 0x99, 0xdc, 0xd2, 0x1a, 0xc3, 0x68, 0x11, 0x4d, 0x91, 0xf7, 0x00, 0xae, 0x3f,
|
||||
0x21, 0x1e, 0x79, 0x93, 0x27, 0x64, 0x25, 0xb0, 0x7d, 0x22, 0x7b, 0x83, 0x03, 0x2e, 0x1a, 0x29,
|
||||
0xc0, 0xb7, 0x61, 0xf7, 0x05, 0x4d, 0xd8, 0x5a, 0x38, 0xeb, 0x7b, 0x80, 0x5c, 0x41, 0x83, 0x6b,
|
||||
0x57, 0xe4, 0x92, 0x32, 0x55, 0x29, 0xa4, 0x85, 0x39, 0x91, 0x28, 0x54, 0xc7, 0xdc, 0x81, 0x5e,
|
||||
0x1a, 0xd0, 0xcb, 0xd7, 0xa1, 0x33, 0x27, 0x2c, 0x11, 0x9d, 0xd8, 0x11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 0x79, 0xec, 0xc3, 0xb6, 0xfe, 0xc8, 0x07,
|
||||
0x53, 0x7c, 0x12, 0xf9, 0x58, 0x27, 0x30, 0x3c, 0x99, 0xe1, 0x7f, 0x29, 0xf3, 0x68, 0x30, 0x7d,
|
||||
0x62, 0x33, 0xdb, 0xdc, 0xc4, 0x3a, 0x91, 0x98, 0x86, 0x6e, 0xa2, 0x1c, 0xa2, 0x35, 0x93, 0x2a,
|
||||
0xc4, 0x9d, 0x64, 0x9f, 0x24, 0x69, 0xb8, 0xfc, 0xf3, 0x4f, 0x8c, 0xfa, 0xca, 0xa1, 0xf5, 0x83,
|
||||
0x48, 0x42, 0x12, 0x6f, 0x41, 0x37, 0x0f, 0xb6, 0x26, 0xea, 0xb5, 0x99, 0xd5, 0x2b, 0x4b, 0xf4,
|
||||
0x00, 0x36, 0x99, 0x8e, 0x62, 0x82, 0x5d, 0x6b, 0xab, 0xd9, 0xd8, 0x55, 0x9a, 0xe5, 0x18, 0xad,
|
||||
0xcf, 0x01, 0x5e, 0x8a, 0x51, 0x14, 0x11, 0xe3, 0x6e, 0x2c, 0x12, 0x84, 0x44, 0xfb, 0xf6, 0xa5,
|
||||
0x66, 0x87, 0x8b, 0x30, 0xa7, 0x1f, 0x6d, 0xea, 0x39, 0xd8, 0x31, 0x32, 0xc0, 0xbf, 0x6a, 0xd0,
|
||||
0x93, 0x08, 0x32, 0x48, 0x84, 0x70, 0x70, 0xfc, 0x32, 0x88, 0x5b, 0x19, 0x62, 0xf9, 0xdf, 0xa6,
|
||||
0xe0, 0x13, 0xdb, 0x30, 0xb9, 0xb0, 0x23, 0xe5, 0xa5, 0xb1, 0x4a, 0xed, 0x3d, 0xe8, 0xcb, 0x6a,
|
||||
0x28, 0x45, 0x63, 0x95, 0xe2, 0x3d, 0x7e, 0x11, 0xc1, 0x48, 0xc4, 0x2e, 0xec, 0x1d, 0xde, 0x28,
|
||||
0x69, 0x88, 0x18, 0x0f, 0xc4, 0xef, 0xd3, 0x80, 0x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, 0xdd, 0xd2, 0xa3, 0x69, 0xbc, 0x5b, 0x91, 0x6a, 0xc3, 0x23, 0x80,
|
||||
0xfc, 0x89, 0x61, 0x8e, 0x94, 0xda, 0xc2, 0x2b, 0x69, 0xbc, 0xbf, 0xe4, 0x8b, 0x06, 0x39, 0x85,
|
||||
0xad, 0xea, 0xb3, 0xc1, 0xac, 0xf0, 0x50, 0xbd, 0xe4, 0x8f, 0x6f, 0xae, 0xfc, 0x5e, 0x84, 0xad,
|
||||
0x3e, 0x1e, 0x34, 0xec, 0x8a, 0xa7, 0x88, 0x86, 0x5d, 0xf9, 0xea, 0xd8, 0x30, 0xbf, 0x85, 0x61,
|
||||
0xf9, 0xde, 0x6f, 0xfe, 0x5f, 0x19, 0x2d, 0x7d, 0x8e, 0x8c, 0x6f, 0xac, 0xf8, 0xaa, 0x01, 0x3f,
|
||||
0x94, 0xad, 0x8b, 0x77, 0x8d, 0x8c, 0xe5, 0xc2, 0xa3, 0x60, 0x7c, 0xad, 0x2c, 0xd4, 0x56, 0xf7,
|
||||
0xa1, 0x25, 0x6f, 0x90, 0xba, 0x64, 0xa5, 0x0b, 0xe5, 0xb8, 0x5f, 0x94, 0x5a, 0x1b, 0xf7, 0x6b,
|
||||
0xb8, 0xa5, 0x3a, 0xcf, 0x08, 0x93, 0xfd, 0x5c, 0x74, 0xb5, 0x60, 0x22, 0x84, 0xdc, 0xe4, 0xac,
|
||||
0x25, 0xde, 0xf8, 0x0f, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xef, 0x98, 0x5d, 0x0a, 0xf0, 0x0f,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ service API {
|
|||
rpc ListCheckpoint(ListCheckpointRequest) returns (ListCheckpointResponse) {}
|
||||
rpc State(StateRequest) returns (StateResponse) {}
|
||||
rpc Events(EventsRequest) returns (stream Event) {}
|
||||
rpc GetStats(StatsRequest) returns (stream Stats) {}
|
||||
}
|
||||
|
||||
message CreateContainerRequest {
|
||||
|
@ -146,3 +147,88 @@ message Event {
|
|||
repeated Container containers = 9;
|
||||
Checkpoint checkpoint = 10;
|
||||
}
|
||||
|
||||
message NetworkStats {
|
||||
string name = 1; // name of network interface
|
||||
uint64 rx_bytes = 2;
|
||||
uint64 rx_Packets = 3;
|
||||
uint64 Rx_errors = 4;
|
||||
uint64 Rx_dropped = 5;
|
||||
uint64 Tx_bytes = 6;
|
||||
uint64 Tx_packets = 7;
|
||||
uint64 Tx_errors = 8;
|
||||
uint64 Tx_dropped = 9;
|
||||
}
|
||||
|
||||
message CpuUsage {
|
||||
uint64 total_usage = 1;
|
||||
repeated uint64 percpu_usage = 2;
|
||||
uint64 usage_in_kernelmode = 3;
|
||||
uint64 usage_in_usermode = 4;
|
||||
}
|
||||
|
||||
message ThrottlingData {
|
||||
uint64 periods = 1;
|
||||
uint64 throttled_periods = 2;
|
||||
uint64 throttled_time = 3;
|
||||
}
|
||||
|
||||
message CpuStats {
|
||||
CpuUsage cpu_usage = 1;
|
||||
ThrottlingData throttling_data = 2;
|
||||
}
|
||||
|
||||
message MemoryData {
|
||||
uint64 usage = 1;
|
||||
uint64 max_usage = 2;
|
||||
uint64 failcnt = 3;
|
||||
}
|
||||
|
||||
message MemoryStats {
|
||||
uint64 cache = 1;
|
||||
MemoryData usage = 2;
|
||||
MemoryData swap_usage = 3;
|
||||
MemoryData kernel_usage = 4;
|
||||
map<string, uint64> stats = 5;
|
||||
}
|
||||
|
||||
message BlkioStatsEntry {
|
||||
uint64 major = 1;
|
||||
uint64 minor = 2;
|
||||
string op = 3;
|
||||
uint64 value = 4;
|
||||
}
|
||||
|
||||
message BlkioStats {
|
||||
repeated BlkioStatsEntry io_service_bytes_recursive = 1; // number of bytes tranferred to and from the block device
|
||||
repeated BlkioStatsEntry io_serviced_recursive = 2;
|
||||
repeated BlkioStatsEntry io_queued_recursive = 3;
|
||||
repeated BlkioStatsEntry io_service_time_recursive = 4;
|
||||
repeated BlkioStatsEntry io_wait_time_recursive = 5;
|
||||
repeated BlkioStatsEntry io_merged_recursive = 6;
|
||||
repeated BlkioStatsEntry io_time_recursive = 7;
|
||||
repeated BlkioStatsEntry sectors_recursive = 8;
|
||||
}
|
||||
|
||||
message HugetlbStats {
|
||||
uint64 usage = 1;
|
||||
uint64 max_usage = 2;
|
||||
uint64 failcnt = 3;
|
||||
}
|
||||
|
||||
message CgroupStats {
|
||||
CpuStats cpu_stats = 1;
|
||||
MemoryStats memory_stats = 2;
|
||||
BlkioStats blkio_stats = 3;
|
||||
map<string, HugetlbStats> hugetlb_stats = 4; // the map is in the format "size of hugepage: stats of the hugepage"
|
||||
}
|
||||
|
||||
message Stats {
|
||||
repeated NetworkStats network_stats = 1;
|
||||
CgroupStats cgroup_stats = 2;
|
||||
uint64 timestamp = 3;
|
||||
};
|
||||
|
||||
message StatsRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
|
|
@ -230,3 +230,31 @@ var ExecCommand = cli.Command{
|
|||
}
|
||||
},
|
||||
}
|
||||
|
||||
var StatsCommand = cli.Command{
|
||||
Name: "stats",
|
||||
Usage: "get stats for running container",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "id",
|
||||
Usage: "container id",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) {
|
||||
req := &types.StatsRequest{
|
||||
Id: context.String("id"),
|
||||
}
|
||||
c := getClient()
|
||||
stream, err := c.GetStats(netcontext.Background(), req)
|
||||
if err != nil {
|
||||
fatal(err.Error(), 1)
|
||||
}
|
||||
for {
|
||||
stats, err := stream.Recv()
|
||||
if err != nil {
|
||||
fatal(err.Error(), 1)
|
||||
}
|
||||
fmt.Println(stats)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ func main() {
|
|||
CheckpointCommand,
|
||||
ContainersCommand,
|
||||
EventsCommand,
|
||||
StatsCommand,
|
||||
}
|
||||
app.Before = func(context *cli.Context) error {
|
||||
if context.GlobalBool("debug") {
|
||||
|
|
3
event.go
3
event.go
|
@ -21,6 +21,8 @@ const (
|
|||
UpdateContainerEventType EventType = "updateContainer"
|
||||
CreateCheckpointEventType EventType = "createCheckpoint"
|
||||
DeleteCheckpointEventType EventType = "deleteCheckpoint"
|
||||
StatsEventType EventType = "events"
|
||||
UnsubscribeStatsEventType EventType = "unsubscribeEvents"
|
||||
)
|
||||
|
||||
func NewEvent(t EventType) *Event {
|
||||
|
@ -47,6 +49,7 @@ type Event struct {
|
|||
Containers []runtime.Container
|
||||
Checkpoint *runtime.Checkpoint
|
||||
Err chan error
|
||||
Stats chan interface{}
|
||||
}
|
||||
|
||||
type Handler interface {
|
||||
|
|
26
stats.go
26
stats.go
|
@ -17,3 +17,29 @@ func Metrics() map[string]interface{} {
|
|||
"events-subscribers": EventSubscriberCounter,
|
||||
}
|
||||
}
|
||||
|
||||
type StatsEvent struct {
|
||||
s *Supervisor
|
||||
}
|
||||
|
||||
type UnsubscribeStatsEvent struct {
|
||||
s *Supervisor
|
||||
}
|
||||
|
||||
func (h *StatsEvent) Handle(e *Event) error {
|
||||
i, ok := h.s.containers[e.ID]
|
||||
if !ok {
|
||||
return ErrContainerNotFound
|
||||
}
|
||||
e.Stats = h.s.statsCollector.collect(i.container)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *UnsubscribeStatsEvent) Handle(e *Event) error {
|
||||
i, ok := h.s.containers[e.ID]
|
||||
if !ok {
|
||||
return ErrContainerNotFound
|
||||
}
|
||||
h.s.statsCollector.unsubscribe(i.container, e.Stats)
|
||||
return nil
|
||||
}
|
||||
|
|
240
stats_collector.go
Normal file
240
stats_collector.go
Normal file
|
@ -0,0 +1,240 @@
|
|||
package containerd
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/containerd/api/grpc/types"
|
||||
"github.com/docker/containerd/runtime"
|
||||
"github.com/docker/docker/pkg/pubsub"
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||
"github.com/opencontainers/runc/libcontainer/system"
|
||||
)
|
||||
|
||||
func convertBlkioEntryToPb(b []cgroups.BlkioStatEntry) []*types.BlkioStatsEntry {
|
||||
var pbEs []*types.BlkioStatsEntry
|
||||
for _, e := range b {
|
||||
pbEs = append(pbEs, &types.BlkioStatsEntry{
|
||||
Major: e.Major,
|
||||
Minor: e.Minor,
|
||||
Op: e.Op,
|
||||
Value: e.Value,
|
||||
})
|
||||
}
|
||||
return pbEs
|
||||
}
|
||||
|
||||
func convertToPb(st *runtime.Stat) *types.Stats {
|
||||
pbSt := &types.Stats{
|
||||
Timestamp: uint64(st.Timestamp.Unix()),
|
||||
CgroupStats: &types.CgroupStats{},
|
||||
}
|
||||
lcSt, ok := st.Data.(*libcontainer.Stats)
|
||||
if !ok {
|
||||
return pbSt
|
||||
}
|
||||
cpuSt := lcSt.CgroupStats.CpuStats
|
||||
pbSt.CgroupStats.CpuStats = &types.CpuStats{
|
||||
CpuUsage: &types.CpuUsage{
|
||||
TotalUsage: cpuSt.CpuUsage.TotalUsage,
|
||||
PercpuUsage: cpuSt.CpuUsage.PercpuUsage,
|
||||
UsageInKernelmode: cpuSt.CpuUsage.UsageInKernelmode,
|
||||
UsageInUsermode: cpuSt.CpuUsage.UsageInUsermode,
|
||||
},
|
||||
ThrottlingData: &types.ThrottlingData{
|
||||
Periods: cpuSt.ThrottlingData.Periods,
|
||||
ThrottledPeriods: cpuSt.ThrottlingData.ThrottledPeriods,
|
||||
ThrottledTime: cpuSt.ThrottlingData.ThrottledTime,
|
||||
},
|
||||
}
|
||||
memSt := lcSt.CgroupStats.MemoryStats
|
||||
pbSt.CgroupStats.MemoryStats = &types.MemoryStats{
|
||||
Cache: memSt.Cache,
|
||||
Usage: &types.MemoryData{
|
||||
Usage: memSt.Usage.Usage,
|
||||
MaxUsage: memSt.Usage.MaxUsage,
|
||||
Failcnt: memSt.Usage.Failcnt,
|
||||
},
|
||||
SwapUsage: &types.MemoryData{
|
||||
Usage: memSt.SwapUsage.Usage,
|
||||
MaxUsage: memSt.SwapUsage.MaxUsage,
|
||||
Failcnt: memSt.SwapUsage.Failcnt,
|
||||
},
|
||||
}
|
||||
blkSt := lcSt.CgroupStats.BlkioStats
|
||||
pbSt.CgroupStats.BlkioStats = &types.BlkioStats{
|
||||
IoServiceBytesRecursive: convertBlkioEntryToPb(blkSt.IoServiceBytesRecursive),
|
||||
IoServicedRecursive: convertBlkioEntryToPb(blkSt.IoServicedRecursive),
|
||||
IoQueuedRecursive: convertBlkioEntryToPb(blkSt.IoQueuedRecursive),
|
||||
IoServiceTimeRecursive: convertBlkioEntryToPb(blkSt.IoServiceTimeRecursive),
|
||||
IoWaitTimeRecursive: convertBlkioEntryToPb(blkSt.IoWaitTimeRecursive),
|
||||
IoMergedRecursive: convertBlkioEntryToPb(blkSt.IoMergedRecursive),
|
||||
IoTimeRecursive: convertBlkioEntryToPb(blkSt.IoTimeRecursive),
|
||||
SectorsRecursive: convertBlkioEntryToPb(blkSt.SectorsRecursive),
|
||||
}
|
||||
pbSt.CgroupStats.HugetlbStats = make(map[string]*types.HugetlbStats)
|
||||
for k, st := range lcSt.CgroupStats.HugetlbStats {
|
||||
pbSt.CgroupStats.HugetlbStats[k] = &types.HugetlbStats{
|
||||
Usage: st.Usage,
|
||||
MaxUsage: st.MaxUsage,
|
||||
Failcnt: st.Failcnt,
|
||||
}
|
||||
}
|
||||
return pbSt
|
||||
}
|
||||
|
||||
type statsPair struct {
|
||||
ct runtime.Container
|
||||
pub *pubsub.Publisher
|
||||
}
|
||||
|
||||
func newStatsCollector(interval time.Duration) *statsCollector {
|
||||
s := &statsCollector{
|
||||
interval: interval,
|
||||
clockTicksPerSecond: uint64(system.GetClockTicks()),
|
||||
bufReader: bufio.NewReaderSize(nil, 128),
|
||||
publishers: make(map[string]*statsPair),
|
||||
}
|
||||
go s.run()
|
||||
return s
|
||||
}
|
||||
|
||||
// statsCollector manages and provides container resource stats
|
||||
type statsCollector struct {
|
||||
m sync.Mutex
|
||||
supervisor *Supervisor
|
||||
interval time.Duration
|
||||
clockTicksPerSecond uint64
|
||||
publishers map[string]*statsPair
|
||||
bufReader *bufio.Reader
|
||||
}
|
||||
|
||||
// collect registers the container with the collector and adds it to
|
||||
// the event loop for collection on the specified interval returning
|
||||
// a channel for the subscriber to receive on.
|
||||
func (s *statsCollector) collect(c runtime.Container) chan interface{} {
|
||||
s.m.Lock()
|
||||
defer s.m.Unlock()
|
||||
publisher, exists := s.publishers[c.ID()]
|
||||
if !exists {
|
||||
pub := pubsub.NewPublisher(100*time.Millisecond, 1024)
|
||||
publisher = &statsPair{ct: c, pub: pub}
|
||||
s.publishers[c.ID()] = publisher
|
||||
}
|
||||
return publisher.pub.Subscribe()
|
||||
}
|
||||
|
||||
// stopCollection closes the channels for all subscribers and removes
|
||||
// the container from metrics collection.
|
||||
func (s *statsCollector) stopCollection(c runtime.Container) {
|
||||
s.m.Lock()
|
||||
if publisher, exists := s.publishers[c.ID()]; exists {
|
||||
publisher.pub.Close()
|
||||
delete(s.publishers, c.ID())
|
||||
}
|
||||
s.m.Unlock()
|
||||
}
|
||||
|
||||
// unsubscribe removes a specific subscriber from receiving updates for a container's stats.
|
||||
func (s *statsCollector) unsubscribe(c runtime.Container, ch chan interface{}) {
|
||||
s.m.Lock()
|
||||
publisher := s.publishers[c.ID()]
|
||||
if publisher != nil {
|
||||
publisher.pub.Evict(ch)
|
||||
if publisher.pub.Len() == 0 {
|
||||
delete(s.publishers, c.ID())
|
||||
}
|
||||
}
|
||||
s.m.Unlock()
|
||||
}
|
||||
|
||||
func (s *statsCollector) run() {
|
||||
type publishersPair struct {
|
||||
container runtime.Container
|
||||
publisher *pubsub.Publisher
|
||||
}
|
||||
// we cannot determine the capacity here.
|
||||
// it will grow enough in first iteration
|
||||
var pairs []*statsPair
|
||||
|
||||
for range time.Tick(s.interval) {
|
||||
// it does not make sense in the first iteration,
|
||||
// but saves allocations in further iterations
|
||||
pairs = pairs[:0]
|
||||
|
||||
s.m.Lock()
|
||||
for _, publisher := range s.publishers {
|
||||
// copy pointers here to release the lock ASAP
|
||||
pairs = append(pairs, publisher)
|
||||
}
|
||||
s.m.Unlock()
|
||||
if len(pairs) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, pair := range pairs {
|
||||
stats, err := pair.ct.Stats()
|
||||
if err != nil {
|
||||
logrus.Errorf("Error getting stats for container ID %s", pair.ct.ID())
|
||||
continue
|
||||
}
|
||||
|
||||
pair.pub.Publish(convertToPb(stats))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const nanoSecondsPerSecond = 1e9
|
||||
|
||||
// getSystemCPUUsage returns the host system's cpu usage in
|
||||
// nanoseconds. An error is returned if the format of the underlying
|
||||
// file does not match.
|
||||
//
|
||||
// Uses /proc/stat defined by POSIX. Looks for the cpu
|
||||
// statistics line and then sums up the first seven fields
|
||||
// provided. See `man 5 proc` for details on specific field
|
||||
// information.
|
||||
func (s *statsCollector) getSystemCPUUsage() (uint64, error) {
|
||||
var line string
|
||||
f, err := os.Open("/proc/stat")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer func() {
|
||||
s.bufReader.Reset(nil)
|
||||
f.Close()
|
||||
}()
|
||||
s.bufReader.Reset(f)
|
||||
err = nil
|
||||
for err == nil {
|
||||
line, err = s.bufReader.ReadString('\n')
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
parts := strings.Fields(line)
|
||||
switch parts[0] {
|
||||
case "cpu":
|
||||
if len(parts) < 8 {
|
||||
return 0, fmt.Errorf("bad format of cpu stats")
|
||||
}
|
||||
var totalClockTicks uint64
|
||||
for _, i := range parts[1:8] {
|
||||
v, err := strconv.ParseUint(i, 10, 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("error parsing cpu stats")
|
||||
}
|
||||
totalClockTicks += v
|
||||
}
|
||||
return (totalClockTicks * nanoSecondsPerSecond) /
|
||||
s.clockTicksPerSecond, nil
|
||||
}
|
||||
}
|
||||
return 0, fmt.Errorf("bad stats format")
|
||||
}
|
|
@ -7,12 +7,15 @@ import (
|
|||
goruntime "runtime"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/containerd/runtime"
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
)
|
||||
|
||||
const statsInterval = 1 * time.Second
|
||||
|
||||
// NewSupervisor returns an initialized Process supervisor.
|
||||
func NewSupervisor(id, stateDir string, tasks chan *StartTask) (*Supervisor, error) {
|
||||
if err := os.MkdirAll(stateDir, 0755); err != nil {
|
||||
|
@ -28,14 +31,15 @@ func NewSupervisor(id, stateDir string, tasks chan *StartTask) (*Supervisor, err
|
|||
return nil, err
|
||||
}
|
||||
s := &Supervisor{
|
||||
stateDir: stateDir,
|
||||
containers: make(map[string]*containerInfo),
|
||||
processes: make(map[int]*containerInfo),
|
||||
runtime: r,
|
||||
tasks: tasks,
|
||||
events: make(chan *Event, DefaultBufferSize),
|
||||
machine: machine,
|
||||
subscribers: make(map[chan *Event]struct{}),
|
||||
stateDir: stateDir,
|
||||
containers: make(map[string]*containerInfo),
|
||||
processes: make(map[int]*containerInfo),
|
||||
runtime: r,
|
||||
tasks: tasks,
|
||||
events: make(chan *Event, DefaultBufferSize),
|
||||
machine: machine,
|
||||
subscribers: make(map[chan *Event]struct{}),
|
||||
statsCollector: newStatsCollector(statsInterval),
|
||||
}
|
||||
// register default event handlers
|
||||
s.handlers = map[EventType]Handler{
|
||||
|
@ -49,6 +53,8 @@ func NewSupervisor(id, stateDir string, tasks chan *StartTask) (*Supervisor, err
|
|||
UpdateContainerEventType: &UpdateEvent{s},
|
||||
CreateCheckpointEventType: &CreateCheckpointEvent{s},
|
||||
DeleteCheckpointEventType: &DeleteCheckpointEvent{s},
|
||||
StatsEventType: &StatsEvent{s},
|
||||
UnsubscribeStatsEventType: &UnsubscribeStatsEvent{s},
|
||||
}
|
||||
// start the container workers for concurrent container starts
|
||||
return s, nil
|
||||
|
@ -74,6 +80,7 @@ type Supervisor struct {
|
|||
subscribers map[chan *Event]struct{}
|
||||
machine Machine
|
||||
containerGroup sync.WaitGroup
|
||||
statsCollector *statsCollector
|
||||
}
|
||||
|
||||
// Stop closes all tasks and sends a SIGTERM to each container's pid1 then waits for they to
|
||||
|
|
Loading…
Reference in a new issue