display both redis/mongo info if available

v1.18.x
barisusakli 10 years ago
parent 0083d4ff1c
commit 7b550b13b9

@ -211,8 +211,29 @@ adminController.flags.get = function(req, res, next) {
};
adminController.database.get = function(req, res, next) {
db.info(function (err, data) {
res.render('admin/advanced/database', data);
async.parallel({
redis: function(next) {
if (nconf.get('redis')) {
var rdb = require('../database/redis');
var cxn = rdb.connect();
rdb.info(cxn, next);
} else {
next();
}
},
mongo: function(next) {
if (nconf.get('mongo')) {
var mdb = require('../database/mongo');
mdb.info(mdb.client, next);
} else {
next();
}
}
}, function(err, results) {
if (err) {
return next(err);
}
res.render('admin/advanced/database', results);
});
};

@ -158,6 +158,24 @@
});
};
module.info = function(db, callback) {
db.stats({scale:1024}, function(err, stats) {
if(err) {
return callback(err);
}
stats.avgObjSize = (stats.avgObjSize / 1024).toFixed(2);
stats.dataSize = (stats.dataSize / 1024).toFixed(2);
stats.storageSize = (stats.storageSize / 1024).toFixed(2);
stats.fileSize = (stats.fileSize / 1024).toFixed(2);
stats.indexSize = (stats.indexSize / 1024).toFixed(2);
stats.raw = JSON.stringify(stats, null, 4);
stats.mongo = true;
callback(null, stats);
});
};
module.close = function() {
db.close();
};

@ -79,24 +79,6 @@ module.exports = function(db, module) {
db.dropDatabase(callback);
};
module.info = function(callback) {
db.stats({scale:1024}, function(err, stats) {
if(err) {
return callback(err);
}
stats.avgObjSize = (stats.avgObjSize / 1024).toFixed(2);
stats.dataSize = (stats.dataSize / 1024).toFixed(2);
stats.storageSize = (stats.storageSize / 1024).toFixed(2);
stats.fileSize = (stats.fileSize / 1024).toFixed(2);
stats.indexSize = (stats.indexSize / 1024).toFixed(2);
stats.raw = JSON.stringify(stats, null, 4);
stats.mongo = true;
callback(null, stats);
});
};
module.exists = function(key, callback) {
if (!key) {
return callback();

@ -115,6 +115,28 @@
redisClient.quit();
};
module.info = function(cxn, callback) {
cxn.info(function (err, data) {
if (err) {
return callback(err);
}
var lines = data.toString().split("\r\n").sort();
var redisData = {};
lines.forEach(function (line) {
var parts = line.split(':');
if (parts[1]) {
redisData[parts[0]] = parts[1];
}
});
redisData.raw = JSON.stringify(redisData, null, 4);
redisData.redis = true;
callback(null, redisData);
});
};
module.helpers = module.helpers || {};
module.helpers.redis = require('./redis/helpers');
}(exports));

@ -35,27 +35,7 @@ module.exports = function(redisClient, module) {
});
};
module.info = function(callback) {
redisClient.info(function (err, data) {
if(err) {
return callback(err);
}
var lines = data.toString().split("\r\n").sort();
var redisData = {};
lines.forEach(function (line) {
var parts = line.split(':');
if (parts[1]) {
redisData[parts[0]] = parts[1];
}
});
redisData.raw = JSON.stringify(redisData, null, 4);
redisData.redis = true;
callback(null, redisData);
});
};
module.exists = function(key, callback) {
redisClient.exists(key, function(err, exists) {

@ -1,5 +1,23 @@
<div class="database">
<div class="col-sm-9">
<!-- IF mongo -->
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-hdd-o"></i> Mongo</div>
<div class="panel-body">
<div class="database-info">
<span>Collections</span> <span class="text-right formatted-number">{collections}</span><br/>
<span>Objects</span> <span class="text-right formatted-number">{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} mb</span><br/>
<span>Storage Size</span> <span class="text-right">{storageSize} mb</span><br/>
<span>Index Size</span> <span class="text-right">{indexSize} mb</span><br/>
<span>File Size</span> <span class="text-right">{fileSize} mb</span><br/>
</div>
</div>
</div>
<!-- ENDIF mongo -->
<!-- IF redis -->
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-hdd-o"></i> Redis</div>
@ -31,29 +49,30 @@
<!-- IF mongo -->
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-hdd-o"></i> Mongo</div>
<div class="panel-body">
<div class="database-info">
<span>Collections</span> <span class="text-right formatted-number">{collections}</span><br/>
<span>Objects</span> <span class="text-right formatted-number">{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} mb</span><br/>
<span>Storage Size</span> <span class="text-right">{storageSize} mb</span><br/>
<span>Index Size</span> <span class="text-right">{indexSize} mb</span><br/>
<span>File Size</span> <span class="text-right">{fileSize} mb</span><br/>
<div class="panel-heading" data-toggle="collapse" data-target=".mongodb-raw">
<h3 class="panel-title"><i class="fa fa-caret-down"></i> MongoDB Raw Info</h3>
</div>
<div class="panel-body mongodb-raw collapse">
<div class="highlight">
<pre>{mongo.raw}</pre>
</div>
</div>
</div>
<!-- ENDIF mongo -->
<!-- IF redis -->
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-hdd-o"></i> Raw Info</div>
<div class="panel-body">
<div class="panel-heading" data-toggle="collapse" data-target=".redis-raw">
<h3 class="panel-title"><i class="fa fa-caret-down"></i> Redis Raw Info</h3>
</div>
<div class="panel-body redis-raw collapse">
<div class="highlight">
<pre>{raw}</pre>
<pre>{redis.raw}</pre>
</div>
</div>
</div>
<!-- ENDIF redis -->
</div>
</div>

Loading…
Cancel
Save