The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4142
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Title is self-explanatory :) Reason to have this done is that I saw this post: https://discuss.linuxcontainers.org/t/lxc-list-column-for-process-number/1017/4 and seemed pretty easy to implement.
From 1f90bc8a722ace1546e5a071e97577c1cbdd84d1 Mon Sep 17 00:00:00 2001 From: David Negreira <da...@otherreality.net> Date: Sat, 6 Jan 2018 15:53:03 +0100 Subject: [PATCH 1/2] lxc_list: Option to display number of processes Signed-off-by: David Negreira <da...@otherreality.net> --- lxc/list.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lxc/list.go b/lxc/list.go index 9599e61e1..4796af0d4 100644 --- a/lxc/list.go +++ b/lxc/list.go @@ -93,6 +93,8 @@ Pre-defined column shorthand chars: n - Name + N - Number of Processes + p - PID of the container's init process P - Profiles @@ -463,6 +465,7 @@ func (c *listCmd) parseColumns() ([]column, error) { 'd': {i18n.G("DESCRIPTION"), c.descriptionColumnData, false, false}, 'l': {i18n.G("LAST USED AT"), c.LastUsedColumnData, false, false}, 'n': {i18n.G("NAME"), c.nameColumnData, false, false}, + 'N': {i18n.G("PROCESSES"), c.NumberOfProcessesColumnData, true, false}, 'p': {i18n.G("PID"), c.PIDColumnData, true, false}, 'P': {i18n.G("PROFILES"), c.ProfilesColumnData, false, false}, 'S': {i18n.G("SNAPSHOTS"), c.numberSnapshotsColumnData, false, true}, @@ -675,3 +678,12 @@ func (c *listCmd) LastUsedColumnData(cInfo api.Container, cState *api.ContainerS return "" } + +func (c *listCmd) NumberOfProcessesColumnData(cInfo api.Container, cState *api.ContainerState, cSnaps []api.ContainerSnapshot) string { + if cInfo.IsActive() && cState != nil { + return fmt.Sprintf("%d", cState.Processes) + } + + return "" + +} From a0c232174b36fb882105de2643754b6f091329ad Mon Sep 17 00:00:00 2001 From: David Negreira <da...@otherreality.net> Date: Sat, 6 Jan 2018 15:54:30 +0100 Subject: [PATCH 2/2] lxc_list_test: added N option to tests Signed-off-by: David Negreira <da...@otherreality.net> --- lxc/list_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc/list_test.go b/lxc/list_test.go index 6bdf62e0d..915f985fd 100644 --- a/lxc/list_test.go +++ b/lxc/list_test.go @@ -52,7 +52,7 @@ func TestShouldShow(t *testing.T) { } // Used by TestColumns and TestInvalidColumns -const shorthand = "46abcdlnpPsSt" +const shorthand = "46abcdlnNpPsSt" const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" func TestColumns(t *testing.T) {
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel