Skip to content

Commit 10fba12

Browse files
committed
job-ingest: override job-ingest.stats.get RPC
Problem: it would be useful to show some statistics about workcrews in 'flux module stats' output. Override the job-ingest.stats.get RPC and provide pipeline statistics instead of the default message counts.
1 parent 7f1b91b commit 10fba12

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/modules/job-ingest/job-ingest.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,11 +708,36 @@ static void reload_cb (flux_t *h,
708708
flux_log_error (h, "error responding to config-reload request");
709709
}
710710

711+
static void stats_get_cb (flux_t *h,
712+
flux_msg_handler_t *mh,
713+
const flux_msg_t *msg,
714+
void *arg)
715+
{
716+
struct job_ingest_ctx *ctx = arg;
717+
json_t *pstats = NULL;
718+
719+
if (flux_request_decode (msg, NULL, NULL) < 0)
720+
goto error;
721+
pstats = pipeline_stats_get (ctx->pipeline);
722+
if (flux_respond_pack (h,
723+
msg,
724+
"{s:O}",
725+
"pipeline", pstats) < 0)
726+
flux_log_error (h, "error responding to stats.get request");
727+
json_decref (pstats);
728+
return;
729+
error:
730+
if (flux_respond_error (h, msg, errno, NULL) < 0)
731+
flux_log_error (h, "error responding to stats.get request");
732+
}
733+
734+
711735
static const struct flux_msg_handler_spec htab[] = {
712736
{ FLUX_MSGTYPE_REQUEST, "job-ingest.getinfo", getinfo_cb, 0},
713737
{ FLUX_MSGTYPE_REQUEST, "job-ingest.submit", submit_cb, FLUX_ROLE_USER },
714738
{ FLUX_MSGTYPE_REQUEST, "job-ingest.shutdown", shutdown_cb, 0 },
715739
{ FLUX_MSGTYPE_REQUEST, "job-ingest.config-reload", reload_cb, 0 },
740+
{ FLUX_MSGTYPE_REQUEST, "job-ingest.stats.get", stats_get_cb, 0 },
716741
FLUX_MSGHANDLER_TABLE_END,
717742
};
718743

0 commit comments

Comments
 (0)