Skip to content

Commit

Permalink
Merge pull request #65 from Microsoft/jjh/processlist
Browse files Browse the repository at this point in the history
Add support for ProcessList
  • Loading branch information
darstahl authored Aug 18, 2016
2 parents 600757d + 4a0988d commit e5e415e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
44 changes: 36 additions & 8 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var (
const (
pendingUpdatesQuery = `{ "PropertyTypes" : ["PendingUpdates"]}`
statisticsQuery = `{ "PropertyTypes" : ["Statistics"]}`
processListQuery = `{ "PropertyTypes" : ["ProcessList"]}`
)

type container struct {
Expand All @@ -29,14 +30,15 @@ type containerProperties struct {
Name string
SystemType string
Owner string
SiloGUID string `json:"SiloGuid,omitempty"`
IsDummy bool `json:",omitempty"`
RuntimeID string `json:"RuntimeId,omitempty"`
Stopped bool `json:",omitempty"`
ExitType string `json:",omitempty"`
AreUpdatesPending bool `json:",omitempty"`
ObRoot string `json:",omitempty"`
Statistics Statistics `json:",omitempty"`
SiloGUID string `json:"SiloGuid,omitempty"`
IsDummy bool `json:",omitempty"`
RuntimeID string `json:"RuntimeId,omitempty"`
Stopped bool `json:",omitempty"`
ExitType string `json:",omitempty"`
AreUpdatesPending bool `json:",omitempty"`
ObRoot string `json:",omitempty"`
Statistics Statistics `json:",omitempty"`
ProcessList []ProcessListItem `json:",omitempty"`
}

// MemoryStats holds the memory statistics for a container
Expand Down Expand Up @@ -84,6 +86,18 @@ type Statistics struct {
Network []NetworkStats `json:",omitempty"`
}

// ProcessList is the structure of an item returned by a ProcessList call on a container
type ProcessListItem struct {
CreateTimestamp time.Time `json:",omitempty"`
ImageName string `json:",omitempty"`
KernelTime100ns uint64 `json:",omitempty"`
MemoryCommitBytes uint64 `json:",omitempty"`
MemoryWorkingSetPrivateBytes uint64 `json:",omitempty"`
MemoryWorkingSetSharedBytes uint64 `json:",omitempty"`
ProcessId uint32 `json:",omitempty"`
UserTime100ns uint64 `json:",omitempty"`
}

// CreateContainer creates a new container with the given configuration but does not start it.
func CreateContainer(id string, c *ContainerConfig) (Container, error) {
operation := "CreateContainer"
Expand Down Expand Up @@ -326,6 +340,20 @@ func (container *container) Statistics() (Statistics, error) {
return properties.Statistics, nil
}

// ProcessList returns an array of ProcessListItems for the container
func (container *container) ProcessList() ([]ProcessListItem, error) {
operation := "ProcessList"
title := "HCSShim::Container::" + operation
logrus.Debugf(title+" id=%s", container.id)
properties, err := container.properties(processListQuery)
if err != nil {
return nil, makeContainerError(container, operation, "", err)
}

logrus.Debugf(title+" succeeded id=%s", container.id)
return properties.ProcessList, nil
}

// Pause pauses the execution of the container. This feature is not enabled in TP5.
func (container *container) Pause() error {
operation := "Pause"
Expand Down
3 changes: 3 additions & 0 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ type Container interface {
// Statistics returns statistics for a container.
Statistics() (Statistics, error)

// ProcessList returns details for the processes in a container.
ProcessList() ([]ProcessListItem, error)

// CreateProcess launches a new process within the container.
CreateProcess(c *ProcessConfig) (Process, error)

Expand Down

0 comments on commit e5e415e

Please sign in to comment.