loleaflet/admin/admin.html | 4 ++++ loleaflet/admin/admin.strings.js | 1 + loleaflet/admin/src/AdminSocketOverview.js | 7 ++++++- scripts/unocommands.py | 2 +- wsd/Admin.cpp | 3 +++ wsd/AdminModel.cpp | 8 ++++++++ wsd/AdminModel.hpp | 2 ++ wsd/LOOLWSD.cpp | 4 ++++ wsd/LOOLWSD.hpp | 2 ++ 9 files changed, 31 insertions(+), 2 deletions(-)
New commits: commit c81dd0265507e9fbf8b468c766d1d9709ec0d7ec Author: George <gwoodc...@gmail.com> AuthorDate: Fri Jul 19 11:39:59 2019 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Fri Jul 19 22:21:55 2019 +0200 added server uptime field to admin console Change-Id: Id23fee1299b87095f186ce7aaa8c2d2e0f3cef52 Reviewed-on: https://gerrit.libreoffice.org/75962 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Michael Meeks <michael.me...@collabora.com> diff --git a/loleaflet/admin/admin.html b/loleaflet/admin/admin.html index a076a1749..23423f2ea 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 5dabb9702..1d10257a5 100644 --- a/loleaflet/admin/admin.strings.js +++ b/loleaflet/admin/admin.strings.js @@ -39,6 +39,7 @@ l10nstrings.strLimitFileSizeMb = _('Maximum file size allowed to write to disk ( l10nstrings.strDocuments = _('Documents:'); l10nstrings.strExpired = _('Expired:'); l10nstrings.strRefresh = _('Refresh'); +l10nstrings.strServerUptime = _('Server uptime') if (module) { module.exports = l10nstrings; diff --git a/loleaflet/admin/src/AdminSocketOverview.js b/loleaflet/admin/src/AdminSocketOverview.js index 15444e9a6..9c61089cc 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 27fca0d84..e08037395 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 414427027..498053604 100644 --- a/wsd/Admin.cpp +++ b/wsd/Admin.cpp @@ -157,6 +157,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 e25c08bf5..d6629ebaa 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 69a9f4557..61c1b275d 100644 --- a/wsd/AdminModel.hpp +++ b/wsd/AdminModel.hpp @@ -266,6 +266,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 75ab01c48..8eb9e31ca 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> @@ -703,6 +704,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; @@ -761,6 +763,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 9e8f7b254..6f1eedbf6 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> @@ -74,6 +75,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(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits