@@ -283,11 +283,37 @@ static UniValue uptime(const JSONRPCRequest& jsonRequest)
283283 return GetTime () - GetStartupTime ();
284284}
285285
286+ static UniValue getrpcinfo (const JSONRPCRequest& request)
287+ {
288+ if (request.fHelp || request.params .size () > 0 ) {
289+ throw std::runtime_error (
290+ RPCHelpMan{" getrpcinfo" ,
291+ " \n Returns details of the RPC server.\n " , {}}
292+ .ToString ()
293+ );
294+ }
295+
296+ LOCK (g_rpc_server_info.mutex );
297+ UniValue active_commands (UniValue::VARR);
298+ for (const RPCCommandExecutionInfo& info : g_rpc_server_info.active_commands ) {
299+ UniValue entry (UniValue::VOBJ);
300+ entry.pushKV (" method" , info.method );
301+ entry.pushKV (" duration" , GetTimeMicros () - info.start );
302+ active_commands.push_back (entry);
303+ }
304+
305+ UniValue result (UniValue::VOBJ);
306+ result.pushKV (" active_commands" , active_commands);
307+
308+ return result;
309+ }
310+
286311// clang-format off
287312static const CRPCCommand vRPCCommands[] =
288313{ // category name actor (function) argNames
289314 // --------------------- ------------------------ ----------------------- ----------
290315 /* Overall control/query calls */
316+ { " control" , " getrpcinfo" , &getrpcinfo, {} },
291317 { " control" , " help" , &help, {" command" } },
292318 { " control" , " stop" , &stop, {" wait" } },
293319 { " control" , " uptime" , &uptime, {} },
0 commit comments