initctl: add what was missing from the JSON status

initctl -j status is for other programs and should have all there is,
the plain view is the one kept short.  It was the other way around:
the restart counter and restart-max were only in the plain view, and
the restart delay of restart-max-sec was not in the JSON either.

Add a restart object:

    "restarts": 7,
    "restart": {
      "count": 4,
      "max": -1,
      "delay": 160,
      "limit": 300
    },

Also add manual and started, and give starts for all services, not
only those with manual-start.  The restarts total stays where it is.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-19 20:39:43 +01:00
1 parent 308287923d
commit 9fa50746a7
4 files changed
+74 -5

No files matched your search

+20 -5
View File
@@ -1755,12 +1755,27 @@ static int json_status_one(FILE *fp, struct svc_row *r, char *indent, int prev)
fprintf(fp,
"%s \"condition\": %s,\n", indent, buf);
if (r->manual)
fprintf(fp,
"%s \"starts\": %u,\n", indent, r->starts);
fprintf(fp,
"%s \"restarts\": %d,\n", indent, r->restart_tot); /* XXX: add restart_cnt and restart_max */
"%s \"manual\": %s,\n"
"%s \"started\": %s,\n"
"%s \"starts\": %u,\n"
"%s \"restarts\": %d,\n"
"%s \"restart\": {\n"
"%s \"count\": %d,\n"
"%s \"max\": %d,\n"
"%s \"delay\": %u,\n"
"%s \"limit\": %u\n"
"%s },\n",
indent, r->manual ? "true" : "false",
indent, r->started ? "true" : "false",
indent, r->starts,
indent, r->restart_tot,
indent,
indent, r->restart_cnt,
indent, r->restart_max,
indent, r->restart_delay,
indent, r->restart_delay_max,
indent);
/* Add memory and CPU information if cgroup support is available */
if (cgrp && r->pid > 1) {