Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Include more information to help with bug reports and debugging #14047

Merged
merged 6 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/server/models/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,10 @@ export class Messages extends Base {
// //////////////////////////////////////////////////////////////////
// threads

countThreads() {
return this.find({ tcount: { $exists: true } }).count();
}

removeThreadRefByThreadId(tmid) {
const query = { tmid };
const update = {
Expand Down
12 changes: 8 additions & 4 deletions app/models/server/models/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ export class Rooms extends Base {
constructor(...args) {
super(...args);

this.tryEnsureIndex({ name: 1 }, { unique: 1, sparse: 1 });
this.tryEnsureIndex({ name: 1 }, { unique: true, sparse: true });
this.tryEnsureIndex({ default: 1 });
this.tryEnsureIndex({ t: 1 });
this.tryEnsureIndex({ 'u._id': 1 });
this.tryEnsureIndex({ 'tokenpass.tokens.token': 1 });
this.tryEnsureIndex({ open: 1 }, { sparse: 1 });
this.tryEnsureIndex({ departmentId: 1 }, { sparse: 1 });
this.tryEnsureIndex({ open: 1 }, { sparse: true });
this.tryEnsureIndex({ departmentId: 1 }, { sparse: true });
this.tryEnsureIndex({ ts: 1 });

// discussions
this.tryEnsureIndex({ prid: 1 });
this.tryEnsureIndex({ prid: 1 }, { sparse: true });
}

findOneByIdOrName(_idOrName, options) {
Expand Down Expand Up @@ -1413,6 +1413,10 @@ export class Rooms extends Base {

return this.update(query, update);
}

countDiscussions() {
return this.find({ prid: { $exists: true } }).count();
}
}

export default new Rooms('room', true);
32 changes: 24 additions & 8 deletions app/statistics/server/functions/get.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { Meteor } from 'meteor/meteor';
import { MongoInternals } from 'meteor/mongo';
import _ from 'underscore';
import os from 'os';

import { Meteor } from 'meteor/meteor';
import { MongoInternals } from 'meteor/mongo';
import { InstanceStatus } from 'meteor/konecty:multiple-instances-status';
import { Sessions, Settings, Users, Rooms, Subscriptions, Uploads, Messages, LivechatVisitors } from '../../../models';
import { settings } from '../../../settings';
import { Info } from '../../../utils';
import { Migrations } from '../../../migrations';

import {
Sessions,
Settings,
Users,
Rooms,
Subscriptions,
Uploads,
Messages,
LivechatVisitors,
} from '../../../models/server';
import { settings } from '../../../settings/server';
import { Info } from '../../../utils/server';
import { Migrations } from '../../../migrations/server';

import { statistics } from '../statisticsNamespace';

const wizardFields = [
Expand Down Expand Up @@ -62,6 +74,7 @@ statistics.get = function _getStatistics() {
statistics.nonActiveUsers = statistics.totalUsers - statistics.activeUsers;
statistics.onlineUsers = Meteor.users.find({ statusConnection: 'online' }).count();
statistics.awayUsers = Meteor.users.find({ statusConnection: 'away' }).count();
statistics.totalConnectedUsers = statistics.onlineUsers + statistics.awayUsers;
statistics.offlineUsers = statistics.totalUsers - statistics.onlineUsers - statistics.awayUsers;

// Room statistics
Expand All @@ -70,6 +83,8 @@ statistics.get = function _getStatistics() {
statistics.totalPrivateGroups = Rooms.findByType('p').count();
statistics.totalDirect = Rooms.findByType('d').count();
statistics.totalLivechat = Rooms.findByType('l').count();
statistics.totalDiscussions = Rooms.countDiscussions();
statistics.totalThreads = Messages.countThreads();

// livechat visitors
statistics.totalLivechatVisitors = LivechatVisitors.find().count();
Expand Down Expand Up @@ -128,10 +143,11 @@ statistics.get = function _getStatistics() {
}

try {
const { version } = Promise.await(mongo.db.command({ buildInfo: 1 }));
const { version, storageEngine } = Promise.await(mongo.db.command({ serverStatus: 1 }));
statistics.mongoVersion = version;
statistics.mongoStorageEngine = storageEngine.name;
} catch (e) {
console.error('Error getting MongoDB version');
console.error('Error getting MongoDB info');
}

statistics.uniqueUsersOfYesterday = Sessions.getUniqueUsersOfYesterday();
Expand Down
21 changes: 21 additions & 0 deletions app/ui-admin/client/adminInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ <h3>{{_ "Runtime_Environment"}}</h3>
<th class="content-background-color border-component-color">{{_ "Node_version"}}</th>
<td class="border-component-color">{{statistics.process.nodeVersion}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Mongo_version"}}</th>
<td class="border-component-color">{{statistics.mongoVersion}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Mongo_storageEngine"}}</th>
<td class="border-component-color">{{statistics.mongoStorageEngine}}</td>
</tr>

<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "OS_Uptime"}}</th>
<td class="border-component-color">{{humanReadableTime statistics.os.uptime}}</td>
Expand Down Expand Up @@ -173,6 +182,10 @@ <h3>{{_ "Usage"}}</h3>
<th class="content-background-color border-component-color">{{_ "Stats_Non_Active_Users"}}</th>
<td class="border-component-color">{{statistics.nonActiveUsers}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Stats_Total_Connected_Users"}}</th>
<td class="border-component-color">{{statistics.totalConnectedUsers}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Stats_Online_Users"}}</th>
<td class="border-component-color">{{statistics.onlineUsers}}</td>
Expand Down Expand Up @@ -205,6 +218,14 @@ <h3>{{_ "Usage"}}</h3>
<th class="content-background-color border-component-color">{{_ "Stats_Total_Livechat_Rooms"}}</th>
<td class="border-component-color">{{statistics.totalLivechat}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Total_Discussions"}}</th>
<td class="border-component-color">{{statistics.totalDiscussions}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Total_Threads"}}</th>
<td class="border-component-color">{{statistics.totalThreads}}</td>
</tr>
<tr class="admin-table-row">
<th class="content-background-color border-component-color">{{_ "Stats_Total_Messages"}}</th>
<td class="border-component-color">{{statistics.totalMessages}}</td>
Expand Down
9 changes: 7 additions & 2 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,8 @@
"Mobile": "Mobile",
"Mobile_Notifications_Default_Alert": "Mobile Notifications Default Alert",
"Monday": "Monday",
"Mongo_version": "Mongo Version",
"Mongo_storageEngine": "Mongo Storage Engine",
"Monitor_history_for_changes_on": "Monitor History for Changes on",
"More": "More",
"More_channels": "More channels",
Expand Down Expand Up @@ -2687,14 +2689,15 @@
"Statistics": "Statistics",
"Statistics_reporting": "Send Statistics to Rocket.Chat",
"Statistics_reporting_Description": "By sending your statistics, you'll help us identify how many instances of Rocket.Chat are deployed, as well as how good the system is behaving, so we can further improve it. Don't worry, as no user information is sent and all the information we receive is kept confidential.",
"Stats_Active_Users": "Active Users",
"Stats_Active_Users": "Activated Users",
"Stats_Avg_Channel_Users": "Average Channel Users",
"Stats_Avg_Private_Group_Users": "Average Private Group Users",
"Stats_Away_Users": "Away Users",
"Stats_Max_Room_Users": "Max Rooms Users",
"Stats_Non_Active_Users": "Inactive Users",
"Stats_Non_Active_Users": "Deactivated Users",
"Stats_Offline_Users": "Offline Users",
"Stats_Online_Users": "Online Users",
"Stats_Total_Connected_Users": "Total Connected Users",
"Stats_Total_Channels": "Total Channels",
"Stats_Total_Direct_Messages": "Total Direct Message Rooms",
"Stats_Total_Livechat_Rooms": "Total Livechat Rooms",
Expand Down Expand Up @@ -2863,7 +2866,9 @@
"Topic": "Topic",
"Total": "Total",
"Total_conversations": "Total Conversations",
"Total_Discussions": "Total Discussions",
"Total_messages": "Total Messages",
"Total_Threads": "Total Threads",
"Total_visitors": "Total Visitors",
"Tourism": "Tourism",
"Transcript_Enabled": "Ask Visitor if They Would Like a Transcript After Chat Closed",
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2841,7 +2841,9 @@
"Topic": "Tópico",
"Total": "Total",
"Total_conversations": "Total de conversas",
"Total_Discussions": "Total de discussões",
"Total_messages": "Quantidade de Mensagens",
"Total_Threads": "Total de tópicos",
"Total_visitors": "Total de visitantes",
"Tourism": "Turismo",
"Transcript_Enabled": "Pergunte ao visitante se eles gostariam de uma transcrição após o bate-papo fechado",
Expand Down
5 changes: 4 additions & 1 deletion server/startup/serverRunning.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ Meteor.startup(function() {
}

let mongoDbVersion;
let mongoDbEngine;
try {
const { version } = Promise.await(mongo.db.command({ buildInfo: 1 }));
const { version, storageEngine } = Promise.await(mongo.db.command({ serverStatus: 1 }));
mongoDbVersion = version;
mongoDbEngine = storageEngine.name;
} catch (e) {
mongoDbVersion = 'Error getting version';
console.error('Error getting MongoDB version');
Expand All @@ -36,6 +38,7 @@ Meteor.startup(function() {
`Rocket.Chat Version: ${ Info.version }`,
` NodeJS Version: ${ process.versions.node } - ${ process.arch }`,
` MongoDB Version: ${ mongoDbVersion }`,
` MongoDB Engine: ${ mongoDbEngine }`,
` Platform: ${ process.platform }`,
` Process Port: ${ process.env.PORT }`,
` Site URL: ${ settings.get('Site_Url') }`,
Expand Down