/* Route string will not include the endpoints. */ static void ping_cb (flux_t h, flux_msg_handler_t *w, const flux_msg_t *msg, void *arg) { module_t *p = arg; const char *json_str; JSON o = NULL; char *route = NULL; char *route_plus_uuid = NULL; int rc = -1; if (flux_request_decode (msg, NULL, &json_str) < 0) goto done; if (!(o = Jfromstr (json_str))) { errno = EPROTO; goto done; } if (!(route = flux_msg_get_route_string (msg))) goto done; route_plus_uuid = xasprintf ("%s!%.5s", route, module_get_uuid (p)); Jadd_str (o, "route", route_plus_uuid); rc = 0; done: if (flux_respond (h, msg, rc < 0 ? errno : 0, rc < 0 ? NULL : Jtostr (o)) < 0) FLUX_LOG_ERROR (h); Jput (o); if (route_plus_uuid) free (route_plus_uuid); if (route) free (route); }
static void stats_clear_request_cb (flux_t h, flux_msg_handler_t *w, const flux_msg_t *msg, void *arg) { flux_clr_msgcounters (h); if (flux_respond (h, msg, 0, NULL) < 0) FLUX_LOG_ERROR (h); }
static void stop_cb (flux_t *h, flux_msg_handler_t *mh, const flux_msg_t *msg, void *arg) { if (flux_request_decode (msg, NULL, NULL) < 0) goto error; #if WITH_TCMALLOC if (!IsHeapProfilerRunning ()) { errno = EINVAL; goto error; } HeapProfilerStop(); #else errno = ENOSYS; goto error; #endif /* WITH_TCMALLOC */ if (flux_respond (h, msg, 0, NULL) < 0) FLUX_LOG_ERROR (h); return; error: if (flux_respond (h, msg, errno, NULL) < 0) FLUX_LOG_ERROR (h); }
static void dump_cb (flux_t *h, flux_msg_handler_t *mh, const flux_msg_t *msg, void *arg) { const char *reason; if (flux_request_unpack (msg, NULL, "{s:s}", "reason", &reason) < 0) goto error; #if WITH_TCMALLOC if (!IsHeapProfilerRunning ()) { errno = EINVAL; goto error; } HeapProfilerDump (reason); #else errno = ENOSYS; goto error; #endif if (flux_respond (h, msg, 0, NULL) < 0) FLUX_LOG_ERROR (h); return; error: if (flux_respond (h, msg, errno, NULL) < 0) FLUX_LOG_ERROR (h); }
static void start_cb (flux_t *h, flux_msg_handler_t *mh, const flux_msg_t *msg, void *arg) { const char *filename; if (flux_request_unpack (msg, NULL, "{s:s}", "filename", &filename) < 0) goto error; #if WITH_TCMALLOC if (IsHeapProfilerRunning ()) { errno = EINVAL; goto error; } HeapProfilerStart (filename); #else errno = ENOSYS; goto error; #endif if (flux_respond (h, msg, 0, NULL) < 0) FLUX_LOG_ERROR (h); return; error: if (flux_respond (h, msg, errno, NULL) < 0) FLUX_LOG_ERROR (h); }
static void rusage_cb (flux_t h, flux_msg_handler_t *w, const flux_msg_t *msg, void *arg) { JSON out = NULL; int rc = -1; if (getrusage_json (RUSAGE_THREAD, &out) < 0) goto done; rc = 0; done: if (flux_respond (h, msg, rc < 0 ? errno : 0, rc < 0 ? NULL : Jtostr (out)) < 0) FLUX_LOG_ERROR (h); Jput (out); }
static void stats_get_cb (flux_t h, flux_msg_handler_t *w, const flux_msg_t *msg, void *arg) { flux_msgcounters_t mcs; JSON out = Jnew (); flux_get_msgcounters (h, &mcs); Jadd_int (out, "#request (tx)", mcs.request_tx); Jadd_int (out, "#request (rx)", mcs.request_rx); Jadd_int (out, "#response (tx)", mcs.response_tx); Jadd_int (out, "#response (rx)", mcs.response_rx); Jadd_int (out, "#event (tx)", mcs.event_tx); Jadd_int (out, "#event (rx)", mcs.event_rx); Jadd_int (out, "#keepalive (tx)", mcs.keepalive_tx); Jadd_int (out, "#keepalive (rx)", mcs.keepalive_rx); if (flux_respond (h, msg, 0, Jtostr (out)) < 0) FLUX_LOG_ERROR (h); Jput (out); }