@resolveio/server-lib 7.1.13 → 7.1.14
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 +307 -0
- package/methods/monitor.js.map +1 -1
- package/package.json +1 -1
package/methods/monitor.js
CHANGED
|
@@ -1,12 +1,319 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
var monitor_mongo_collection_1 = require("../collections/monitor-mongo.collection");
|
|
4
40
|
var monitor_cpu_collection_1 = require("../collections/monitor-cpu.collection");
|
|
5
41
|
var monitor_https_outbound_collection_1 = require("../collections/monitor-https-outbound.collection");
|
|
6
42
|
var monitor_https_inbound_collection_1 = require("../collections/monitor-https-inbound.collection");
|
|
7
43
|
var monitor_memory_collection_1 = require("../collections/monitor-memory.collection");
|
|
44
|
+
var __1 = require("..");
|
|
8
45
|
function loadMonitorMethods(methodManager) {
|
|
9
46
|
methodManager.methods({
|
|
47
|
+
superadminMonitor: {
|
|
48
|
+
skipQueue: true,
|
|
49
|
+
function: function (date_start, date_end, collection, instance, client, graphInterval, variable, variableType) {
|
|
50
|
+
var _this = this;
|
|
51
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
52
|
+
var groupId, groupDate, query, graphData;
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
54
|
+
return __generator(this, function (_h) {
|
|
55
|
+
switch (_h.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
groupId = {};
|
|
58
|
+
groupDate = {};
|
|
59
|
+
if (graphInterval === 'seconds') {
|
|
60
|
+
groupId = {
|
|
61
|
+
second: {
|
|
62
|
+
$second: {
|
|
63
|
+
date: '$date',
|
|
64
|
+
timezone: "America/Chicago"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
minute: {
|
|
68
|
+
$minute: {
|
|
69
|
+
date: '$date',
|
|
70
|
+
timezone: "America/Chicago"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
hour: {
|
|
74
|
+
$hour: {
|
|
75
|
+
date: '$date',
|
|
76
|
+
timezone: "America/Chicago"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
day: {
|
|
80
|
+
$dayOfMonth: {
|
|
81
|
+
date: '$date',
|
|
82
|
+
timezone: "America/Chicago"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
month: {
|
|
86
|
+
$month: {
|
|
87
|
+
date: '$date',
|
|
88
|
+
timezone: "America/Chicago"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
year: {
|
|
92
|
+
$year: {
|
|
93
|
+
date: '$date',
|
|
94
|
+
timezone: "America/Chicago"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
client: '$client',
|
|
98
|
+
instance: '$instance'
|
|
99
|
+
};
|
|
100
|
+
groupDate = (_a = {
|
|
101
|
+
'year': '$_id.year',
|
|
102
|
+
'month': '$_id.month',
|
|
103
|
+
'day': '$_id.day',
|
|
104
|
+
'hour': '$_id.hour',
|
|
105
|
+
'minute': '$_id.minute',
|
|
106
|
+
'second': '$_id.second'
|
|
107
|
+
},
|
|
108
|
+
_a[variable] = '$' + variable,
|
|
109
|
+
_a);
|
|
110
|
+
}
|
|
111
|
+
else if (graphInterval === 'minutes') {
|
|
112
|
+
groupId = {
|
|
113
|
+
minute: {
|
|
114
|
+
$minute: {
|
|
115
|
+
date: '$date',
|
|
116
|
+
timezone: "America/Chicago"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
hour: {
|
|
120
|
+
$hour: {
|
|
121
|
+
date: '$date',
|
|
122
|
+
timezone: "America/Chicago"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
day: {
|
|
126
|
+
$dayOfMonth: {
|
|
127
|
+
date: '$date',
|
|
128
|
+
timezone: "America/Chicago"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
month: {
|
|
132
|
+
$month: {
|
|
133
|
+
date: '$date',
|
|
134
|
+
timezone: "America/Chicago"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
year: {
|
|
138
|
+
$year: {
|
|
139
|
+
date: '$date',
|
|
140
|
+
timezone: "America/Chicago"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
client: '$client',
|
|
144
|
+
instance: '$instance'
|
|
145
|
+
};
|
|
146
|
+
groupDate = (_b = {
|
|
147
|
+
'year': '$_id.year',
|
|
148
|
+
'month': '$_id.month',
|
|
149
|
+
'day': '$_id.day',
|
|
150
|
+
'hour': '$_id.hour',
|
|
151
|
+
'minute': '$_id.minute'
|
|
152
|
+
},
|
|
153
|
+
_b[variable] = '$' + variable,
|
|
154
|
+
_b);
|
|
155
|
+
}
|
|
156
|
+
else if (graphInterval === 'hours') {
|
|
157
|
+
groupId = {
|
|
158
|
+
hour: {
|
|
159
|
+
$hour: {
|
|
160
|
+
date: '$date',
|
|
161
|
+
timezone: "America/Chicago"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
day: {
|
|
165
|
+
$dayOfMonth: {
|
|
166
|
+
date: '$date',
|
|
167
|
+
timezone: "America/Chicago"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
month: {
|
|
171
|
+
$month: {
|
|
172
|
+
date: '$date',
|
|
173
|
+
timezone: "America/Chicago"
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
year: {
|
|
177
|
+
$year: {
|
|
178
|
+
date: '$date',
|
|
179
|
+
timezone: "America/Chicago"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
client: '$client',
|
|
183
|
+
instance: '$instance'
|
|
184
|
+
};
|
|
185
|
+
groupDate = (_c = {
|
|
186
|
+
'year': '$_id.year',
|
|
187
|
+
'month': '$_id.month',
|
|
188
|
+
'day': '$_id.day',
|
|
189
|
+
'hour': '$_id.hour'
|
|
190
|
+
},
|
|
191
|
+
_c[variable] = '$' + variable,
|
|
192
|
+
_c);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
groupId = {
|
|
196
|
+
day: {
|
|
197
|
+
$dayOfMonth: {
|
|
198
|
+
date: '$date',
|
|
199
|
+
timezone: "America/Chicago"
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
month: {
|
|
203
|
+
$month: {
|
|
204
|
+
date: '$date',
|
|
205
|
+
timezone: "America/Chicago"
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
year: {
|
|
209
|
+
$year: {
|
|
210
|
+
date: '$date',
|
|
211
|
+
timezone: "America/Chicago"
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
client: '$client',
|
|
215
|
+
instance: '$instance'
|
|
216
|
+
};
|
|
217
|
+
groupDate = (_d = {
|
|
218
|
+
'year': '$_id.year',
|
|
219
|
+
'month': '$_id.month',
|
|
220
|
+
'day': '$_id.day'
|
|
221
|
+
},
|
|
222
|
+
_d[variable] = '$' + variable,
|
|
223
|
+
_d);
|
|
224
|
+
}
|
|
225
|
+
query = [
|
|
226
|
+
{
|
|
227
|
+
$match: {
|
|
228
|
+
$and: [
|
|
229
|
+
{
|
|
230
|
+
date: { $gte: date_start }
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
date: { $lte: date_end }
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
];
|
|
239
|
+
if (client) {
|
|
240
|
+
query[0]['$match'].$and.push({ client: client });
|
|
241
|
+
}
|
|
242
|
+
if (instance) {
|
|
243
|
+
query[0]['$match'].$and.push({ instance: instance });
|
|
244
|
+
}
|
|
245
|
+
if (variableType === 'count') {
|
|
246
|
+
query.push({
|
|
247
|
+
$group: {
|
|
248
|
+
_id: groupId,
|
|
249
|
+
count: {
|
|
250
|
+
$sum: 1
|
|
251
|
+
},
|
|
252
|
+
date: {
|
|
253
|
+
$first: '$date'
|
|
254
|
+
},
|
|
255
|
+
client: {
|
|
256
|
+
$first: '$client'
|
|
257
|
+
},
|
|
258
|
+
instance: {
|
|
259
|
+
$first: '$instance'
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
query.push({
|
|
266
|
+
$group: (_e = {
|
|
267
|
+
_id: groupId
|
|
268
|
+
},
|
|
269
|
+
_e[variable] = (_f = {},
|
|
270
|
+
_f['$' + variableType] = '$' + variable,
|
|
271
|
+
_f),
|
|
272
|
+
_e.date = {
|
|
273
|
+
$first: '$date'
|
|
274
|
+
},
|
|
275
|
+
_e.client = {
|
|
276
|
+
$first: '$client'
|
|
277
|
+
},
|
|
278
|
+
_e.instance = {
|
|
279
|
+
$first: '$instance'
|
|
280
|
+
},
|
|
281
|
+
_e)
|
|
282
|
+
});
|
|
283
|
+
query.push({
|
|
284
|
+
$addFields: (_g = {},
|
|
285
|
+
_g[variable] = groupDate,
|
|
286
|
+
_g)
|
|
287
|
+
});
|
|
288
|
+
query.push({
|
|
289
|
+
$group: {
|
|
290
|
+
_id: {
|
|
291
|
+
client: '$_id.client',
|
|
292
|
+
instance: '$_id.instance'
|
|
293
|
+
},
|
|
294
|
+
data: {
|
|
295
|
+
$push: '$' + variable
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
query.push({
|
|
301
|
+
$sort: {
|
|
302
|
+
'_id.client': 1,
|
|
303
|
+
'_id.instance': 1
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
return [4 /*yield*/, __1.ResolveIOServer.getMainDB().model(collection).aggregate(query).allowDiskUse(true)];
|
|
307
|
+
case 1:
|
|
308
|
+
graphData = _h.sent();
|
|
309
|
+
resolve(graphData);
|
|
310
|
+
return [2 /*return*/];
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}); });
|
|
314
|
+
},
|
|
315
|
+
skipValidation: true
|
|
316
|
+
},
|
|
10
317
|
monitorMongos: {
|
|
11
318
|
function: function () {
|
|
12
319
|
return monitor_mongo_collection_1.MonitorMongos.find().exec();
|
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;AAE1E,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACf,aAAa,EAAE;YACX,QAAQ,EAAE;gBACN,OAAO,wCAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACvC,CAAC;SACJ;QACD,WAAW,EAAE;YACT,QAAQ,EAAE;gBACN,OAAO,oCAAW,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACrC,CAAC;SACJ;QACD,cAAc,EAAE;YACZ,QAAQ,EAAE;gBACN,OAAO,0CAAc,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACxC,CAAC;SACJ;QACD,qBAAqB,EAAE;YACnB,QAAQ,EAAE;gBACN,OAAO,yDAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC/C,CAAC;SACJ;QACD,oBAAoB,EAAE;YAClB,QAAQ,EAAE;gBACN,OAAO,uDAAoB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC9C,CAAC;SACJ;KACP,CAAC,CAAC;AACJ,CAAC;AA5BD,gDA4BC","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';\n\nexport function loadMonitorMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n monitorMongos: {\n function: function() {\n return MonitorMongos.find().exec();\n }\n },\n monitorCPUs: {\n function: function() {\n return MonitorCPUs.find().exec();\n }\n },\n monitorMemorys: {\n function: function() {\n return MonitorMemorys.find().exec();\n }\n },\n monitorHTTPSOutbounds: {\n function: function() {\n return MonitorHTTPSOutbounds.find().exec();\n }\n },\n monitorHTTPSInbounds: {\n function: function() {\n return MonitorHTTPSInbounds.find().exec();\n }\n },\n\t});\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/methods/monitor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oFAAwE;AACxE,gFAAoE;AACpE,sGAAyF;AACzF,oGAAuF;AACvF,sFAA0E;AAC1E,wBAAqC;AAErC,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACf,iBAAiB,EAAE;YACf,SAAS,EAAE,IAAI;YACxB,QAAQ,EAAE,UAAS,UAAgB,EAAE,QAAc,EAAE,UAAkB,EAAE,QAAgB,EAAE,MAAc,EAAE,aAAqB,EAAE,QAAgB,EAAE,YAAoB;gBAA9J,iBA+QT;gBA9QA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;;;;gCACpC,OAAO,GAAG,EAAE,CAAC;gCACb,SAAS,GAAG,EAAE,CAAC;gCAEnB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AAC;;;;qBACnB,CAAC,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,IAAI;SACd;QACD,aAAa,EAAE;YACX,QAAQ,EAAE;gBACN,OAAO,wCAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACvC,CAAC;SACJ;QACD,WAAW,EAAE;YACT,QAAQ,EAAE;gBACN,OAAO,oCAAW,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACrC,CAAC;SACJ;QACD,cAAc,EAAE;YACZ,QAAQ,EAAE;gBACN,OAAO,0CAAc,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACxC,CAAC;SACJ;QACD,qBAAqB,EAAE;YACnB,QAAQ,EAAE;gBACN,OAAO,yDAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC/C,CAAC;SACJ;QACD,oBAAoB,EAAE;YAClB,QAAQ,EAAE;gBACN,OAAO,uDAAoB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC9C,CAAC;SACJ;KACP,CAAC,CAAC;AACJ,CAAC;AAhTD,gDAgTC","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 '..';\n\nexport function loadMonitorMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n superadminMonitor: {\n skipQueue: true,\n\t\t\tfunction: 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\t[variable]: '$' + variable\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\t[variable]: '$' + variable\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\t[variable]: '$' + variable\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\t[variable]: '$' + variable\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 }\n \n if (variableType === 'count') {\n query.push(\n {\n $group: {\n _id: groupId,\n count: {\n $sum: 1\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 }\n }\n ); \n }\n else {\n query.push(\n {\n $group: {\n _id: groupId,\n [variable]: {\n ['$' + variableType]: '$' + 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 }\n }\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\t[variable]: groupDate\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tquery.push(\n {\n $group: {\n _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 data: {\n $push: '$' + variable\n\t\t\t\t\t\t\t\t\t}\n }\n }\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$sort: {\n\t\t\t\t\t\t\t'_id.client': 1,\n\t\t\t\t\t\t\t'_id.instance': 1\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.getMainDB().model(collection).aggregate(query).allowDiskUse(true);\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().exec();\n }\n },\n monitorCPUs: {\n function: function() {\n return MonitorCPUs.find().exec();\n }\n },\n monitorMemorys: {\n function: function() {\n return MonitorMemorys.find().exec();\n }\n },\n monitorHTTPSOutbounds: {\n function: function() {\n return MonitorHTTPSOutbounds.find().exec();\n }\n },\n monitorHTTPSInbounds: {\n function: function() {\n return MonitorHTTPSInbounds.find().exec();\n }\n },\n\t});\n}"]}
|