@resolveio/server-lib 9.6.29 → 9.6.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/methods/monitor.js +50 -44
- package/methods/monitor.js.map +1 -1
- package/package.json +1 -1
package/methods/monitor.js
CHANGED
|
@@ -271,7 +271,6 @@ function loadMonitorMethods(methodManager) {
|
|
|
271
271
|
data: 0
|
|
272
272
|
}
|
|
273
273
|
});
|
|
274
|
-
console.log(JSON.stringify(query, null, 2));
|
|
275
274
|
return [4 /*yield*/, __1.ResolveIOServer.getMongoManager().collection(collection).aggregate(query, { allowDiskUse: true, readPreference: 'secondary' })];
|
|
276
275
|
case 1:
|
|
277
276
|
graphData = _c.sent();
|
|
@@ -288,9 +287,9 @@ function loadMonitorMethods(methodManager) {
|
|
|
288
287
|
var _this = this;
|
|
289
288
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
290
289
|
var groupId, groupDate, query, firstGroupId, graphData;
|
|
291
|
-
var _a, _b, _c, _d, _e
|
|
292
|
-
return __generator(this, function (
|
|
293
|
-
switch (
|
|
290
|
+
var _a, _b, _c, _d, _e;
|
|
291
|
+
return __generator(this, function (_f) {
|
|
292
|
+
switch (_f.label) {
|
|
294
293
|
case 0:
|
|
295
294
|
groupId = {};
|
|
296
295
|
groupDate = {};
|
|
@@ -478,8 +477,6 @@ function loadMonitorMethods(methodManager) {
|
|
|
478
477
|
groupDate[variable] = '$' + variable;
|
|
479
478
|
groupDate['date'] = '$date';
|
|
480
479
|
groupDate['data'] = '$data';
|
|
481
|
-
}
|
|
482
|
-
if (collection === 'monitor-mongos') {
|
|
483
480
|
query.push({
|
|
484
481
|
$group: (_a = {
|
|
485
482
|
_id: firstGroupId
|
|
@@ -517,7 +514,7 @@ function loadMonitorMethods(methodManager) {
|
|
|
517
514
|
'$sum': '$data.' + variable
|
|
518
515
|
},
|
|
519
516
|
_c.date = {
|
|
520
|
-
$
|
|
517
|
+
$first: '$date'
|
|
521
518
|
},
|
|
522
519
|
_c.data = {
|
|
523
520
|
$push: '$data'
|
|
@@ -546,47 +543,56 @@ function loadMonitorMethods(methodManager) {
|
|
|
546
543
|
});
|
|
547
544
|
}
|
|
548
545
|
else {
|
|
549
|
-
query.push(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}
|
|
546
|
+
// query.push(
|
|
547
|
+
// {
|
|
548
|
+
// $group: {
|
|
549
|
+
// _id: groupId,
|
|
550
|
+
// [variable]: {
|
|
551
|
+
// ['$' + variableType]: '$' + variable
|
|
552
|
+
// }
|
|
553
|
+
// }
|
|
554
|
+
// }
|
|
555
|
+
// );
|
|
556
|
+
// query.push(
|
|
557
|
+
// {
|
|
558
|
+
// $group: {
|
|
559
|
+
// _id: groupDate,
|
|
560
|
+
// data: {
|
|
561
|
+
// $push: {k: {$concat: ['$_id.client', ' - ', {$replaceAll: { input: '$_id.instance', find: ".", replacement: "-" }}]}, v: '$' + variable}
|
|
562
|
+
// }
|
|
563
|
+
// }
|
|
564
|
+
// }
|
|
565
|
+
// );
|
|
566
|
+
// query.push(
|
|
567
|
+
// {
|
|
568
|
+
// $addFields: {
|
|
569
|
+
// data: {
|
|
570
|
+
// $arrayToObject: '$data'
|
|
571
|
+
// }
|
|
572
|
+
// }
|
|
573
|
+
// }
|
|
574
|
+
// );
|
|
575
|
+
// query.push(
|
|
576
|
+
// {
|
|
577
|
+
// $replaceRoot: {
|
|
578
|
+
// newRoot: {
|
|
579
|
+
// $mergeObjects: ['$data', '$$ROOT']
|
|
580
|
+
// }
|
|
581
|
+
// }
|
|
582
|
+
// }
|
|
583
|
+
// );
|
|
584
|
+
// query.push(
|
|
585
|
+
// {
|
|
586
|
+
// $project: {
|
|
587
|
+
// data: 0
|
|
588
|
+
// }
|
|
589
|
+
// }
|
|
590
|
+
// );
|
|
585
591
|
}
|
|
586
592
|
console.log(JSON.stringify(query, null, 2));
|
|
587
593
|
return [4 /*yield*/, __1.ResolveIOServer.getMongoManager().collection(collection).aggregate(query, { allowDiskUse: true, readPreference: 'secondary' })];
|
|
588
594
|
case 1:
|
|
589
|
-
graphData =
|
|
595
|
+
graphData = _f.sent();
|
|
590
596
|
resolve(graphData);
|
|
591
597
|
return [2 /*return*/];
|
|
592
598
|
}
|
package/methods/monitor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/methods/monitor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oFAAwE;AACxE,gFAAoE;AACpE,sGAAyF;AACzF,oGAAuF;AACvF,sFAA0E;AAC1E,wBAAqC;AACrC,yCAA0C;AAE1C,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACf,0BAA0B,EAAE;YACxB,QAAQ,EAAE,UAAS,UAAgB,EAAE,QAAc,EAAE,UAAkB,EAAE,QAAgB,EAAE,MAAc,EAAE,aAAqB,EAAE,QAAgB,EAAE,YAAoB;gBAA9J,iBAuPlB;gBAtPA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;;;;gCACpC,OAAO,GAAG,EAAE,CAAC;gCACb,SAAS,GAAG,EAAE,CAAC;gCAEnB,IAAI,aAAa,KAAK,SAAS,EAAE;oCAChC,OAAO,GAAG;wCACT,MAAM,E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CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gCAE5B,qBAAM,mBAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAC,CAAC,EAAA;;gCAA9I,SAAS,GAAG,SAAkI;gCAElJ,OAAO,CAAC,SAAS,CAAC,CAAC;;;;qBACnB,CAAC,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,IAAI;SACd;QACD,aAAa,EAAE;YACX,QAAQ,EAAE;gBACN,OAAO,wCAAa,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YACjE,CAAC;SACJ;QACD,WAAW,EAAE;YACT,QAAQ,EAAE;gBACN,OAAO,oCAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YAC/D,CAAC;SACJ;QACD,cAAc,EAAE;YACZ,QAAQ,EAAE;gBACN,OAAO,0CAAc,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YAClE,CAAC;SACJ;QACD,qBAAqB,EAAE;YACnB,QAAQ,EAAE;gBACN,OAAO,yDAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YACzE,CAAC;SACJ;QACD,oBAAoB,EAAE;YAClB,QAAQ,EAAE;gBACN,OAAO,uDAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YACxE,CAAC;SACJ;KACP,CAAC,CAAC;AACJ,CAAC;AApmBD,gDAomBC","file":"monitor.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';\nimport { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\nimport { ResolveIOServer } from '..';\nimport { deepCopy } from '../util/common';\n\nexport function loadMonitorMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n superadminMonitorGraphData: {\n function: function(date_start: Date, date_end: Date, collection: string, instance: string, client: string, graphInterval: string, variable: string, variableType: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupDate = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute',\n\t\t\t\t\t\t\t'second': '$_id.second'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day'\n\t\t\t\t\t\t};\n }\n\n let query = <any>[\n {\n $match: {\n $and: [\n {\n date: {$gte: date_start}\n },\n {\n date: {$lte: date_end}\n }\n ]\n }\n }\n ];\n\n if (client) {\n query[0]['$match'].$and.push({client: client});\n }\n\n if (instance) {\n query[0]['$match'].$and.push({instance: instance});\n\t\t\t\t\t}\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\t[variable]: variableType === 'count' ? {$sum: 1} : {\n\t\t\t\t\t\t\t\t\t['$' + variableType]: '$' + variable\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupDate,\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t$push: {k: {$concat: ['$_id.client', ' - ', {$replaceAll: { input: '$_id.instance', find: \".\", replacement: \"-\" }}]}, v: '$' + variable}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t$arrayToObject: '$data'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$replaceRoot: {\n\t\t\t\t\t\t\t\tnewRoot: {\n\t\t\t\t\t\t\t\t\t$mergeObjects: ['$data', '$$ROOT']\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\t\tdata: 0\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tconsole.log(JSON.stringify(query, null, 2));\n\n\t\t\t\t\tlet graphData = await ResolveIOServer.getMongoManager().collection(collection).aggregate(query, {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tresolve(graphData);\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n },\n\t\tsuperadminMonitorTableData: {\n function: function(date_start: Date, date_end: Date, collection: string, instance: string, client: string, graphInterval: string, variable: string, variableType: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupDate = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute',\n\t\t\t\t\t\t\t'second': '$_id.second'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day'\n\t\t\t\t\t\t};\n }\n\n let query = <any>[\n {\n $match: {\n $and: [\n {\n date: {$gte: date_start}\n },\n {\n date: {$lte: date_end}\n }\n ]\n }\n }\n ];\n\n if (client) {\n query[0]['$match'].$and.push({client: client});\n }\n\n if (instance) {\n query[0]['$match'].$and.push({instance: instance});\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tlet firstGroupId = deepCopy(groupId);\n\t\t\t\t\t\n\t\t\t\t\tif (collection === 'monitor-mongos') {\n\t\t\t\t\t\tfirstGroupId[variable] = '$' + variable;\n\t\t\t\t\t\tgroupDate[variable] = '$' + variable;\n\t\t\t\t\t\tgroupDate['date'] = '$date';\n\t\t\t\t\t\tgroupDate['data'] = '$data';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (collection === 'monitor-mongos') {\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: firstGroupId,\n\t\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t\t'$sum': 1\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t[variable + '_name']: {\n\t\t\t\t\t\t\t\t\t\t$first: '$' + [variable]\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t\t\t\t$first: '$date'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tclient: {\n\t\t\t\t\t\t\t\t\t\t$first: '$client'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tinstance: {\n\t\t\t\t\t\t\t\t\t\t$first: '$instance'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t[variable]: '$' + variable,\n\t\t\t\t\t\t\t\t\t[variable + '_name']: '$' + variable + '_name'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t'$sum': '$data.' + variable\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t\t\t$push: '$date'\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t$push: '$data'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\t[variable]: groupDate\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\tclient: '$_id.client',\n\t\t\t\t\t\t\t\t\t\tinstance: '$_id.instance'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t$push: '$' + variable\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t\t$sum: '$' + variable + '.' + variable\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t\t['$' + variableType]: '$' + variable\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: groupDate,\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t$push: {k: {$concat: ['$_id.client', ' - ', {$replaceAll: { input: '$_id.instance', find: \".\", replacement: \"-\" }}]}, v: '$' + variable}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t$arrayToObject: '$data'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$replaceRoot: {\n\t\t\t\t\t\t\t\t\tnewRoot: {\n\t\t\t\t\t\t\t\t\t\t$mergeObjects: ['$data', '$$ROOT']\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\t\t\tdata: 0\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconsole.log(JSON.stringify(query, null, 2));\n\n\t\t\t\t\tlet graphData = await ResolveIOServer.getMongoManager().collection(collection).aggregate(query, {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tresolve(graphData);\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n },\n monitorMongos: {\n function: function() {\n return MonitorMongos.find({}, {readPreference: 'secondary'});\n }\n },\n monitorCPUs: {\n function: function() {\n return MonitorCPUs.find({}, {readPreference: 'secondary'});\n }\n },\n monitorMemorys: {\n function: function() {\n return MonitorMemorys.find({}, {readPreference: 'secondary'});\n }\n },\n monitorHTTPSOutbounds: {\n function: function() {\n return MonitorHTTPSOutbounds.find({}, {readPreference: 'secondary'});\n }\n },\n monitorHTTPSInbounds: {\n function: function() {\n return MonitorHTTPSInbounds.find({}, {readPreference: 'secondary'});\n }\n },\n\t});\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/methods/monitor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oFAAwE;AACxE,gFAAoE;AACpE,sGAAyF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,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gCAE5B,qBAAM,mBAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAC,CAAC,EAAA;;gCAA9I,SAAS,GAAG,SAAkI;gCAElJ,OAAO,CAAC,SAAS,CAAC,CAAC;;;;qBACnB,CAAC,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,IAAI;SACd;QACD,aAAa,EAAE;YACX,QAAQ,EAAE;gBACN,OAAO,wCAAa,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YACjE,CAAC;SACJ;QACD,WAAW,EAAE;YACT,QAAQ,EAAE;gBACN,OAAO,oCAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YAC/D,CAAC;SACJ;QACD,cAAc,EAAE;YACZ,QAAQ,EAAE;gBACN,OAAO,0CAAc,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YAClE,CAAC;SACJ;QACD,qBAAqB,EAAE;YACnB,QAAQ,EAAE;gBACN,OAAO,yDAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YACzE,CAAC;SACJ;QACD,oBAAoB,EAAE;YAClB,QAAQ,EAAE;gBACN,OAAO,uDAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,cAAc,EAAE,WAAW,EAAC,CAAC,CAAC;YACxE,CAAC;SACJ;KACP,CAAC,CAAC;AACJ,CAAC;AAlmBD,gDAkmBC","file":"monitor.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';\nimport { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\nimport { ResolveIOServer } from '..';\nimport { deepCopy } from '../util/common';\n\nexport function loadMonitorMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n superadminMonitorGraphData: {\n function: function(date_start: Date, date_end: Date, collection: string, instance: string, client: string, graphInterval: string, variable: string, variableType: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupDate = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute',\n\t\t\t\t\t\t\t'second': '$_id.second'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day'\n\t\t\t\t\t\t};\n }\n\n let query = <any>[\n {\n $match: {\n $and: [\n {\n date: {$gte: date_start}\n },\n {\n date: {$lte: date_end}\n }\n ]\n }\n }\n ];\n\n if (client) {\n query[0]['$match'].$and.push({client: client});\n }\n\n if (instance) {\n query[0]['$match'].$and.push({instance: instance});\n\t\t\t\t\t}\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\t[variable]: variableType === 'count' ? {$sum: 1} : {\n\t\t\t\t\t\t\t\t\t['$' + variableType]: '$' + variable\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupDate,\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t$push: {k: {$concat: ['$_id.client', ' - ', {$replaceAll: { input: '$_id.instance', find: \".\", replacement: \"-\" }}]}, v: '$' + variable}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t$arrayToObject: '$data'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$replaceRoot: {\n\t\t\t\t\t\t\t\tnewRoot: {\n\t\t\t\t\t\t\t\t\t$mergeObjects: ['$data', '$$ROOT']\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tquery.push(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\t\tdata: 0\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\t// console.log(JSON.stringify(query, null, 2));\n\n\t\t\t\t\tlet graphData = await ResolveIOServer.getMongoManager().collection(collection).aggregate(query, {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tresolve(graphData);\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n },\n\t\tsuperadminMonitorTableData: {\n function: function(date_start: Date, date_end: Date, collection: string, instance: string, client: string, graphInterval: string, variable: string, variableType: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupDate = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute',\n\t\t\t\t\t\t\t'second': '$_id.second'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour',\n\t\t\t\t\t\t\t'minute': '$_id.minute'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day',\n\t\t\t\t\t\t\t'hour': '$_id.hour'\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$date',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n },\n client: '$client',\n instance: '$instance'\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupDate = {\n\t\t\t\t\t\t\t'year': '$_id.year',\n\t\t\t\t\t\t\t'month': '$_id.month',\n\t\t\t\t\t\t\t'day': '$_id.day'\n\t\t\t\t\t\t};\n }\n\n let query = <any>[\n {\n $match: {\n $and: [\n {\n date: {$gte: date_start}\n },\n {\n date: {$lte: date_end}\n }\n ]\n }\n }\n ];\n\n if (client) {\n query[0]['$match'].$and.push({client: client});\n }\n\n if (instance) {\n query[0]['$match'].$and.push({instance: instance});\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tlet firstGroupId = deepCopy(groupId);\n\t\t\t\t\t\n\t\t\t\t\tif (collection === 'monitor-mongos') {\n\t\t\t\t\t\tfirstGroupId[variable] = '$' + variable;\n\t\t\t\t\t\tgroupDate[variable] = '$' + variable;\n\t\t\t\t\t\tgroupDate['date'] = '$date';\n\t\t\t\t\t\tgroupDate['data'] = '$data';\n\t\t\t\t\t\t\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: firstGroupId,\n\t\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t\t'$sum': 1\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t[variable + '_name']: {\n\t\t\t\t\t\t\t\t\t\t$first: '$' + [variable]\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t\t\t\t$first: '$date'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tclient: {\n\t\t\t\t\t\t\t\t\t\t$first: '$client'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tinstance: {\n\t\t\t\t\t\t\t\t\t\t$first: '$instance'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t[variable]: '$' + variable,\n\t\t\t\t\t\t\t\t\t[variable + '_name']: '$' + variable + '_name'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t'$sum': '$data.' + variable\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t\t\t$first: '$date'\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t$push: '$data'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\tquery.push({\n\t\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\t\t[variable]: groupDate\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tquery.push(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\tclient: '$_id.client',\n\t\t\t\t\t\t\t\t\t\tinstance: '$_id.instance'\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t$push: '$' + variable\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t[variable]: {\n\t\t\t\t\t\t\t\t\t\t$sum: '$' + variable + '.' + variable\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// query.push(\n\t\t\t\t\t\t// \t{\n\t\t\t\t\t\t// \t\t$group: {\n\t\t\t\t\t\t// \t\t\t_id: groupId,\n\t\t\t\t\t\t// \t\t\t[variable]: {\n\t\t\t\t\t\t// \t\t\t\t['$' + variableType]: '$' + variable\n\t\t\t\t\t\t// \t\t\t}\n\t\t\t\t\t\t// \t\t}\n\t\t\t\t\t\t// \t}\n\t\t\t\t\t\t// );\n\n\t\t\t\t\t\t// query.push(\n\t\t\t\t\t\t// \t{\n\t\t\t\t\t\t// \t\t$group: {\n\t\t\t\t\t\t// \t\t\t_id: groupDate,\n\t\t\t\t\t\t// \t\t\tdata: {\n\t\t\t\t\t\t// \t\t\t\t$push: {k: {$concat: ['$_id.client', ' - ', {$replaceAll: { input: '$_id.instance', find: \".\", replacement: \"-\" }}]}, v: '$' + variable}\n\t\t\t\t\t\t// \t\t\t}\n\t\t\t\t\t\t// \t\t}\n\t\t\t\t\t\t// \t}\n\t\t\t\t\t\t// );\n\n\t\t\t\t\t\t// query.push(\n\t\t\t\t\t\t// \t{\n\t\t\t\t\t\t// \t\t$addFields: {\n\t\t\t\t\t\t// \t\t\tdata: {\n\t\t\t\t\t\t// \t\t\t\t$arrayToObject: '$data'\n\t\t\t\t\t\t// \t\t\t}\n\t\t\t\t\t\t// \t\t}\n\t\t\t\t\t\t// \t}\n\t\t\t\t\t\t// );\n\n\t\t\t\t\t\t// query.push(\n\t\t\t\t\t\t// \t{\n\t\t\t\t\t\t// \t\t$replaceRoot: {\n\t\t\t\t\t\t// \t\t\tnewRoot: {\n\t\t\t\t\t\t// \t\t\t\t$mergeObjects: ['$data', '$$ROOT']\n\t\t\t\t\t\t// \t\t\t}\n\t\t\t\t\t\t// \t\t}\n\t\t\t\t\t\t// \t}\n\t\t\t\t\t\t// );\n\n\t\t\t\t\t\t// query.push(\n\t\t\t\t\t\t// \t{\n\t\t\t\t\t\t// \t\t$project: {\n\t\t\t\t\t\t// \t\t\tdata: 0\n\t\t\t\t\t\t// \t\t}\n\t\t\t\t\t\t// \t}\n\t\t\t\t\t\t// );\n\t\t\t\t\t}\n\n\t\t\t\t\tconsole.log(JSON.stringify(query, null, 2));\n\n\t\t\t\t\tlet graphData = await ResolveIOServer.getMongoManager().collection(collection).aggregate(query, {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tresolve(graphData);\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n },\n monitorMongos: {\n function: function() {\n return MonitorMongos.find({}, {readPreference: 'secondary'});\n }\n },\n monitorCPUs: {\n function: function() {\n return MonitorCPUs.find({}, {readPreference: 'secondary'});\n }\n },\n monitorMemorys: {\n function: function() {\n return MonitorMemorys.find({}, {readPreference: 'secondary'});\n }\n },\n monitorHTTPSOutbounds: {\n function: function() {\n return MonitorHTTPSOutbounds.find({}, {readPreference: 'secondary'});\n }\n },\n monitorHTTPSInbounds: {\n function: function() {\n return MonitorHTTPSInbounds.find({}, {readPreference: 'secondary'});\n }\n },\n\t});\n}"]}
|