mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-14 17:56:16 +01:00
Display proper info for redis in info command, show graph of pageviews
from last 24 hours
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
"body-parser": "^1.18.2",
|
"body-parser": "^1.18.2",
|
||||||
"bootstrap": "^3.3.7",
|
"bootstrap": "^3.3.7",
|
||||||
"chart.js": "^2.7.1",
|
"chart.js": "^2.7.1",
|
||||||
|
"cli-graph": "^3.2.2",
|
||||||
"clipboard": "^2.0.1",
|
"clipboard": "^2.0.1",
|
||||||
"colors": "^1.1.2",
|
"colors": "^1.1.2",
|
||||||
"compression": "^1.7.1",
|
"compression": "^1.7.1",
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ var async = require('async');
|
|||||||
var winston = require('winston');
|
var winston = require('winston');
|
||||||
var childProcess = require('child_process');
|
var childProcess = require('child_process');
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
|
var CliGraph = require('cli-graph');
|
||||||
|
|
||||||
var build = require('../meta/build');
|
var build = require('../meta/build');
|
||||||
var db = require('../database');
|
var db = require('../database');
|
||||||
var plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
var events = require('../events');
|
var events = require('../events');
|
||||||
|
var analytics = require('../analytics');
|
||||||
var reset = require('./reset');
|
var reset = require('./reset');
|
||||||
|
|
||||||
function buildTargets() {
|
function buildTargets() {
|
||||||
@@ -124,8 +126,42 @@ function info() {
|
|||||||
db.info(db.client, next);
|
db.info(db.client, next);
|
||||||
},
|
},
|
||||||
function (info, next) {
|
function (info, next) {
|
||||||
console.log(' version: ' + info.version);
|
var config = require('../../config.json');
|
||||||
console.log(' engine: ' + info.storageEngine);
|
|
||||||
|
switch (config.database) {
|
||||||
|
case 'redis':
|
||||||
|
console.log(' version: ' + info.redis_version);
|
||||||
|
console.log(' disk sync: ' + info.rdb_last_bgsave_status);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'mongo':
|
||||||
|
console.log(' version: ' + info.version);
|
||||||
|
console.log(' engine: ' + info.storageEngine);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
},
|
||||||
|
async.apply(analytics.getHourlyStatsForSet, 'analytics:pageviews', Date.now(), 24),
|
||||||
|
function (data, next) {
|
||||||
|
var graph = new CliGraph({
|
||||||
|
height: 12,
|
||||||
|
width: 25,
|
||||||
|
center: {
|
||||||
|
x: 0,
|
||||||
|
y: 11,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
var min = Math.min(...data);
|
||||||
|
var max = Math.max(...data);
|
||||||
|
|
||||||
|
data.forEach(function (point, idx) {
|
||||||
|
graph.addPoint(idx + 1, Math.round(point / max * 10));
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('');
|
||||||
|
console.log(graph.toString());
|
||||||
|
console.log('Pageviews, last 24h (min: ' + min + ' max: ' + max + ')');
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
], function (err) {
|
], function (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user