Skip to content

Commit 0c85ea8

Browse files
authored
Merge pull request #459 from rical/add-mem-to-initctl-json
initctl: add memory field to JSON status output
2 parents c23952c + c3839ed commit 0c85ea8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/initctl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,16 @@ static int json_status_one(FILE *fp, svc_t *svc, char *indent, int prev)
10481048
"%s \"starts\": %d,\n", indent, svc->once);
10491049
fprintf(fp,
10501050
"%s \"restarts\": %d,\n", indent, svc->restart_tot); /* XXX: add restart_cnt and restart_max */
1051+
1052+
/* Add memory information if cgroup support is available */
1053+
if (cgrp && svc->pid > 1) {
1054+
char *group = pid_cgroup(svc->pid);
1055+
if (group) {
1056+
fprintf(fp, "%s \"memory\": %lu,\n", indent, cgroup_memory(group));
1057+
free(group);
1058+
}
1059+
}
1060+
10511061
fprintf(fp,
10521062
"%s \"pidfile\": \"%s\",\n"
10531063
"%s \"pid\": %d,\n"

0 commit comments

Comments
 (0)