summaryrefslogtreecommitdiff
path: root/src/systemd-cgtop
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-09-14 18:33:57 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-09-14 18:33:57 -0400
commit3c72c8d3ee67388336aca58c5afa3fb93a9c24c0 (patch)
treed072df7fee0f5906fad88c08398b2fe887cbc064 /src/systemd-cgtop
parente51613a3291342c6006edda8783755fb8994fd75 (diff)
parent6ba6ca19507add38549e07058c57489a8cd98cd1 (diff)
Merge branch 'notsystemd/postmove' into notsystemd/master
# Conflicts: # src/grp-journal/systemd-journald/Makefile # src/grp-login/systemd-logind/Makefile # src/grp-machine/grp-import/systemd-export/Makefile # src/grp-machine/grp-import/systemd-import/Makefile # src/grp-machine/grp-import/systemd-pull/Makefile # src/grp-machine/systemd-machined/Makefile # src/grp-network/libnetworkd-core/Makefile # src/grp-resolve/libbasic-dns/Makefile # src/grp-resolve/systemd-resolved/Makefile # src/grp-utils/systemd-path/Makefile # src/libshared/src/Makefile # src/libsystemd-network/include/systemd-network/sd-ndisc.h # src/libsystemd/Makefile # src/libsystemd/src/test.mk # src/libudev/Makefile # src/systemd-dbus1-generator/Makefile # src/systemd-nspawn/nspawn.c Signed-off-by: Luke Shumaker <lukeshu@sbcglobal.net>
Diffstat (limited to 'src/systemd-cgtop')
-rw-r--r--src/systemd-cgtop/Makefile2
-rw-r--r--src/systemd-cgtop/cgtop.c24
-rw-r--r--src/systemd-cgtop/systemd-cgtop.xml8
3 files changed, 28 insertions, 6 deletions
diff --git a/src/systemd-cgtop/Makefile b/src/systemd-cgtop/Makefile
index 4980eed15b..abebe7f3d0 100644
--- a/src/systemd-cgtop/Makefile
+++ b/src/systemd-cgtop/Makefile
@@ -28,6 +28,6 @@ systemd_cgtop_SOURCES = \
src/cgtop/cgtop.c
systemd_cgtop_LDADD = \
- libshared.la
+ libsystemd-shared.la
include $(topsrcdir)/build-aux/Makefile.tail.mk
diff --git a/src/systemd-cgtop/cgtop.c b/src/systemd-cgtop/cgtop.c
index 91cab3f6b1..f23ebf4f57 100644
--- a/src/systemd-cgtop/cgtop.c
+++ b/src/systemd-cgtop/cgtop.c
@@ -72,6 +72,7 @@ static bool arg_batch = false;
static bool arg_raw = false;
static usec_t arg_delay = 1*USEC_PER_SEC;
static char* arg_machine = NULL;
+static char* arg_root = NULL;
static bool arg_recursive = true;
static enum {
@@ -558,7 +559,7 @@ static void display(Hashmap *a) {
assert(a);
- if (on_tty())
+ if (!terminal_is_dumb())
fputs(ANSI_HOME_CLEAR, stdout);
array = alloca(sizeof(Group*) * hashmap_size(a));
@@ -653,7 +654,7 @@ static void display(Hashmap *a) {
}
static void help(void) {
- printf("%s [OPTIONS...]\n\n"
+ printf("%s [OPTIONS...] [CGROUP]\n\n"
"Show top control groups by their resource usage.\n\n"
" -h --help Show this help\n"
" --version Show package version\n"
@@ -835,7 +836,13 @@ static int parse_argv(int argc, char *argv[]) {
assert_not_reached("Unhandled option");
}
- if (optind < argc) {
+ if (optind == argc-1) {
+ if (arg_machine) {
+ log_error("Specifying a control group path together with the -M option is not allowed");
+ return -EINVAL;
+ }
+ arg_root = argv[optind];
+ } else if (optind < argc) {
log_error("Too many arguments.");
return -EINVAL;
}
@@ -864,6 +871,17 @@ static int get_cgroup_root(char **ret) {
const char *m;
int r;
+ if (arg_root) {
+ char *aux;
+
+ aux = strdup(arg_root);
+ if (!aux)
+ return log_oom();
+
+ *ret = aux;
+ return 0;
+ }
+
if (!arg_machine) {
r = cg_get_root_path(ret);
if (r < 0)
diff --git a/src/systemd-cgtop/systemd-cgtop.xml b/src/systemd-cgtop/systemd-cgtop.xml
index c76f646984..be13631239 100644
--- a/src/systemd-cgtop/systemd-cgtop.xml
+++ b/src/systemd-cgtop/systemd-cgtop.xml
@@ -52,6 +52,7 @@
<cmdsynopsis>
<command>systemd-cgtop</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
+ <arg choice="opt">GROUP</arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -62,7 +63,9 @@
groups of the local Linux control group hierarchy, ordered by
their CPU, memory, or disk I/O load. The display is refreshed in
regular intervals (by default every 1s), similar in style to
- <citerefentry project='man-pages'><refentrytitle>top</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
+ <citerefentry project='man-pages'><refentrytitle>top</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
+ If a control group path is specified, shows only the services of
+ the specified control group.</para>
<para>If <command>systemd-cgtop</command> is not connected to a
tty, no column headers are printed and the default is to only run
@@ -252,7 +255,8 @@
<listitem><para>Limit control groups shown to the part
corresponding to the container
- <replaceable>MACHINE</replaceable>.</para></listitem>
+ <replaceable>MACHINE</replaceable>.
+ This option may not be used when a control group path is specified.</para></listitem>
</varlistentry>
<xi:include href="standard-options.xml" xpointer="help" />