@resolveio/server-lib 9.10.1 → 10.0.0
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/collections/app-status.collection.js +11 -1
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +11 -1
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +11 -1
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +11 -1
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +11 -1
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +11 -1
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +11 -1
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +11 -1
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +11 -1
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +11 -1
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +11 -1
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +11 -1
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +11 -1
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-response.collection.js +11 -1
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +24 -19
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +24 -18
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +24 -18
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +11 -1
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +11 -1
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +11 -1
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +11 -1
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +11 -1
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +11 -1
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +11 -1
- package/collections/user.collection.js.map +1 -1
- package/managers/mongo.manager.d.ts +17 -3
- package/managers/mongo.manager.js +43 -26
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +24 -89
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +17 -15
- package/managers/subscription.manager.js.map +1 -1
- package/methods/monitor.js +1 -13
- package/methods/monitor.js.map +1 -1
- package/models/monitor-cpu.model.d.ts +5 -2
- package/models/monitor-cpu.model.js.map +1 -1
- package/models/monitor-memory.model.d.ts +5 -2
- package/models/monitor-memory.model.js.map +1 -1
- package/models/monitor-mongo.model.d.ts +5 -2
- package/models/monitor-mongo.model.js.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +0 -4
- package/public_api.js +0 -4
- package/public_api.js.map +1 -1
- package/collections/monitor-https-inbound.collection.d.ts +0 -3
- package/collections/monitor-https-inbound.collection.js +0 -67
- package/collections/monitor-https-inbound.collection.js.map +0 -1
- package/collections/monitor-https-outbound.collection.d.ts +0 -3
- package/collections/monitor-https-outbound.collection.js +0 -75
- package/collections/monitor-https-outbound.collection.js.map +0 -1
- package/models/monitor-https-inbound.model.d.ts +0 -11
- package/models/monitor-https-inbound.model.js +0 -4
- package/models/monitor-https-inbound.model.js.map +0 -1
- package/models/monitor-https-outbound.model.d.ts +0 -12
- package/models/monitor-https-outbound.model.js +0 -4
- package/models/monitor-https-outbound.model.js.map +0 -1
|
@@ -40,8 +40,6 @@ exports.MonitorManager = void 0;
|
|
|
40
40
|
var bent = require("bent");
|
|
41
41
|
var monitor_cpu_collection_1 = require("../collections/monitor-cpu.collection");
|
|
42
42
|
var monitor_memory_collection_1 = require("../collections/monitor-memory.collection");
|
|
43
|
-
var monitor_https_inbound_collection_1 = require("../collections/monitor-https-inbound.collection");
|
|
44
|
-
var monitor_https_outbound_collection_1 = require("../collections/monitor-https-outbound.collection");
|
|
45
43
|
var monitor_mongo_collection_1 = require("../collections/monitor-mongo.collection");
|
|
46
44
|
var index_1 = require("../index");
|
|
47
45
|
var common_1 = require("../util/common");
|
|
@@ -73,9 +71,10 @@ var MonitorManager = /** @class */ (function () {
|
|
|
73
71
|
if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
|
|
74
72
|
monitor_cpu_collection_1.MonitorCPUs.create({
|
|
75
73
|
_id: mongo_manager_1.objectIdHexString(),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
metadata: {
|
|
75
|
+
instance: this._instanceHostname,
|
|
76
|
+
client: this._serverConfig['CLIENT_NAME']
|
|
77
|
+
},
|
|
79
78
|
date: new Date(data.time),
|
|
80
79
|
app: data.process,
|
|
81
80
|
system: data.system
|
|
@@ -84,8 +83,10 @@ var MonitorManager = /** @class */ (function () {
|
|
|
84
83
|
else {
|
|
85
84
|
if (this._instanceHostname) {
|
|
86
85
|
this._monitorData.push({
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
metadata: {
|
|
87
|
+
instance: this._instanceHostname,
|
|
88
|
+
client: this._serverConfig['CLIENT_NAME']
|
|
89
|
+
},
|
|
89
90
|
date: new Date(data.time),
|
|
90
91
|
type: 'cpu',
|
|
91
92
|
app: data.process,
|
|
@@ -101,9 +102,10 @@ var MonitorManager = /** @class */ (function () {
|
|
|
101
102
|
if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
|
|
102
103
|
monitor_memory_collection_1.MonitorMemorys.create({
|
|
103
104
|
_id: mongo_manager_1.objectIdHexString(),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
metadata: {
|
|
106
|
+
instance: this._instanceHostname,
|
|
107
|
+
client: this._serverConfig['CLIENT_NAME']
|
|
108
|
+
},
|
|
107
109
|
date: new Date(data.time),
|
|
108
110
|
physical_total: data.physical_total,
|
|
109
111
|
physical_used: data.physical_used,
|
|
@@ -116,8 +118,10 @@ var MonitorManager = /** @class */ (function () {
|
|
|
116
118
|
else {
|
|
117
119
|
if (this._instanceHostname) {
|
|
118
120
|
this._monitorData.push({
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
metadata: {
|
|
122
|
+
instance: this._instanceHostname,
|
|
123
|
+
client: this._serverConfig['CLIENT_NAME']
|
|
124
|
+
},
|
|
121
125
|
date: new Date(data.time),
|
|
122
126
|
type: 'memory',
|
|
123
127
|
physical_total: data.physical_total,
|
|
@@ -132,87 +136,16 @@ var MonitorManager = /** @class */ (function () {
|
|
|
132
136
|
return [2 /*return*/];
|
|
133
137
|
});
|
|
134
138
|
}); });
|
|
135
|
-
this._monitorAgent.on('https', function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
136
|
-
return __generator(this, function (_a) {
|
|
137
|
-
if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
|
|
138
|
-
monitor_https_inbound_collection_1.MonitorHTTPSInbounds.create({
|
|
139
|
-
_id: mongo_manager_1.objectIdHexString(),
|
|
140
|
-
__v: 0,
|
|
141
|
-
instance: this._instanceHostname,
|
|
142
|
-
client: this._serverConfig['CLIENT_NAME'],
|
|
143
|
-
date: new Date(data.time),
|
|
144
|
-
method: data.method,
|
|
145
|
-
url: data.url,
|
|
146
|
-
duration: data.duration,
|
|
147
|
-
contentType: data.contentType,
|
|
148
|
-
requestHeader: data.requestHeader
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
if (this._instanceHostname) {
|
|
153
|
-
this._monitorData.push({
|
|
154
|
-
instance: this._instanceHostname,
|
|
155
|
-
client: this._serverConfig['CLIENT_NAME'],
|
|
156
|
-
date: new Date(data.time),
|
|
157
|
-
type: 'https-inbound',
|
|
158
|
-
method: data.method,
|
|
159
|
-
url: data.url,
|
|
160
|
-
duration: data.duration,
|
|
161
|
-
contentType: data.contentType,
|
|
162
|
-
requestHeader: data.requestHeader
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return [2 /*return*/];
|
|
167
|
-
});
|
|
168
|
-
}); });
|
|
169
|
-
this._monitorAgent.on('https-outbound', function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
170
|
-
return __generator(this, function (_a) {
|
|
171
|
-
if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
|
|
172
|
-
monitor_https_outbound_collection_1.MonitorHTTPSOutbounds.create({
|
|
173
|
-
_id: mongo_manager_1.objectIdHexString(),
|
|
174
|
-
__v: 0,
|
|
175
|
-
instance: this._instanceHostname,
|
|
176
|
-
client: this._serverConfig['CLIENT_NAME'],
|
|
177
|
-
date: new Date(data.time),
|
|
178
|
-
method: data.method,
|
|
179
|
-
url: data.url,
|
|
180
|
-
duration: data.duration,
|
|
181
|
-
status: data.status,
|
|
182
|
-
contentType: data.contentType,
|
|
183
|
-
requestHeaders: data.requestHeaders
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
if (!data.url.startsWith('https://backend.resolveio.com/api/monitor/')) {
|
|
188
|
-
if (this._instanceHostname) {
|
|
189
|
-
this._monitorData.push({
|
|
190
|
-
instance: this._instanceHostname,
|
|
191
|
-
client: this._serverConfig['CLIENT_NAME'],
|
|
192
|
-
date: new Date(data.time),
|
|
193
|
-
type: 'https-outbound',
|
|
194
|
-
method: data.method,
|
|
195
|
-
url: data.url,
|
|
196
|
-
duration: data.duration,
|
|
197
|
-
status: data.status,
|
|
198
|
-
contentType: data.contentType,
|
|
199
|
-
requestHeaders: data.requestHeaders
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return [2 /*return*/];
|
|
205
|
-
});
|
|
206
|
-
}); });
|
|
207
139
|
this._monitorAgent.on('mongo', function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
208
140
|
return __generator(this, function (_a) {
|
|
209
141
|
if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
|
|
210
142
|
if (!data.collection.startsWith('monitor-')) {
|
|
211
143
|
monitor_mongo_collection_1.MonitorMongos.create({
|
|
212
144
|
_id: mongo_manager_1.objectIdHexString(),
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
145
|
+
metadata: {
|
|
146
|
+
instance: this._instanceHostname,
|
|
147
|
+
client: this._serverConfig['CLIENT_NAME']
|
|
148
|
+
},
|
|
216
149
|
date: new Date(data.time),
|
|
217
150
|
method: data.method,
|
|
218
151
|
doc_collection: data.collection,
|
|
@@ -224,8 +157,10 @@ var MonitorManager = /** @class */ (function () {
|
|
|
224
157
|
else {
|
|
225
158
|
if (this._instanceHostname) {
|
|
226
159
|
this._monitorData.push({
|
|
227
|
-
|
|
228
|
-
|
|
160
|
+
metadata: {
|
|
161
|
+
instance: this._instanceHostname,
|
|
162
|
+
client: this._serverConfig['CLIENT_NAME']
|
|
163
|
+
},
|
|
229
164
|
date: new Date(data.time),
|
|
230
165
|
type: 'mongo',
|
|
231
166
|
method: data.method,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/monitor.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2BAA6B;AAC7B,gFAAoE;AACpE,sFAA0E;AAC1E,oGAAuF;AACvF,sGAAyF;AACzF,oFAAwE;AACxE,kCAA2C;AAC3C,yCAA0C;AAC1C,iDAAoD;AAEpD;IAOC,wBAAY,UAAU,EAAE,YAAY,EAAE,YAAY;QAH1C,sBAAiB,GAAG,EAAE,CAAC;QACvB,iBAAY,GAAG,EAAE,CAAC;QAGzB,IAAI,C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CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,EAAE;4BACzH,uBAAe,CAAC,aAAa,EAAE,CAAC,gBAAgB,EAAE,CAAC,SAAS,CAAC,mBAAmB,EAAE,yCAAyC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;4BAEzJ,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;yBACf;;;wBAjBoC,CAAC,EAAE,CAAA;;;6BAsBvC,OAAO,CAAC,MAAM,EAAd,yBAAc;;;;wBAEC,qBAAM,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,EAAA;;wBAA9C,QAAQ,GAAG,SAAmC;;;;wBAGpD,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,EAAE;4BACzH,uBAAe,CAAC,aAAa,EAAE,CAAC,gBAAgB,EAAE,CAAC,SAAS,CAAC,mBAAmB,EAAE,yCAAyC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;4BAEzJ,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;yBACf;;;wBAML,IAAI,CAAC,cAAc,EAAE,CAAC;;;;aACtB,EAAE,KAAK,CAAC,CAAC;IACX,CAAC;IACF,qBAAC;AAAD,CA/QA,AA+QC,IAAA;AA/QY,wCAAc","file":"monitor.manager.js","sourcesContent":["import ResolveIOMainServer from '../server-app';\nimport * as bent from 'bent';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\nimport { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';\nimport { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\nimport { ResolveIOServer } from '../index';\nimport { deepCopy } from '../util/common';\nimport { objectIdHexString } from './mongo.manager';\n\nexport class MonitorManager {\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _monitorAgent;\n\tprivate _serverConfig;\n\tprivate _instanceHostname = '';\n\tprivate _monitorData = [];\n\n\tconstructor(mainServer, monitorAgent, serverConfig) {\n\t\tthis._mainServer = mainServer;\n\t\tthis._monitorAgent = monitorAgent;\n\t\tthis._serverConfig = serverConfig;\n\n\t\tthis.setupEvents();\n\t\tthis.setupEventLoop();\n\t}\n\n\tsetupEvents() {\t\t\n\t\tthis._monitorAgent.on('initialized', (env) => {\n\t\t\tenv = this._monitorAgent.getEnvironment();\n\t\t\tfor (let entry in env) {\n\t\t\t\tconsole.log(entry + ':' + env[entry]);\n\t\t\t\tif (entry === 'environment.HOSTNAME') {\n\t\t\t\t\tthis._instanceHostname = env[entry].replace('ip-', '').replace(/-/g, '.');\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t\t\n\t\tthis._monitorAgent.on('cpu', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorCPUs.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tapp: data.process,\n\t\t\t\t\tsystem: data.system\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'cpu',\n\t\t\t\t\t\tapp: data.process,\n\t\t\t\t\t\tsystem: data.system\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('memory', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorMemorys.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\tprivate: data.private,\n\t\t\t\t\tphysical: data.physical\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'memory',\n\t\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\t\tprivate: data.private,\n\t\t\t\t\t\tphysical: data.physical\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('https', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorHTTPSInbounds.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeader: data.requestHeader\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'https-inbound',\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\t\trequestHeader: data.requestHeader\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('https-outbound', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorHTTPSOutbounds.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tstatus: data.status,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeaders: data.requestHeaders\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (!data.url.startsWith('https://backend.resolveio.com/api/monitor/')) {\n\t\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\t\ttype: 'https-outbound',\n\t\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\t\tstatus: data.status,\n\t\t\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\t\t\trequestHeaders: data.requestHeaders\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('mongo', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tif (!data.collection.startsWith('monitor-')) {\n\t\t\t\t\tMonitorMongos.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tquery: data.query\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'mongo',\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tquery: data.query\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('eventloop', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tconsole.log(JSON.stringify(data, null, 2));\n\t\t\t}\n\t\t});\n\n\t\t// this._monitorAgent.on('socket', async (data) => {\n\t\t// \tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\n\t\t// \t}\n\t\t// \telse {\n\t\t// \t\tconst response = await post('/api/monitor/socket', {\n\t\t// \t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t// \t\t\tdate: new Date(data.time),\n\t\t\t\t\t\n\t\t// \t\t});\n\t\t// \t}\n\t\t// });\n\t}\n\n\tsetupEventLoop() {\n\t\tsetTimeout(async () => {\n\t\t\tif (this._monitorData.length) {\n\t\t\t\tconst post = bent('https://backend.resolveio.com', 'POST', 'json', 200);\n\n\t\t\t\tlet monitorData = deepCopy(this._monitorData);\n\t\t\t\tthis._monitorData = [];\n\n\t\t\t\tlet size = JSON.stringify(monitorData).replace(/[\\[\\]\\,\\\"]/g,'').length * 8;\n\n\t\t\t\tif (size < 45000000) { // 50 MB size limit\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await post('/api/monitor', monitorData);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\n\t\t\t\t\t\t\tconsole.log(e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet tmpData = [];\n\t\t\t\t\tfor (let i = 0; i < monitorData.length; i++) {\n\t\t\t\t\t\ttmpData.push(monitorData[i]);\n\t\t\t\t\t\tsize = JSON.stringify(tmpData).replace(/[\\[\\]\\,\\\"]/g,'').length * 8;\n\n\t\t\t\t\t\tif (size > 45000000) {\n\t\t\t\t\t\t\ttmpData.pop();\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst response = await post('/api/monitor', tmpData);\n\n\t\t\t\t\t\t\t\ttmpData = [monitorData[i]];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\t\t\n\t\t\t\t\t\t\t\t\tconsole.log(e);\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\tif (tmpData.length) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst response = await post('/api/monitor', tmpData);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\t\n\t\t\t\t\t\t\t\tconsole.log(e);\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}\n\t\t\t}\n\n\t\t\tthis.setupEventLoop();\n\t\t}, 60000);\n\t}\n}"]}
|
|
1
|
+
{"version":3,"sources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E,CAAC,CAAC,CAAC,CAAC;4BAEzJ,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;yBACf;;;wBAML,IAAI,CAAC,cAAc,EAAE,CAAC;;;;aACtB,EAAE,KAAK,CAAC,CAAC;IACX,CAAC;IACF,qBAAC;AAAD,CApNA,AAoNC,IAAA;AApNY,wCAAc","file":"monitor.manager.js","sourcesContent":["import ResolveIOMainServer from '../server-app';\nimport * as bent from 'bent';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\nimport { ResolveIOServer } from '../index';\nimport { deepCopy } from '../util/common';\nimport { objectIdHexString } from './mongo.manager';\n\nexport class MonitorManager {\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _monitorAgent;\n\tprivate _serverConfig;\n\tprivate _instanceHostname = '';\n\tprivate _monitorData = [];\n\n\tconstructor(mainServer, monitorAgent, serverConfig) {\n\t\tthis._mainServer = mainServer;\n\t\tthis._monitorAgent = monitorAgent;\n\t\tthis._serverConfig = serverConfig;\n\n\t\tthis.setupEvents();\n\t\tthis.setupEventLoop();\n\t}\n\n\tsetupEvents() {\t\t\n\t\tthis._monitorAgent.on('initialized', (env) => {\n\t\t\tenv = this._monitorAgent.getEnvironment();\n\t\t\tfor (let entry in env) {\n\t\t\t\tconsole.log(entry + ':' + env[entry]);\n\t\t\t\tif (entry === 'environment.HOSTNAME') {\n\t\t\t\t\tthis._instanceHostname = env[entry].replace('ip-', '').replace(/-/g, '.');\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t\t\n\t\tthis._monitorAgent.on('cpu', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorCPUs.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME']\n\t\t\t\t\t},\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tapp: data.process,\n\t\t\t\t\tsystem: data.system\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'cpu',\n\t\t\t\t\t\tapp: data.process,\n\t\t\t\t\t\tsystem: data.system\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('memory', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorMemorys.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME']\n\t\t\t\t\t},\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\tprivate: data.private,\n\t\t\t\t\tphysical: data.physical\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'memory',\n\t\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\t\tprivate: data.private,\n\t\t\t\t\t\tphysical: data.physical\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('mongo', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tif (!data.collection.startsWith('monitor-')) {\n\t\t\t\t\tMonitorMongos.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tquery: data.query\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'mongo',\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tquery: data.query\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('eventloop', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tconsole.log(JSON.stringify(data, null, 2));\n\t\t\t}\n\t\t});\n\n\t\t// this._monitorAgent.on('socket', async (data) => {\n\t\t// \tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\n\t\t// \t}\n\t\t// \telse {\n\t\t// \t\tconst response = await post('/api/monitor/socket', {\n\t\t// \t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t// \t\t\tdate: new Date(data.time),\n\t\t\t\t\t\n\t\t// \t\t});\n\t\t// \t}\n\t\t// });\n\t}\n\n\tsetupEventLoop() {\n\t\tsetTimeout(async () => {\n\t\t\tif (this._monitorData.length) {\n\t\t\t\tconst post = bent('https://backend.resolveio.com', 'POST', 'json', 200);\n\n\t\t\t\tlet monitorData = deepCopy(this._monitorData);\n\t\t\t\tthis._monitorData = [];\n\n\t\t\t\tlet size = JSON.stringify(monitorData).replace(/[\\[\\]\\,\\\"]/g,'').length * 8;\n\n\t\t\t\tif (size < 45000000) { // 50 MB size limit\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await post('/api/monitor', monitorData);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\n\t\t\t\t\t\t\tconsole.log(e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet tmpData = [];\n\t\t\t\t\tfor (let i = 0; i < monitorData.length; i++) {\n\t\t\t\t\t\ttmpData.push(monitorData[i]);\n\t\t\t\t\t\tsize = JSON.stringify(tmpData).replace(/[\\[\\]\\,\\\"]/g,'').length * 8;\n\n\t\t\t\t\t\tif (size > 45000000) {\n\t\t\t\t\t\t\ttmpData.pop();\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst response = await post('/api/monitor', tmpData);\n\n\t\t\t\t\t\t\t\ttmpData = [monitorData[i]];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\t\t\n\t\t\t\t\t\t\t\t\tconsole.log(e);\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\tif (tmpData.length) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst response = await post('/api/monitor', tmpData);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\t\n\t\t\t\t\t\t\t\tconsole.log(e);\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}\n\t\t\t}\n\n\t\t\tthis.setupEventLoop();\n\t\t}, 60000);\n\t}\n}"]}
|
|
@@ -176,27 +176,29 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
176
176
|
_loop_2 = function (i) {
|
|
177
177
|
var mongoQueue = queueArr[i];
|
|
178
178
|
if (this_2._publications[mongoQueue.subscription.publication].user_specific) {
|
|
179
|
+
var promises = [];
|
|
179
180
|
for (var j = 0; j < mongoQueue.subscription.clients.length; j++) {
|
|
180
181
|
var client = mongoQueue.subscription.clients[j];
|
|
181
182
|
var ws = this_2._mainServer.getWS(client.id_socket);
|
|
182
183
|
if (ws && ws['id_socket'] === client.id_socket) {
|
|
183
|
-
this_2.sendDataToOne(ws, client.messageId, mongoQueue.subscription, mongoQueue.type, mongoQueue.collection)
|
|
184
|
-
if (mongoQueue.run_again) {
|
|
185
|
-
mongoQueue.running = false;
|
|
186
|
-
mongoQueue.run_again = false;
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
190
|
-
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}, function () {
|
|
194
|
-
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
195
|
-
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
196
|
-
}
|
|
197
|
-
});
|
|
184
|
+
promises.push(this_2.sendDataToOne(ws, client.messageId, mongoQueue.subscription, mongoQueue.type, mongoQueue.collection));
|
|
198
185
|
}
|
|
199
186
|
}
|
|
187
|
+
Promise.all(promises).then(function () {
|
|
188
|
+
if (mongoQueue.run_again) {
|
|
189
|
+
mongoQueue.running = false;
|
|
190
|
+
mongoQueue.run_again = false;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
194
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}).catch(function () {
|
|
198
|
+
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
199
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
200
202
|
}
|
|
201
203
|
else {
|
|
202
204
|
this_2.sendDataToAll(mongoQueue).then(function () {
|