diff options
author | Ricardo Velhote <rvelhote@gmail.com> | 2017-05-14 19:18:26 +0100 |
---|---|---|
committer | Ricardo Velhote <rvelhote@gmail.com> | 2017-06-25 20:25:45 +0100 |
commit | c07475294ae2c60f1dcc394922838b1f1f57b476 (patch) | |
tree | c319c0083959385a694e7b30ea7f00422c5c82b1 /src/rpc/server.cpp | |
parent | d609fd85ca41c003233d74fbd6c680970ad4a48b (diff) |
[RPC] Add an uptime command that displays the amount of time that bitcoind has been running
Diffstat (limited to 'src/rpc/server.cpp')
-rw-r--r-- | src/rpc/server.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 1a04ce2b47..c320d20453 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -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() |