diff options
-rw-r--r-- | loleaflet/admin/admin.html | 4 | ||||
-rw-r--r-- | loleaflet/admin/admin.strings.js | 1 | ||||
-rw-r--r-- | loleaflet/admin/src/AdminSocketOverview.js | 7 | ||||
-rwxr-xr-x | scripts/unocommands.py | 2 | ||||
-rw-r--r-- | wsd/Admin.cpp | 3 | ||||
-rw-r--r-- | wsd/AdminModel.cpp | 8 | ||||
-rw-r--r-- | wsd/AdminModel.hpp | 2 | ||||
-rw-r--r-- | wsd/LOOLWSD.cpp | 4 | ||||
-rw-r--r-- | wsd/LOOLWSD.hpp | 2 |
9 files changed, 31 insertions, 2 deletions
diff --git a/loleaflet/admin/admin.html b/loleaflet/admin/admin.html index ecd67cdb9e..342d6ea808 100644 --- a/loleaflet/admin/admin.html +++ b/loleaflet/admin/admin.html @@ -85,6 +85,10 @@ <div class="main-data" id="recv_bytes">0</div> <h4><script>document.write(l10nstrings.strRecvBytes)</script></h4> </div> + <div class="col-xs-6 col-sm-2 placeholder"> + <div class="main-data" id="uptime">0</div> + <h4><script>document.write(l10nstrings.strServerUptime)</script></h4> + </div> </div> <div class="container-fluid"> <ul class="nav nav-tabs"> diff --git a/loleaflet/admin/admin.strings.js b/loleaflet/admin/admin.strings.js index 29713a8dfd..7dea1cdd30 100644 --- a/loleaflet/admin/admin.strings.js +++ b/loleaflet/admin/admin.strings.js @@ -40,6 +40,7 @@ l10nstrings.strDocuments = _('Documents:'); l10nstrings.strExpired = _('Expired:'); l10nstrings.strRefresh = _('Refresh'); l10nstrings.strShutdown = _('Shutdown Server'); +l10nstrings.strServerUptime = _('Server uptime') if (module) { module.exports = l10nstrings; diff --git a/loleaflet/admin/src/AdminSocketOverview.js b/loleaflet/admin/src/AdminSocketOverview.js index 15444e9a6f..9c61089ccc 100644 --- a/loleaflet/admin/src/AdminSocketOverview.js +++ b/loleaflet/admin/src/AdminSocketOverview.js @@ -51,6 +51,7 @@ var AdminSocketOverview = AdminSocketBase.extend({ this.socket.send('active_users_count'); this.socket.send('sent_bytes'); this.socket.send('recv_bytes'); + this.socket.send('uptime') }, onSocketOpen: function() { @@ -311,7 +312,8 @@ var AdminSocketOverview = AdminSocketBase.extend({ textMsg.startsWith('active_docs_count') || textMsg.startsWith('active_users_count') || textMsg.startsWith('sent_bytes') || - textMsg.startsWith('recv_bytes')) + textMsg.startsWith('recv_bytes') || + textMsg.startsWith('uptime')) { textMsg = textMsg.split(' '); var sCommand = textMsg[0]; @@ -322,6 +324,9 @@ var AdminSocketOverview = AdminSocketBase.extend({ sCommand === 'recv_bytes') { nData = Util.humanizeMem(nData); } + else if (sCommand === 'uptime') { + nData = Util.humanizeSecs(nData) + } $(document.getElementById(sCommand)).text(nData); } else if (textMsg.startsWith('rmdoc')) { diff --git a/scripts/unocommands.py b/scripts/unocommands.py index 3e5ec6bb88..a28c3ab5dc 100755 --- a/scripts/unocommands.py +++ b/scripts/unocommands.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- # # This file is part of the LibreOffice project. 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(); |