From ed1bf9a16f7cac30ba5adfd3420696018cbcc2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 28 Nov 2018 19:24:54 -0500 Subject: [PATCH] add more info to advanced db page --- public/language/en-GB/admin/advanced/database.json | 8 ++++++++ public/src/utils.js | 2 +- src/database/mongo.js | 4 ++++ src/database/redis.js | 9 +++++++++ src/views/admin/advanced/database.tpl | 11 +++++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/public/language/en-GB/admin/advanced/database.json b/public/language/en-GB/admin/advanced/database.json index b5351b91e4..f0892fd0f5 100644 --- a/public/language/en-GB/admin/advanced/database.json +++ b/public/language/en-GB/admin/advanced/database.json @@ -18,6 +18,9 @@ "mongo.resident-memory": "Resident Memory", "mongo.virtual-memory": "Virtual Memory", "mongo.mapped-memory": "Mapped Memory", + "mongo.bytes-in": "Bytes In", + "mongo.bytes-out": "Bytes Out", + "mongo.num-requests": "Number of Requests", "mongo.raw-info": "MongoDB Raw Info", "redis": "Redis", @@ -30,6 +33,11 @@ "redis.total-connections-recieved": "Total Connections Received", "redis.total-commands-processed": "Total Commands Processed", "redis.iops": "Instantaneous Ops. Per Second", + "redis.iinput": "Instantaneous Input Per Second", + "redis.ioutput": "Instantaneous Output Per Second", + "redis.total-input": "Total Input", + "redis.total-output": "Total Ouput", + "redis.keyspace-hits": "Keyspace Hits", "redis.keyspace-misses": "Keyspace Misses", "redis.raw-info": "Redis Raw Info", diff --git a/public/src/utils.js b/public/src/utils.js index e9defd8377..65ca2f8819 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -501,7 +501,7 @@ // takes a string like 1000 and returns 1,000 addCommas: function (text) { - return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + return String(text).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); }, toISOString: function (timestamp) { diff --git a/src/database/mongo.js b/src/database/mongo.js index f7a9438593..7336570e16 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -9,6 +9,7 @@ var session = require('express-session'); var _ = require('lodash'); var semver = require('semver'); var prompt = require('prompt'); +var utils = require('../utils'); var client; var mongoModule = module.exports; @@ -240,6 +241,9 @@ mongoModule.info = function (db, callback) { stats.mem.mapped = (stats.mem.mapped / 1024).toFixed(3); stats.collectionData = results.listCollections; stats.network = results.serverStatus.network; + stats.network.bytesIn = (stats.network.bytesIn / scale).toFixed(3); + stats.network.bytesOut = (stats.network.bytesOut / scale).toFixed(3); + stats.network.numRequests = utils.addCommas(stats.network.numRequests); stats.raw = JSON.stringify(stats, null, 4); stats.avgObjSize = stats.avgObjSize.toFixed(2); diff --git a/src/database/redis.js b/src/database/redis.js index cbd66c1abf..95a78b6310 100644 --- a/src/database/redis.js +++ b/src/database/redis.js @@ -179,6 +179,15 @@ redisModule.info = function (cxn, callback) { redisData[parts[0]] = parts[1]; } }); + + redisData.keys = redisData['db' + nconf.get('redis:database')]; + + redisData.instantaneous_input = (redisData.instantaneous_input_kbps / 1024).toFixed(3); + redisData.instantaneous_output = (redisData.instantaneous_output_kbps / 1024).toFixed(3); + + redisData.total_net_input = (redisData.total_net_input_bytes / (1024 * 1024 * 1024)).toFixed(3); + redisData.total_net_output = (redisData.total_net_output_bytes / (1024 * 1024 * 1024)).toFixed(3); + redisData.used_memory_human = (redisData.used_memory / (1024 * 1024 * 1024)).toFixed(3); redisData.raw = JSON.stringify(redisData, null, 4); redisData.redis = true; diff --git a/src/views/admin/advanced/database.tpl b/src/views/admin/advanced/database.tpl index 53533a9249..10d3989e97 100644 --- a/src/views/admin/advanced/database.tpl +++ b/src/views/admin/advanced/database.tpl @@ -23,6 +23,10 @@ [[admin/advanced/database:mongo.resident-memory]] [[admin/advanced/database:x-gb, {mongo.mem.resident}]]
[[admin/advanced/database:mongo.virtual-memory]] [[admin/advanced/database:x-gb, {mongo.mem.virtual}]]
[[admin/advanced/database:mongo.mapped-memory]] [[admin/advanced/database:x-gb, {mongo.mem.mapped}]]
+
+ [[admin/advanced/database:mongo.bytes-in]] [[admin/advanced/database:x-gb, {mongo.network.bytesIn}]]
+ [[admin/advanced/database:mongo.bytes-out]] [[admin/advanced/database:x-gb, {mongo.network.bytesOut}]]
+ [[admin/advanced/database:mongo.num-requests]] {mongo.network.numRequests}
@@ -38,6 +42,7 @@ [[admin/advanced/database:uptime-seconds]] {redis.uptime_in_seconds}
[[admin/advanced/database:uptime-days]] {redis.uptime_in_days}

+ [[admin/advanced/database:redis.keys]] {redis.keys}
[[admin/advanced/database:redis.connected-clients]] {redis.connected_clients}
[[admin/advanced/database:redis.connected-slaves]] {redis.connected_slaves}
[[admin/advanced/database:redis.blocked-clients]] {redis.blocked_clients}
@@ -49,6 +54,12 @@ [[admin/advanced/database:redis.total-connections-recieved]] {redis.total_connections_received}
[[admin/advanced/database:redis.total-commands-processed]] {redis.total_commands_processed}
[[admin/advanced/database:redis.iops]] {redis.instantaneous_ops_per_sec}
+ + [[admin/advanced/database:redis.iinput]] [[admin/advanced/database:x-mb, {redis.instantaneous_input}]]
+ [[admin/advanced/database:redis.ioutput]] [[admin/advanced/database:x-mb, {redis.instantaneous_output}]]
+ [[admin/advanced/database:redis.total-input]] [[admin/advanced/database:x-gb, {redis.total_net_input}]]
+ [[admin/advanced/database:redis.total-output]] [[admin/advanced/database:x-gb, {redis.total_net_output}]]
+
[[admin/advanced/database:redis.keyspace-hits]] {redis.keyspace_hits}
[[admin/advanced/database:redis.keyspace-misses]] {redis.keyspace_misses}