ListPids returns process ID and other info

Signed-off-by: Jess <jessica.valarezo@docker.com>
This commit is contained in:
Jess
2017-10-10 22:57:15 +00:00
parent 72bb45ac46
commit 061c719209
18 changed files with 1118 additions and 405 deletions

View File

@@ -10,6 +10,7 @@
It has these top-level messages:
CreateOptions
ProcessDetails
*/
package hcsshimopts
@@ -18,6 +19,7 @@ import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import _ "github.com/golang/protobuf/ptypes/duration"
import google_protobuf2 "github.com/gogo/protobuf/types"
import time "time"
@@ -48,8 +50,26 @@ func (m *CreateOptions) Reset() { *m = CreateOptions{} }
func (*CreateOptions) ProtoMessage() {}
func (*CreateOptions) Descriptor() ([]byte, []int) { return fileDescriptorHcsshim, []int{0} }
// ProcessDetails contains additional information about a process
// ProcessDetails is made of the same fields as found in hcsshim.ProcessListItem
type ProcessDetails struct {
ImageName string `protobuf:"bytes,1,opt,name=image_name,json=imageName,proto3" json:"image_name,omitempty"`
CreatedAt *google_protobuf2.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt" json:"created_at,omitempty"`
KernelTime_100Ns uint64 `protobuf:"varint,3,opt,name=kernel_time_100_ns,json=kernelTime100Ns,proto3" json:"kernel_time_100_ns,omitempty"`
MemoryCommitBytes uint64 `protobuf:"varint,4,opt,name=memory_commit_bytes,json=memoryCommitBytes,proto3" json:"memory_commit_bytes,omitempty"`
MemoryWorkingSetPrivateBytes uint64 `protobuf:"varint,5,opt,name=memory_working_set_private_bytes,json=memoryWorkingSetPrivateBytes,proto3" json:"memory_working_set_private_bytes,omitempty"`
MemoryWorkingSetSharedBytes uint64 `protobuf:"varint,6,opt,name=memory_working_set_shared_bytes,json=memoryWorkingSetSharedBytes,proto3" json:"memory_working_set_shared_bytes,omitempty"`
ProcessID uint32 `protobuf:"varint,7,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"`
UserTime_100Ns uint64 `protobuf:"varint,8,opt,name=user_time_100_ns,json=userTime100Ns,proto3" json:"user_time_100_ns,omitempty"`
}
func (m *ProcessDetails) Reset() { *m = ProcessDetails{} }
func (*ProcessDetails) ProtoMessage() {}
func (*ProcessDetails) Descriptor() ([]byte, []int) { return fileDescriptorHcsshim, []int{1} }
func init() {
proto.RegisterType((*CreateOptions)(nil), "containerd.windows.hcsshim.CreateOptions")
proto.RegisterType((*ProcessDetails)(nil), "containerd.windows.hcsshim.ProcessDetails")
}
func (m *CreateOptions) Marshal() (dAtA []byte, err error) {
size := m.Size()
@@ -77,6 +97,70 @@ func (m *CreateOptions) MarshalTo(dAtA []byte) (int, error) {
return i, nil
}
func (m *ProcessDetails) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ProcessDetails) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.ImageName) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintHcsshim(dAtA, i, uint64(len(m.ImageName)))
i += copy(dAtA[i:], m.ImageName)
}
if m.CreatedAt != nil {
dAtA[i] = 0x12
i++
i = encodeVarintHcsshim(dAtA, i, uint64(m.CreatedAt.Size()))
n2, err := m.CreatedAt.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n2
}
if m.KernelTime_100Ns != 0 {
dAtA[i] = 0x18
i++
i = encodeVarintHcsshim(dAtA, i, uint64(m.KernelTime_100Ns))
}
if m.MemoryCommitBytes != 0 {
dAtA[i] = 0x20
i++
i = encodeVarintHcsshim(dAtA, i, uint64(m.MemoryCommitBytes))
}
if m.MemoryWorkingSetPrivateBytes != 0 {
dAtA[i] = 0x28
i++
i = encodeVarintHcsshim(dAtA, i, uint64(m.MemoryWorkingSetPrivateBytes))
}
if m.MemoryWorkingSetSharedBytes != 0 {
dAtA[i] = 0x30
i++
i = encodeVarintHcsshim(dAtA, i, uint64(m.MemoryWorkingSetSharedBytes))
}
if m.ProcessID != 0 {
dAtA[i] = 0x38
i++
i = encodeVarintHcsshim(dAtA, i, uint64(m.ProcessID))
}
if m.UserTime_100Ns != 0 {
dAtA[i] = 0x40
i++
i = encodeVarintHcsshim(dAtA, i, uint64(m.UserTime_100Ns))
}
return i, nil
}
func encodeFixed64Hcsshim(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
dAtA[offset+1] = uint8(v >> 8)
@@ -112,6 +196,38 @@ func (m *CreateOptions) Size() (n int) {
return n
}
func (m *ProcessDetails) Size() (n int) {
var l int
_ = l
l = len(m.ImageName)
if l > 0 {
n += 1 + l + sovHcsshim(uint64(l))
}
if m.CreatedAt != nil {
l = m.CreatedAt.Size()
n += 1 + l + sovHcsshim(uint64(l))
}
if m.KernelTime_100Ns != 0 {
n += 1 + sovHcsshim(uint64(m.KernelTime_100Ns))
}
if m.MemoryCommitBytes != 0 {
n += 1 + sovHcsshim(uint64(m.MemoryCommitBytes))
}
if m.MemoryWorkingSetPrivateBytes != 0 {
n += 1 + sovHcsshim(uint64(m.MemoryWorkingSetPrivateBytes))
}
if m.MemoryWorkingSetSharedBytes != 0 {
n += 1 + sovHcsshim(uint64(m.MemoryWorkingSetSharedBytes))
}
if m.ProcessID != 0 {
n += 1 + sovHcsshim(uint64(m.ProcessID))
}
if m.UserTime_100Ns != 0 {
n += 1 + sovHcsshim(uint64(m.UserTime_100Ns))
}
return n
}
func sovHcsshim(x uint64) (n int) {
for {
n++
@@ -135,6 +251,23 @@ func (this *CreateOptions) String() string {
}, "")
return s
}
func (this *ProcessDetails) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&ProcessDetails{`,
`ImageName:` + fmt.Sprintf("%v", this.ImageName) + `,`,
`CreatedAt:` + strings.Replace(fmt.Sprintf("%v", this.CreatedAt), "Timestamp", "google_protobuf2.Timestamp", 1) + `,`,
`KernelTime_100Ns:` + fmt.Sprintf("%v", this.KernelTime_100Ns) + `,`,
`MemoryCommitBytes:` + fmt.Sprintf("%v", this.MemoryCommitBytes) + `,`,
`MemoryWorkingSetPrivateBytes:` + fmt.Sprintf("%v", this.MemoryWorkingSetPrivateBytes) + `,`,
`MemoryWorkingSetSharedBytes:` + fmt.Sprintf("%v", this.MemoryWorkingSetSharedBytes) + `,`,
`ProcessID:` + fmt.Sprintf("%v", this.ProcessID) + `,`,
`UserTime_100Ns:` + fmt.Sprintf("%v", this.UserTime_100Ns) + `,`,
`}`,
}, "")
return s
}
func valueToStringHcsshim(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
@@ -223,6 +356,232 @@ func (m *CreateOptions) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *ProcessDetails) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: ProcessDetails: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ProcessDetails: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ImageName", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthHcsshim
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ImageName = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthHcsshim
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.CreatedAt == nil {
m.CreatedAt = &google_protobuf2.Timestamp{}
}
if err := m.CreatedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field KernelTime_100Ns", wireType)
}
m.KernelTime_100Ns = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.KernelTime_100Ns |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field MemoryCommitBytes", wireType)
}
m.MemoryCommitBytes = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.MemoryCommitBytes |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 5:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field MemoryWorkingSetPrivateBytes", wireType)
}
m.MemoryWorkingSetPrivateBytes = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.MemoryWorkingSetPrivateBytes |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 6:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field MemoryWorkingSetSharedBytes", wireType)
}
m.MemoryWorkingSetSharedBytes = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.MemoryWorkingSetSharedBytes |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 7:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ProcessID", wireType)
}
m.ProcessID = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ProcessID |= (uint32(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 8:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field UserTime_100Ns", wireType)
}
m.UserTime_100Ns = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.UserTime_100Ns |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipHcsshim(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthHcsshim
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipHcsshim(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
@@ -333,20 +692,35 @@ func init() {
}
var fileDescriptorHcsshim = []byte{
// 227 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4a, 0xcf, 0x2c, 0xc9,
0x28, 0x4d, 0xd2,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xd6, 0x48, 0xec,
0x24, 0x36, 0xb0, 0x5b, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x75, 0x31, 0x65, 0xd0, 0x5f,
0x01, 0x00, 0x00,
// 473 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xc1, 0x6e, 0xd3, 0x30,
0x1c, 0xc6, 0x1b, 0x36, 0xc6, 0x6a, 0x54, 0x60, 0x86, 0x43, 0x28, 0x90, 0x54, 0xbb, 0x50, 0x09,
0x94, 0x74, 0x70, 0x42, 0x5c, 0x20, 0xab, 0x90, 0x76, 0x19, 0x53, 0x86, 0x84, 0xb4, 0x8b, 0xe5,
0x26, 0x7f, 0x52, 0x6b, 0xb5, 0x1d, 0xd9, 0x2e, 0xd5, 0x6e, 0x3c, 0x06, 0x0f, 0xc1, 0x83, 0xf4,
0xc8, 0x91, 0xd3, 0x60, 0x79, 0x12, 0x14, 0xdb, 0x2d, 0x63, 0x70, 0xda, 0xed, 0x1f, 0x7f, 0xbf,
0xef, 0xfb, 0xc7, 0x5f, 0x82, 0xb2, 0x8a, 0x99, 0xe9, 0x7c, 0x92, 0x14, 0x92, 0xa7, 0x85, 0x14,
0x86, 0x32, 0x01, 0xaa, 0xbc, 0x3c, 0x2e, 0x98, 0x28, 0xe5, 0x42, 0xa7, 0xd3, 0x42, 0xeb, 0x29,
0xe3, 0xb2, 0x36, 0xeb, 0x39, 0xa9, 0x95, 0x34, 0x12, 0xf7, 0xff, 0xd0, 0x89, 0xa7, 0x13, 0x4f,
0xf4, 0x1f, 0x54, 0xb2, 0x92, 0x16, 0x4b, 0xdb, 0xc9, 0x39, 0xfa, 0x51, 0x25, 0x65, 0x35, 0x83,
0xd4, 0x3e, 0x4d, 0xe6, 0x9f, 0xd2, 0x72, 0xae, 0xa8, 0x61, 0x52, 0x78, 0x3d, 0xbe, 0xaa, 0x1b,
0xc6, 0x41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6, 0xe5, 0xcc, 0x37, 0xad, 0xf9, 0xb1,
0xe3, 0x3e, 0x3a, 0xec, 0x18, 0xcc, 0x91, 0x83, 0x5c, 0xce, 0x18, 0xc5, 0xff, 0xc9, 0xd1, 0x53,
0xaa, 0xa0, 0xf4, 0x31, 0x5b, 0x36, 0xe6, 0xd1, 0xd5, 0x98, 0x63, 0xcb, 0xb8, 0x94, 0xe7, 0x08,
0xd5, 0xae, 0x56, 0xc2, 0xca, 0xf0, 0xd6, 0x20, 0x18, 0xf6, 0xb2, 0x5e, 0x73, 0x1e, 0x77, 0x7d,
0xd9, 0x07, 0xe3, 0xbc, 0xeb, 0x81, 0x83, 0x12, 0x3f, 0x45, 0xf7, 0xe6, 0x1a, 0xd4, 0x5f, 0xb5,
0x6c, 0xdb, 0x25, 0xbd, 0xf6, 0x7c, 0x5d, 0x4a, 0x76, 0xb2, 0xbc, 0x88, 0x3a, 0x3f, 0x2e, 0xa2,
0xce, 0x97, 0x26, 0x0a, 0x96, 0x4d, 0x14, 0x7c, 0x6f, 0xa2, 0xe0, 0x57, 0x13, 0x05, 0x27, 0x6f,
0xae, 0xf3, 0x93, 0xbf, 0xbe, 0x34, 0x4f, 0xb6, 0xec, 0xc7, 0x7b, 0xf9, 0x3b, 0x00, 0x00, 0xff,
0xff, 0x75, 0x5d, 0xc9, 0xa6, 0x2f, 0x03, 0x00, 0x00,
}

View File

@@ -4,9 +4,23 @@ package containerd.windows.hcsshim;
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/containerd/containerd/windows/hcsshimopts;hcsshimopts";
message CreateOptions {
google.protobuf.Duration terminate_duration = 1 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
}
// ProcessDetails contains additional information about a process
// ProcessDetails is made of the same fields as found in hcsshim.ProcessListItem
message ProcessDetails {
string image_name = 1;
google.protobuf.Timestamp created_at = 2;
uint64 kernel_time_100_ns = 3;
uint64 memory_commit_bytes = 4;
uint64 memory_working_set_private_bytes = 5;
uint64 memory_working_set_shared_bytes = 6;
uint32 process_id = 7;
uint64 user_time_100_ns = 8;
}

View File

@@ -29,11 +29,43 @@ file {
}
syntax: "proto3"
}
file {
name: "google/protobuf/timestamp.proto"
package: "google.protobuf"
message_type {
name: "Timestamp"
field {
name: "seconds"
number: 1
label: LABEL_OPTIONAL
type: TYPE_INT64
json_name: "seconds"
}
field {
name: "nanos"
number: 2
label: LABEL_OPTIONAL
type: TYPE_INT32
json_name: "nanos"
}
}
options {
java_package: "com.google.protobuf"
java_outer_classname: "TimestampProto"
java_multiple_files: true
go_package: "github.com/golang/protobuf/ptypes/timestamp"
cc_enable_arenas: true
objc_class_prefix: "GPB"
csharp_namespace: "Google.Protobuf.WellKnownTypes"
}
syntax: "proto3"
}
file {
name: "github.com/containerd/containerd/windows/hcsshimopts/hcsshim.proto"
package: "containerd.windows.hcsshim"
dependency: "gogoproto/gogo.proto"
dependency: "google/protobuf/duration.proto"
dependency: "google/protobuf/timestamp.proto"
message_type {
name: "CreateOptions"
field {
@@ -49,6 +81,66 @@ file {
json_name: "terminateDuration"
}
}
message_type {
name: "ProcessDetails"
field {
name: "image_name"
number: 1
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "imageName"
}
field {
name: "created_at"
number: 2
label: LABEL_OPTIONAL
type: TYPE_MESSAGE
type_name: ".google.protobuf.Timestamp"
json_name: "createdAt"
}
field {
name: "kernel_time_100_ns"
number: 3
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "kernelTime100Ns"
}
field {
name: "memory_commit_bytes"
number: 4
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "memoryCommitBytes"
}
field {
name: "memory_working_set_private_bytes"
number: 5
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "memoryWorkingSetPrivateBytes"
}
field {
name: "memory_working_set_shared_bytes"
number: 6
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "memoryWorkingSetSharedBytes"
}
field {
name: "process_id"
number: 7
label: LABEL_OPTIONAL
type: TYPE_UINT32
json_name: "processId"
}
field {
name: "user_time_100_ns"
number: 8
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "userTime100Ns"
}
}
options {
go_package: "github.com/containerd/containerd/windows/hcsshimopts;hcsshimopts"
}

View File

@@ -12,6 +12,7 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/runtime"
"github.com/containerd/containerd/windows/hcsshimopts"
"github.com/containerd/typeurl"
"github.com/gogo/protobuf/types"
specs "github.com/opencontainers/runtime-spec/specs-go"
@@ -213,20 +214,28 @@ func (t *task) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (runt
return p, nil
}
func (t *task) Pids(ctx context.Context) ([]uint32, error) {
func (t *task) Pids(ctx context.Context) ([]runtime.ProcessInfo, error) {
t.Lock()
defer t.Unlock()
var (
pids = make([]uint32, len(t.processes))
idx = 0
)
for _, p := range t.processes {
pids[idx] = p.Pid()
idx++
var infoList []runtime.ProcessInfo
hcsProcessList, err := t.hcsContainer.ProcessList()
if err != nil {
return nil, err
}
return pids, nil
for _, process := range hcsProcessList {
info, err := t.convertToProcessDetails(process)
if err != nil {
return nil, err
}
infoList = append(infoList, runtime.ProcessInfo{
Pid: process.ProcessId,
Info: info,
})
}
return infoList, nil
}
func (t *task) Checkpoint(_ context.Context, _ string, _ *types.Any) error {
@@ -388,3 +397,21 @@ func (t *task) cleanup() {
removeLayer(context.Background(), t.rwLayer)
t.Unlock()
}
// convertToProcessDetails converts a given hcsshim ProcessListItem to proto ProcessDetails
func (t *task) convertToProcessDetails(p hcsshim.ProcessListItem) (*hcsshimopts.ProcessDetails, error) {
protobufTime, err := types.TimestampProto(p.CreateTimestamp)
if err != nil {
return nil, errors.Wrapf(errdefs.ErrInvalidArgument, "failed to convert timestamp for process pid: %d\n", p.ProcessId)
}
return &hcsshimopts.ProcessDetails{
ImageName: p.ImageName,
CreatedAt: protobufTime,
KernelTime_100Ns: p.KernelTime100ns,
MemoryCommitBytes: p.MemoryCommitBytes,
MemoryWorkingSetPrivateBytes: p.MemoryWorkingSetPrivateBytes,
MemoryWorkingSetSharedBytes: p.MemoryWorkingSetSharedBytes,
ProcessID: p.ProcessId,
UserTime_100Ns: p.UserTime100ns,
}, nil
}