added mongo info function, change admin redis template to database template

v1.18.x
Baris Usakli 11 years ago
parent 67d5ea83e7
commit 519d376071

@ -1,3 +1,6 @@
<!-- IF redis -->
<h1>Redis</h1>
<hr />
<div id="admin-redis-info">
@ -21,4 +24,19 @@
<span>Keyspace Hits</span> <span class="text-right">{keyspace_hits}</span><br/>
<span>Keyspace Misses</span> <span class="text-right">{keyspace_misses}</span><br/>
</div>
<!-- ENDIF redis -->
<!-- IF mongo -->
<h1>Mongo</h1>
<hr />
<div id="admin-redis-info">
<span>Collections</span> <span class="text-right">{collections}</span><br/>
<span>Objects</span> <span class="text-right">{objects}</span><br/>
<span>Avg. Object Size</span> <span class="text-right">{avgObjSize} kb</span><br/>
<hr/>
<span>Data Size</span> <span class="text-right">{dataSize} kb</span><br/>
<span>Storage Size</span> <span class="text-right">{storageSize} kb</span><br/>
<span>File Size</span> <span class="text-right">{fileSize} kb</span><br/>
</div>
<!-- ENDIF mongo -->

@ -105,7 +105,7 @@
<li><a href='{relative_path}/admin/themes'><i class='fa fa-th'></i> Themes</a></li>
<li><a href='{relative_path}/admin/plugins'><i class='fa fa-code-fork'></i> Plugins</a></li>
<li><a href='{relative_path}/admin/settings'><i class='fa fa-cogs'></i> Settings</a></li>
<li><a href='{relative_path}/admin/redis'><i class='fa fa-hdd-o'></i> Redis</a></li>
<li><a href='{relative_path}/admin/database'><i class='fa fa-hdd-o'></i> Database</a></li>
<li><a href='{relative_path}/admin/logger'><i class='fa fa-th'></i> Logger</a></li>
<li><a href="{relative_path}/admin/motd"><i class="fa fa-comment"></i> MOTD</a></li>
</ul>

@ -4,7 +4,7 @@
"^admin/topics.*": "admin/topics",
"^admin/categories.*": "admin/categories",
"^admin/users.*": "admin/users",
"^admin/redis.*": "admin/redis",
"^admin/database.*": "admin/database",
"^admin/index.*": "admin/index",
"^admin/themes.*": "admin/themes",
"^admin/plugins/?$": "admin/plugins",

@ -71,7 +71,15 @@
}
module.info = function(callback) {
throw new Error('not-implemented');
db.stats({scale:1024}, function(err, stats) {
stats.avgObjSize = (stats.avgObjSize / 1024).toFixed(2);
stats.mongo = true;
//remove this when andrew adds in undefined checking to templates
stats.redis = false;
callback(err, stats);
});
}
// key

@ -103,7 +103,7 @@
}
data = data.split("\r\n");
var finalData = {};
var redisData = {};
for (var i in data) {
@ -116,14 +116,18 @@
var jsonObject = JSON.parse(json);
for (var key in jsonObject) {
finalData[key] = jsonObject[key];
redisData[key] = jsonObject[key];
}
} catch (err) {
winston.warn('can\'t parse redis status variable, ignoring', i, data[i], err);
}
}
callback(null, finalData);
redisData.redis = true;
//remove this when andrew adds in undefined checking to templates
redisData.mongo = false;
callback(null, redisData);
});
}

@ -55,7 +55,7 @@ var nconf = require('nconf'),
(function () {
var routes = [
'categories/active', 'categories/disabled', 'users', 'topics', 'settings', 'themes',
'twitter', 'facebook', 'gplus', 'redis', 'motd', 'groups', 'plugins', 'logger',
'twitter', 'facebook', 'gplus', 'database', 'motd', 'groups', 'plugins', 'logger',
'users/latest', 'users/sort-posts', 'users/sort-reputation',
'users/search'
];
@ -265,7 +265,7 @@ var nconf = require('nconf'),
});
});
app.namespace('/redis', function () {
app.namespace('/database', function () {
app.get('/', function (req, res) {
db.info(function (err, data) {
res.json(data);

Loading…
Cancel
Save