summaryrefslogtreecommitdiffstats
path: root/wsd
diff options
context:
space:
mode:
Diffstat (limited to 'wsd')
-rw-r--r--wsd/Admin.cpp3
-rw-r--r--wsd/AdminModel.cpp8
-rw-r--r--wsd/AdminModel.hpp2
-rw-r--r--wsd/LOOLWSD.cpp4
-rw-r--r--wsd/LOOLWSD.hpp2
5 files changed, 19 insertions, 0 deletions
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index ea3d5b5be6..9d9fc25489 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -152,6 +152,9 @@ void AdminSocketHandler::handleMessage(bool /* fin */, WSOpCode /* code */,
else if (tokens[0] == "recv_bytes")
sendTextFrame("recv_bytes " + std::to_string(model.getRecvBytesTotal() / 1024));
+ else if (tokens[0] == "uptime")
+ sendTextFrame("uptime " + std::to_string(model.getServerUptime()));
+
else if (tokens[0] == "kill" && tokens.count() == 2)
{
try
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index df15297243..e0074ce5f7 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -11,6 +11,7 @@
#include "AdminModel.hpp"
+#include <chrono>
#include <memory>
#include <set>
#include <sstream>
@@ -733,4 +734,11 @@ void AdminModel::updateMemoryDirty(const std::string& docKey, int dirty)
}
}
+double AdminModel::getServerUptime()
+{
+ auto currentTime = std::chrono::system_clock::now();
+ std::chrono::duration<double> uptime = currentTime - LOOLWSD::StartTime;
+ return uptime.count();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index 2b69f900b7..57e7193e19 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -284,6 +284,8 @@ public:
uint64_t getSentBytesTotal() { return _sentBytesTotal; }
uint64_t getRecvBytesTotal() { return _recvBytesTotal; }
+ double getServerUptime();
+
/// Document basic info list sorted by most idle time
std::vector<DocBasicInfo> getDocumentsSortedByIdle() const;
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 0e0fe60983..f1e3d92fd9 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -42,6 +42,7 @@
#include <cstdlib>
#include <cstring>
#include <ctime>
+#include <chrono>
#include <fstream>
#include <iostream>
#include <map>
@@ -716,6 +717,7 @@ unsigned LOOLWSD::MaxConnections;
unsigned LOOLWSD::MaxDocuments;
std::string LOOLWSD::OverrideWatermark;
std::set<const Poco::Util::AbstractConfiguration*> LOOLWSD::PluginConfigurations;
+std::chrono::time_point<std::chrono::system_clock> LOOLWSD::StartTime;
static std::string UnitTestLibrary;
@@ -774,6 +776,8 @@ void LOOLWSD::initialize(Application& self)
throw std::runtime_error("Failed to load wsd unit test library.");
}
+ StartTime = std::chrono::system_clock::now();
+
auto& conf = config();
// Add default values of new entries here.
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 53fe4deb23..6928cb6f9d 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -12,6 +12,7 @@
#include <algorithm>
#include <atomic>
+#include <chrono>
#include <map>
#include <set>
#include <string>
@@ -73,6 +74,7 @@ public:
static unsigned MaxDocuments;
static std::string OverrideWatermark;
static std::set<const Poco::Util::AbstractConfiguration*> PluginConfigurations;
+ static std::chrono::time_point<std::chrono::system_clock> StartTime;
static std::vector<int> getKitPids();