summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge <gwoodcode@gmail.com>2019-07-19 11:39:59 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-12-16 16:54:07 +0100
commitf92a4a7ba2413bd5b6249232fbd2a1843331f9d1 (patch)
tree334b98c48e19d0f57f800d7b465237f33e123f8a
parentOne -f should be enough (diff)
downloadonline-f92a4a7ba2413bd5b6249232fbd2a1843331f9d1.tar.gz
online-f92a4a7ba2413bd5b6249232fbd2a1843331f9d1.zip
added server uptime field to admin console
Change-Id: Id23fee1299b87095f186ce7aaa8c2d2e0f3cef52 Signed-off-by: Michael Meeks <michael.meeks@collabora.com> (cherry picked from commit 360d5a0956c39e696cc4fbab89ec6cdd2cf106d3)
-rw-r--r--loleaflet/admin/admin.html4
-rw-r--r--loleaflet/admin/admin.strings.js1
-rw-r--r--loleaflet/admin/src/AdminSocketOverview.js7
-rwxr-xr-xscripts/unocommands.py2
-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
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();