initctl: add Memory: and CGroup: to process status command

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-03-19 09:33:52 +01:00
1 parent 3107027132
commit ff86f29f41
1 file changed
+20
+20
View File
@@ -600,6 +600,21 @@ static char *status(svc_t *svc)
return buf; return buf;
} }
static void show_cgroup_tree(char *group, char *pfx)
{
char path[256];
if (!group) {
puts("");
return;
}
strlcpy(path, FINIT_CGPATH, sizeof(path));
strlcat(path, group, sizeof(path));
cgroup_tree(path, pfx, 0);
}
static int show_status(char *arg) static int show_status(char *arg)
{ {
char ident[MAX_IDENT_LEN]; char ident[MAX_IDENT_LEN];
@@ -611,6 +626,7 @@ static int show_status(char *arg)
if (arg && arg[0]) { if (arg && arg[0]) {
long now = jiffies(); long now = jiffies();
char uptm[42] = "N/A"; char uptm[42] = "N/A";
char *group;
svc = client_svc_find(arg); svc = client_svc_find(arg);
if (!svc) if (!svc)
@@ -629,6 +645,10 @@ static int show_status(char *arg)
printf("Group : %s\n", svc->group); printf("Group : %s\n", svc->group);
printf("Uptime : %s\n", svc->pid ? uptime(now - svc->start_time, uptm, sizeof(uptm)) : uptm); printf("Uptime : %s\n", svc->pid ? uptime(now - svc->start_time, uptm, sizeof(uptm)) : uptm);
printf("Runlevels : %s\n", runlevel_string(runlevel, svc->runlevels)); printf("Runlevels : %s\n", runlevel_string(runlevel, svc->runlevels));
group = pid_cgroup(svc->pid, buf, sizeof(buf));
printf("Memory; : %s\n", memsz(cgroup_memory(group), uptm, sizeof(uptm)));
printf("CGroup : %s\n", group);
show_cgroup_tree(group, " ");
printf("\n"); printf("\n");
return do_log(svc->cmd); return do_log(svc->cmd);