[RPC] Add an uptime command that displays the amount of time that bitcoind has been running

This commit is contained in:
Ricardo Velhote
2017-05-14 19:18:26 +01:00
parent d609fd85ca
commit c07475294a
6 changed files with 63 additions and 3 deletions

View File

@@ -258,6 +258,22 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
return "Bitcoin server stopping";
}
UniValue uptime(const JSONRPCRequest& jsonRequest)
{
if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
throw std::runtime_error(
"uptime\n"
"\nReturns the total uptime of the server.\n"
"\nResult:\n"
"ttt (numeric) The number of seconds that the server has been running\n"
"\nExamples:\n"
+ HelpExampleCli("uptime", "")
+ HelpExampleRpc("uptime", "")
);
return GetTime() - GetStartupTime();
}
/**
* Call Table
*/
@@ -267,6 +283,7 @@ static const CRPCCommand vRPCCommands[] =
/* Overall control/query calls */
{ "control", "help", &help, true, {"command"} },
{ "control", "stop", &stop, true, {} },
{ "control", "uptime", &uptime, true, {} },
};
CRPCTable::CRPCTable()