whatap 1.0.1 → 1.0.2
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/README.md +32 -78
- package/lib/conf/conf-sys-mon.js +101 -0
- package/lib/conf/config-default.js +10 -3
- package/lib/conf/configure.js +369 -349
- package/lib/conf/license.js +1 -1
- package/lib/control/cmd-config.js +24 -0
- package/lib/control/control-handler.js +367 -0
- package/lib/control/packagectr-helper.js +34 -3
- package/lib/core/agent.js +176 -882
- package/lib/core/interceptor.js +6 -6
- package/lib/core/request-agent.js +27 -0
- package/lib/core/shimmer.js +82 -36
- package/lib/counter/counter-manager.js +79 -8
- package/lib/counter/meter/meter-activex.js +67 -0
- package/lib/counter/meter/meter-httpc.js +57 -0
- package/lib/counter/meter/meter-resource.js +9 -0
- package/lib/counter/meter/meter-service.js +168 -0
- package/lib/counter/meter/meter-socket.io.js +51 -0
- package/lib/counter/meter/meter-sql.js +71 -0
- package/lib/counter/meter/meter-users.js +58 -0
- package/lib/counter/meter.js +183 -0
- package/lib/counter/task/activetransaction.js +68 -17
- package/lib/counter/task/agentinfo.js +107 -0
- package/lib/{system → counter/task}/gc-action.js +27 -74
- package/lib/counter/task/gcstat.js +34 -0
- package/lib/counter/task/heapmem.js +25 -0
- package/lib/counter/task/httpc.js +76 -0
- package/lib/counter/task/metering-info.js +125 -0
- package/lib/counter/task/proc-cpu.js +29 -0
- package/lib/counter/task/realtimeuser.js +31 -0
- package/lib/counter/task/res/systemECSTask.js +39 -0
- package/lib/counter/task/res/systemKubeTask.js +53 -0
- package/lib/counter/task/res/util/awsEcsClientThread.js +218 -0
- package/lib/counter/task/res/util/linuxProcStatUtil.js +14 -0
- package/lib/counter/task/res-sys-cpu.js +62 -0
- package/lib/counter/task/service.js +202 -0
- package/lib/counter/task/socketio.js +30 -0
- package/lib/counter/task/sql.js +105 -0
- package/lib/counter/task/systemperf.js +43 -0
- package/lib/data/datapack-sender.js +289 -0
- package/lib/data/dataprofile-agent.js +162 -0
- package/lib/data/datatext-agent.js +135 -0
- package/lib/data/event-level.js +15 -0
- package/lib/data/test.js +49 -0
- package/lib/data/zipprofile.js +197 -0
- package/lib/env/constants.js +21 -0
- package/lib/error/error-handler.js +437 -0
- package/lib/io/data-inputx.js +13 -3
- package/lib/io/data-outputx.js +268 -206
- package/lib/kube/kube-client.js +144 -0
- package/lib/lang/text-types.js +58 -0
- package/lib/logger.js +6 -6
- package/lib/logsink/line-log-util.js +87 -0
- package/lib/logsink/line-log.js +12 -0
- package/lib/logsink/log-sender.js +78 -0
- package/lib/logsink/log-tracer.js +40 -0
- package/lib/logsink/sender-util.js +56 -0
- package/lib/logsink/zip/zip-send.js +177 -0
- package/lib/net/netflag.js +55 -0
- package/lib/net/receiver.js +66 -0
- package/lib/net/security-master.js +139 -20
- package/lib/net/sender.js +141 -0
- package/lib/net/tcp-return.js +18 -0
- package/lib/net/tcp-session.js +286 -0
- package/lib/net/tcpreq-client-proxy.js +70 -0
- package/lib/net/tcprequest-mgr.js +58 -0
- package/lib/observers/apollo-server-observer.js +33 -27
- package/lib/observers/cluster-observer.js +22 -0
- package/lib/observers/express-observer.js +215 -0
- package/lib/observers/file-observer.js +184 -0
- package/lib/observers/global-observer.js +155 -80
- package/lib/observers/grpc-observer.js +336 -0
- package/lib/observers/http-observer.js +666 -236
- package/lib/observers/maria-observer.js +204 -362
- package/lib/observers/memcached-observer.js +56 -0
- package/lib/observers/mongo-observer.js +317 -0
- package/lib/observers/mongodb-observer.js +169 -226
- package/lib/observers/mongoose-observer.js +518 -323
- package/lib/observers/mssql-observer.js +177 -418
- package/lib/observers/mysql-observer.js +342 -449
- package/lib/observers/mysql2-observer.js +396 -358
- package/lib/observers/net-observer.js +77 -0
- package/lib/observers/oracle-observer.js +559 -384
- package/lib/observers/pgsql-observer.js +231 -489
- package/lib/observers/prisma-observer.js +303 -92
- package/lib/observers/process-observer.js +79 -35
- package/lib/observers/promise-observer.js +31 -0
- package/lib/observers/redis-observer.js +166 -331
- package/lib/observers/schedule-observer.js +67 -0
- package/lib/observers/socket.io-observer.js +226 -187
- package/lib/observers/stream-observer.js +19 -0
- package/lib/observers/thrift-observer.js +197 -0
- package/lib/observers/websocket-observer.js +175 -301
- package/lib/pack/activestack-pack.js +55 -0
- package/lib/pack/apenum.js +8 -0
- package/lib/pack/counter-pack.js +3 -0
- package/lib/pack/errorsnap-pack.js +69 -0
- package/lib/pack/event-pack.js +54 -0
- package/lib/pack/hitmap-pack.js +63 -0
- package/lib/pack/hitmap-pack1.js +152 -0
- package/lib/pack/log-sink-pack.js +14 -52
- package/lib/pack/netstat.js +15 -0
- package/lib/pack/otype.js +7 -0
- package/lib/pack/profile-pack.js +49 -0
- package/lib/pack/realtimeuser-pack.js +41 -0
- package/lib/pack/stat-general-pack.js +96 -0
- package/lib/pack/staterror-pack.js +120 -0
- package/lib/pack/stathttpc-pack.js +66 -0
- package/lib/pack/stathttpc-rec.js +78 -0
- package/lib/pack/statremote-pack.js +46 -0
- package/lib/pack/statservice-pack.js +63 -0
- package/lib/pack/statservice-pack1.js +88 -0
- package/lib/pack/statservice-rec.js +292 -0
- package/lib/pack/statservice-rec_dep.js +151 -0
- package/lib/pack/statsql-pack.js +69 -0
- package/lib/pack/statsql-rec.js +100 -0
- package/lib/pack/statuseragent-pack.js +44 -0
- package/lib/pack/tagcount-pack.js +4 -4
- package/lib/pack/tagctr.js +15 -0
- package/lib/pack/text-pack.js +50 -0
- package/lib/pack/time-count.js +25 -0
- package/lib/pack/websocket.js +15 -0
- package/lib/pack/zip-pack.js +70 -0
- package/lib/pii/pii-item.js +31 -0
- package/lib/pii/pii-mask.js +174 -0
- package/lib/plugin/plugin-loadermanager.js +57 -0
- package/lib/plugin/plugin.js +75 -0
- package/lib/service/tx-record.js +332 -0
- package/lib/stat/stat-error.js +116 -0
- package/lib/stat/stat-httpc.js +98 -0
- package/lib/stat/stat-remote-ip.js +46 -0
- package/lib/stat/stat-remote-ipurl.js +88 -0
- package/lib/stat/stat-sql.js +113 -0
- package/lib/stat/stat-tranx.js +58 -0
- package/lib/stat/stat-tx-caller.js +160 -0
- package/lib/stat/stat-tx-domain.js +111 -0
- package/lib/stat/stat-tx-referer.js +112 -0
- package/lib/stat/stat-useragent.js +48 -0
- package/lib/stat/timingsender.js +76 -0
- package/lib/step/activestack-step.js +38 -0
- package/lib/step/dbc-step.js +36 -0
- package/lib/step/http-stepx.js +67 -0
- package/lib/step/message-step.js +40 -0
- package/lib/step/method-stepx.js +45 -0
- package/lib/step/resultset-step.js +40 -0
- package/lib/step/securemsg-step.js +44 -0
- package/lib/step/socket-step.js +46 -0
- package/lib/step/sql-stepx.js +68 -0
- package/lib/step/sqlxtype.js +16 -0
- package/lib/step/step.js +66 -0
- package/lib/step/stepenum.js +54 -0
- package/lib/topology/link.js +63 -0
- package/lib/topology/nodeinfo.js +123 -0
- package/lib/topology/status-detector.js +111 -0
- package/lib/trace/trace-context-manager.js +113 -25
- package/lib/trace/trace-context.js +21 -7
- package/lib/trace/trace-httpc.js +17 -11
- package/lib/trace/trace-sql.js +29 -21
- package/lib/util/anylist.js +103 -0
- package/lib/util/cardinality/hyperloglog.js +106 -0
- package/lib/util/cardinality/murmurhash.js +31 -0
- package/lib/util/cardinality/registerset.js +75 -0
- package/lib/util/errordata.js +21 -0
- package/lib/util/escape-literal-sql.js +5 -5
- package/lib/util/hashutil.js +18 -18
- package/lib/util/iputil_x.js +527 -0
- package/lib/util/keygen.js +0 -3
- package/lib/util/kube-util.js +73 -0
- package/lib/util/linkedset.js +1 -2
- package/lib/util/nodeutil.js +2 -1
- package/lib/util/paramsecurity.js +80 -0
- package/lib/util/pre-process.js +13 -0
- package/lib/util/process-seq.js +166 -0
- package/lib/util/property-util.js +36 -0
- package/lib/util/request-queue.js +70 -0
- package/lib/util/requestdouble-queue.js +72 -0
- package/lib/util/resourceprofile.js +157 -0
- package/lib/util/stop-watch.js +30 -0
- package/lib/util/system-util.js +10 -0
- package/lib/util/userid-util.js +57 -0
- package/lib/value/map-value.js +3 -2
- package/package.json +9 -4
- package/whatap.conf +1 -4
- package/agent/darwin/arm64/whatap_nodejs +0 -0
- package/agent/linux/amd64/whatap_nodejs +0 -0
- package/agent/linux/arm64/whatap_nodejs +0 -0
- package/build.txt +0 -4
- package/lib/observers/ioredis-observer.js +0 -294
- package/lib/udp/async_sender.js +0 -119
- package/lib/udp/index.js +0 -17
- package/lib/udp/packet_enum.js +0 -52
- package/lib/udp/packet_queue.js +0 -69
- package/lib/udp/packet_type_enum.js +0 -33
- package/lib/udp/param_def.js +0 -72
- package/lib/udp/udp_session.js +0 -336
- package/lib/util/sql-util.js +0 -178
- package/lib/util/trace-helper.js +0 -91
- package/lib/util/transfer.js +0 -58
|
@@ -4,22 +4,18 @@
|
|
|
4
4
|
* can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
var CounterTask = require('
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
DataOutputX = require('../../lib/io/data-outputx'),
|
|
18
|
-
ParamPack = require('../pack/param-pack').ParamPack,
|
|
19
|
-
MapValue = require('../value/map-value');
|
|
7
|
+
var CounterTask = require('./counter-task'),
|
|
8
|
+
DataPackSender = require('../../data/datapack-sender'),
|
|
9
|
+
conf = require('../../conf/configure'),
|
|
10
|
+
DateUtil = require('../../util/dateutil'),
|
|
11
|
+
Logger = require('../../logger'),
|
|
12
|
+
TagCountPack = require('../../pack/tagcount-pack'),
|
|
13
|
+
HashUtil = require('../../util/hashutil'),
|
|
14
|
+
SecurityMaster = require('../../../lib/net/security-master'),
|
|
15
|
+
NodeUtil = require('../../util/nodeutil'),
|
|
16
|
+
IPUtil = require('../../util/iputil');
|
|
20
17
|
|
|
21
18
|
const { PerformanceObserver } = require('perf_hooks');
|
|
22
|
-
const DataOuputX = require('../../lib/io/data-outputx');
|
|
23
19
|
|
|
24
20
|
function GCAction() {
|
|
25
21
|
CounterTask.call(this);
|
|
@@ -40,19 +36,19 @@ GCAction.prototype.checkGCObserverSupport = function () {
|
|
|
40
36
|
}
|
|
41
37
|
};
|
|
42
38
|
|
|
43
|
-
GCAction.prototype.process = function () {
|
|
39
|
+
GCAction.prototype.process = function (p) {
|
|
44
40
|
try {
|
|
45
41
|
if (!conf.getProperty('perfx_nodejs_gc_enabled', false) || !this.isObserverSupported) {
|
|
46
42
|
return;
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
this.
|
|
45
|
+
this.nodejs_memory_gc(p);
|
|
50
46
|
} catch (e) {
|
|
51
47
|
Logger.printError("WHATAP-GC-003", "NodeJS GC process error", e, false);
|
|
52
48
|
}
|
|
53
49
|
};
|
|
54
50
|
|
|
55
|
-
GCAction.prototype.
|
|
51
|
+
GCAction.prototype.nodejs_memory_gc = function (p) {
|
|
56
52
|
const gcStats = new Map();
|
|
57
53
|
const self = this;
|
|
58
54
|
|
|
@@ -82,7 +78,7 @@ GCAction.prototype.getNodeMemoryGC = function () {
|
|
|
82
78
|
|
|
83
79
|
// 수집된 데이터가 있으면 전송
|
|
84
80
|
if (gcStats.size > 0) {
|
|
85
|
-
self.sendGCData(gcStats);
|
|
81
|
+
self.sendGCData(p, gcStats);
|
|
86
82
|
}
|
|
87
83
|
});
|
|
88
84
|
|
|
@@ -92,21 +88,20 @@ GCAction.prototype.getNodeMemoryGC = function () {
|
|
|
92
88
|
}
|
|
93
89
|
};
|
|
94
90
|
|
|
95
|
-
GCAction.prototype.sendGCData = function (gc_stats) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
p.category = "nodejsx_memory_gc";
|
|
91
|
+
GCAction.prototype.sendGCData = function (p, gc_stats) {
|
|
92
|
+
const pk = new TagCountPack();
|
|
93
|
+
pk.time = Math.floor(Date.now() / 1000) * 1000;
|
|
94
|
+
pk.category = "nodejsx_memory_gc";
|
|
100
95
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
96
|
+
pk.putTagString("oname", SecurityMaster.ONAME);
|
|
97
|
+
pk.putTagString("host_ip", IPUtil.getIp());
|
|
98
|
+
pk.putTagInt("pid", process.pid);
|
|
99
|
+
pk.putTagInt("!rectype", 2);
|
|
105
100
|
|
|
106
|
-
const idLv =
|
|
107
|
-
const nameLv =
|
|
108
|
-
const countLv =
|
|
109
|
-
const timeLv =
|
|
101
|
+
const idLv = pk.fields.internList("@id");
|
|
102
|
+
const nameLv = pk.fields.internList("name");
|
|
103
|
+
const countLv = pk.fields.internList("CollectionCount");
|
|
104
|
+
const timeLv = pk.fields.internList("CollectionTime");
|
|
110
105
|
|
|
111
106
|
// GC 통계 데이터 추가
|
|
112
107
|
for (const [gc_name, stats] of gc_stats) {
|
|
@@ -116,51 +111,9 @@ GCAction.prototype.sendGCData = function (gc_stats) {
|
|
|
116
111
|
timeLv.addLong(Math.round(stats.collectionTime));
|
|
117
112
|
}
|
|
118
113
|
|
|
119
|
-
|
|
120
|
-
bout.writePack(p, null);
|
|
121
|
-
const packbytes = bout.toByteArray();
|
|
122
|
-
|
|
123
|
-
AsyncSender.send_relaypack(packbytes)
|
|
114
|
+
DataPackSender.sendTagCounterPack(pk);
|
|
124
115
|
};
|
|
125
116
|
|
|
126
|
-
GCAction.prototype.execSystemGC = function () {
|
|
127
|
-
var p = new ParamPack();
|
|
128
|
-
p.pcode = SecurityMaster.PCODE;
|
|
129
|
-
p.oid = SecurityMaster.OID;
|
|
130
|
-
p.oname = SecurityMaster.ONAME;
|
|
131
|
-
p.okind = SecurityMaster.OKIND;
|
|
132
|
-
// p.oid
|
|
133
|
-
try {
|
|
134
|
-
var mem1 = process.memoryUsage();
|
|
135
|
-
var total1 = mem1.heapTotal;
|
|
136
|
-
var used1 = mem1.heapUsed;
|
|
137
|
-
|
|
138
|
-
if (global && global.gc && typeof global.gc === 'function') {
|
|
139
|
-
global.gc();
|
|
140
|
-
} else {
|
|
141
|
-
Logger.printError('WHATAP-601', 'Garbage collection unavailable. Pass --expose-gc '
|
|
142
|
-
+ 'when launching node to enable forced garbage collection.', new Error());
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
var mem2 = process.memoryUsage();
|
|
146
|
-
var total2 = mem2.heapTotal;
|
|
147
|
-
var used2 = mem2.heapUsed;
|
|
148
|
-
|
|
149
|
-
var mv = new MapValue();
|
|
150
|
-
mv.putLong("before-t", total1);
|
|
151
|
-
mv.putLong("before-u", used1);
|
|
152
|
-
mv.putLong("after-t", total2);
|
|
153
|
-
mv.putLong("after-u", used2);
|
|
154
|
-
p.putValue("gc", mv);
|
|
155
|
-
|
|
156
|
-
return p;
|
|
157
|
-
} catch (e) {
|
|
158
|
-
// p.putValue("error", e.toString());
|
|
159
|
-
console.log(`e: ${e}`)
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
117
|
GCAction.prototype.getGCTypeName = function (kind) {
|
|
165
118
|
const major = NodeUtil.getNodeMajorVersion();
|
|
166
119
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var CounterTask = require('./counter-task'),
|
|
8
|
+
ResourceProfile = require('../../util/resourceprofile');
|
|
9
|
+
|
|
10
|
+
function GcStat() {
|
|
11
|
+
CounterTask.call(this);
|
|
12
|
+
|
|
13
|
+
this.old = [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
GcStat.prototype = new CounterTask();
|
|
17
|
+
GcStat.prototype.constructor = GcStat;
|
|
18
|
+
GcStat.prototype.process = function (p) {
|
|
19
|
+
var info = ResourceProfile.getCurrentProcGcInfo();
|
|
20
|
+
if(this.old.length == 0) {
|
|
21
|
+
p.gc_count = info[0];
|
|
22
|
+
p.gc_time = info[1];
|
|
23
|
+
} else {
|
|
24
|
+
var tmp_count = info[0] - this.old[0];
|
|
25
|
+
var tmp_time = info[1] - this.old[1];
|
|
26
|
+
p.gc_count = tmp_count;
|
|
27
|
+
p.gc_time = tmp_time;
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
this.old = info;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = GcStat;
|
|
34
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var CounterTask = require('./counter-task'),
|
|
8
|
+
ResourceProfile = require('./../../util/resourceprofile');
|
|
9
|
+
|
|
10
|
+
function HeapMem() {
|
|
11
|
+
CounterTask.call(this);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
HeapMem.prototype = new CounterTask();
|
|
15
|
+
HeapMem.prototype.constructor = HeapMem;
|
|
16
|
+
HeapMem.prototype.process = function (p) {
|
|
17
|
+
let m = undefined;
|
|
18
|
+
if(p.version <= 1) m =ResourceProfile.getMemory();
|
|
19
|
+
else m =ResourceProfile.getMemoryV2();
|
|
20
|
+
|
|
21
|
+
p.heap_tot = m.heap_total;
|
|
22
|
+
p.heap_use = m.heap_used;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
module.exports = HeapMem;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var CounterTask = require('./counter-task'),
|
|
8
|
+
IntKeyLinkedMap = require('../../util/intkey-linkedmap'),
|
|
9
|
+
MeterActiveX = require('../meter/meter-activex'),
|
|
10
|
+
conf = require('../../conf/configure'),
|
|
11
|
+
MeterHttpC = require('../meter/meter-httpc');
|
|
12
|
+
|
|
13
|
+
function HttpC() {
|
|
14
|
+
CounterTask.call(this);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
HttpC.prototype = new CounterTask();
|
|
18
|
+
HttpC.prototype.constructor = HttpC;
|
|
19
|
+
HttpC.prototype.process = function (p) {
|
|
20
|
+
var httpc = MeterHttpC.getBucketReset();
|
|
21
|
+
p.httpc_time = httpc.time;
|
|
22
|
+
p.httpc_count = httpc.count;
|
|
23
|
+
p.httpc_error = httpc.error;
|
|
24
|
+
|
|
25
|
+
if (conf.httpc_host_meter_enabled) {
|
|
26
|
+
httpc_host_meter(p);
|
|
27
|
+
}
|
|
28
|
+
if (conf.actx_meter_enabled) {
|
|
29
|
+
httpc_actx_meter(p);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function httpc_host_meter(p) {
|
|
34
|
+
var meter = MeterHttpC;
|
|
35
|
+
if (meter.stat.size() > 0) {
|
|
36
|
+
p.httpc_meter = new IntKeyLinkedMap();
|
|
37
|
+
var en = meter.stat.keys();
|
|
38
|
+
for (var i = 0; i < 100 && en.hasMoreElements(); i++) {
|
|
39
|
+
var key = en.nextElement();
|
|
40
|
+
var b = meter.stat.get(key);
|
|
41
|
+
p.httpc_meter.put(key, {
|
|
42
|
+
time: b.time,
|
|
43
|
+
count: b.count,
|
|
44
|
+
error: b.error,
|
|
45
|
+
actx : 0
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
meter.resetStat();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function httpc_actx_meter(p) {
|
|
53
|
+
var meter = MeterActiveX;
|
|
54
|
+
if (meter.stat_httpc.size() > 0) {
|
|
55
|
+
if (p.httpc_meter == null) {
|
|
56
|
+
p.httpc_meter = new IntKeyLinkedMap();
|
|
57
|
+
}
|
|
58
|
+
var en = meter.stat_httpc.keys();
|
|
59
|
+
for (var i = 0; i < 100 && en.hasMoreElements(); i++) {
|
|
60
|
+
var key = en.nextElement();
|
|
61
|
+
var b = meter.stat_httpc.get(key);
|
|
62
|
+
var org = p.httpc_meter.get(key);
|
|
63
|
+
if (org) {
|
|
64
|
+
org.actx = b;
|
|
65
|
+
} else {
|
|
66
|
+
p.httpc_meter.put(key, {
|
|
67
|
+
time: 0,
|
|
68
|
+
count: 0,
|
|
69
|
+
error: 0,
|
|
70
|
+
actx: b
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
module.exports = HttpC;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var CounterTask = require('./counter-task'),
|
|
8
|
+
DataPackSender = require('../../data/datapack-sender'),
|
|
9
|
+
conf = require('../../conf/configure'),
|
|
10
|
+
DateUtil = require('../../util/dateutil'),
|
|
11
|
+
Logger = require('../../logger'),
|
|
12
|
+
fs = require('fs'),
|
|
13
|
+
TagCountPack = require('../../pack/tagcount-pack'),
|
|
14
|
+
OType = require('../../pack/otype'),
|
|
15
|
+
APEnum = require('../../pack/apenum'),
|
|
16
|
+
Util = require('../../util/index');
|
|
17
|
+
|
|
18
|
+
function MeteringInfo() {
|
|
19
|
+
CounterTask.call(this);
|
|
20
|
+
this.first_connected = true;
|
|
21
|
+
this.lastTime = DateUtil.getFiveMinUnit(DateUtil.currentTime());
|
|
22
|
+
this.hostUUID = null;
|
|
23
|
+
this.csp = null;
|
|
24
|
+
this.hostUUIDFileName = '/sys/class/dmi/id/product_uuid';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
MeteringInfo.prototype = new CounterTask();
|
|
28
|
+
MeteringInfo.prototype.constructor = MeteringInfo;
|
|
29
|
+
|
|
30
|
+
MeteringInfo.prototype.process = function (p) {
|
|
31
|
+
if (!conf.getProperty('metering_tagcount_enabled', false)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (this.first_connected) {
|
|
36
|
+
this.first_connected = false;
|
|
37
|
+
this.doProcess(p);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const now = DateUtil.getFiveMinUnit(DateUtil.currentTime());
|
|
42
|
+
if (this.lastTime >= now) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.lastTime = now;
|
|
47
|
+
this.doProcess(p);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
MeteringInfo.prototype.doProcess = function (p) {
|
|
51
|
+
const host_uuid = this.getHostUUID(this.hostUUIDFileName);
|
|
52
|
+
if(!host_uuid)
|
|
53
|
+
return;
|
|
54
|
+
|
|
55
|
+
const pk = new TagCountPack();
|
|
56
|
+
pk.category = 'metering';
|
|
57
|
+
pk.time = DateUtil.currentTime() / 300000 * 300000;
|
|
58
|
+
|
|
59
|
+
pk.putTagInt('otype', OType.AP);
|
|
60
|
+
pk.putTagInt('subtype', APEnum.AP_NODE);
|
|
61
|
+
pk.putTagInt('ip', p.host_ip);
|
|
62
|
+
pk.putTagString('host_uuid', host_uuid);
|
|
63
|
+
pk.putTagString('_no_5m_hour_', "");
|
|
64
|
+
|
|
65
|
+
const csp = this.getCsp();
|
|
66
|
+
if (csp) {
|
|
67
|
+
pk.putTagString('csp', csp)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
pk.putTagFloat('mcore', p.metering)
|
|
71
|
+
|
|
72
|
+
DataPackSender.sendTagCounterPack(pk);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
MeteringInfo.prototype.hasHostUUID = function (fileName) {
|
|
76
|
+
try{
|
|
77
|
+
return fs.existsSync(fileName);
|
|
78
|
+
}catch (e) {
|
|
79
|
+
Logger.printError("WHATAP-081", "hasHostUUID error", e, false);
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
MeteringInfo.prototype.getHostUUID = function (fileName) {
|
|
85
|
+
const hostUUID = this.getHostUUIDValue();
|
|
86
|
+
if (hostUUID) {
|
|
87
|
+
return hostUUID;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const hasHostUUIDFile = this.hasHostUUID(fileName);
|
|
91
|
+
if (hasHostUUIDFile) {
|
|
92
|
+
try {
|
|
93
|
+
const data = fs.readFileSync(fileName, 'utf8').trim();
|
|
94
|
+
if (data && data.length > 0) {
|
|
95
|
+
this.hostUUID = data;
|
|
96
|
+
return this.hostUUID;
|
|
97
|
+
} else {
|
|
98
|
+
Logger.print('WHATAP-082', `cannot read ${fileName}`, false);
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
Logger.printError('WHATAP-083', `error reading ${fileName}`, error, false);
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
Logger.print('WHATAP-084', `cannot find ${fileName}`, false);
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
MeteringInfo.prototype.getHostUUIDValue = function () {
|
|
110
|
+
return this.hostUUID;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
MeteringInfo.prototype.getCsp = function () {
|
|
114
|
+
if(process.env["ECS_CONTAINER_METADATA_URI"]) {
|
|
115
|
+
this.csp = "aws";
|
|
116
|
+
return this.csp;
|
|
117
|
+
}
|
|
118
|
+
if(Util.cloudPlatformCheck()) {
|
|
119
|
+
this.csp = "kic";
|
|
120
|
+
return this.csp;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
module.exports = MeteringInfo;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var CounterTask = require('./counter-task'),
|
|
8
|
+
ResourceProfile = require('./../../util/resourceprofile'),
|
|
9
|
+
Long = require('long');
|
|
10
|
+
|
|
11
|
+
function ProcCpu() {
|
|
12
|
+
CounterTask.call(this);
|
|
13
|
+
this.oldCpu = 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
ProcCpu.prototype = new CounterTask();
|
|
17
|
+
ProcCpu.prototype.constructor = ProcCpu;
|
|
18
|
+
ProcCpu.prototype.process = function (p) {
|
|
19
|
+
var cpu = ResourceProfile.getCPU().times; /*long*/
|
|
20
|
+
if(this.oldCpu<=0) {
|
|
21
|
+
this.oldCpu = cpu;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
var dTime = cpu - this.oldCpu;
|
|
25
|
+
this.oldCpu = cpu;
|
|
26
|
+
p.cputime = dTime;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
module.exports = ProcCpu;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var CounterTask = require('./counter-task'),
|
|
8
|
+
MeterUser = require('../meter/meter-users'),
|
|
9
|
+
RealTimeUserPack= require('../../pack/realtimeuser-pack'),
|
|
10
|
+
DataPackSender = require('../../data/datapack-sender'),
|
|
11
|
+
Long = require('long');
|
|
12
|
+
|
|
13
|
+
function RealTimeUser() {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
RealTimeUser.prototype = new CounterTask();
|
|
17
|
+
RealTimeUser.prototype.constructor = RealTimeUser;
|
|
18
|
+
RealTimeUser.prototype.process = function (p) {
|
|
19
|
+
var hll = MeterUser.getRealtimeUsers();
|
|
20
|
+
if(hll == null) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var pk = new RealTimeUserPack();
|
|
25
|
+
pk.time = p.time;
|
|
26
|
+
pk.cadinality=hll.cardinality();
|
|
27
|
+
pk.logbits = hll.getBytes();
|
|
28
|
+
DataPackSender.sendRealtimeUserPack(pk);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
module.exports = RealTimeUser;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var CounterTask = require('../counter-task'),
|
|
8
|
+
conf = require('../../../conf/configure'),
|
|
9
|
+
SecurityMaster = require('../../../net/security-master'),
|
|
10
|
+
AwsEcsClientThread = require('./util/awsEcsClientThread');
|
|
11
|
+
|
|
12
|
+
function SystemECSTask() {
|
|
13
|
+
CounterTask.call(this);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
SystemECSTask.prototype = new CounterTask();
|
|
17
|
+
SystemECSTask.prototype.constructor = SystemECSTask;
|
|
18
|
+
SystemECSTask.prototype.process = function (p) {
|
|
19
|
+
p.host_ip = SecurityMaster.IP;
|
|
20
|
+
|
|
21
|
+
var ecs = AwsEcsClientThread;
|
|
22
|
+
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
p.cpu = ecs.cpu * conf.correction_factor_cpu;
|
|
25
|
+
p.cpu_sys = ecs.cpu_sys;
|
|
26
|
+
p.cpu_usr = ecs.cpu_user;
|
|
27
|
+
p.mem = ecs.mem_pct;
|
|
28
|
+
|
|
29
|
+
if (ecs.millicore > 0) {
|
|
30
|
+
p.metering = ecs.millicore / 1024;
|
|
31
|
+
p.cpu_cores = Math.ceil(p.metering);
|
|
32
|
+
} else {
|
|
33
|
+
p.metering = p.cpu_cores;
|
|
34
|
+
}
|
|
35
|
+
}, 500);
|
|
36
|
+
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
module.exports = SystemECSTask;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
3
|
+
* Use of this source code is governed by a license that
|
|
4
|
+
* can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
var CounterTask = require('../counter-task'),
|
|
8
|
+
StatSql = require('../../../stat/stat-sql'),
|
|
9
|
+
conf = require('../../../conf/configure'),
|
|
10
|
+
ConfSysMon = require('../../../conf/conf-sys-mon'),
|
|
11
|
+
SecurityMaster = require('../../../net/security-master'),
|
|
12
|
+
TraceContextManager = require('../../../trace/trace-context-manager'),
|
|
13
|
+
MeterActiveX = require('../../meter/meter-activex'),
|
|
14
|
+
ActiveStackPack = require('../../../pack/activestack-pack'),
|
|
15
|
+
ParamPack = require('../../../pack/param-pack'),
|
|
16
|
+
EventPack = require('../../../pack/event-pack'),
|
|
17
|
+
ActiveStackStep = require('../../../step/activestack-step'),
|
|
18
|
+
DataPackSender = require('../../../data/datapack-sender'),
|
|
19
|
+
DataTextAgent = require('../../../data/datatext-agent'),
|
|
20
|
+
EventLevel = require('../../../data/event-level'),
|
|
21
|
+
MeterUsers = require('../../meter/meter-users'),
|
|
22
|
+
KeyGen = require('../../../util/keygen'),
|
|
23
|
+
TextTypes = require('../../../lang/text-types'),
|
|
24
|
+
ResourceProfile = require('../../../util/resourceprofile'),
|
|
25
|
+
Logger = require('../../../logger'),
|
|
26
|
+
HashUtil = require('../../../util/hashutil'),
|
|
27
|
+
KubeUtil = require('../../../util/kube-util'),
|
|
28
|
+
KubeClient = require('../../../kube/kube-client'),
|
|
29
|
+
DateUtil = require('../../../util/dateutil'),
|
|
30
|
+
Long = require('long');
|
|
31
|
+
|
|
32
|
+
function SystemKubeTask() {
|
|
33
|
+
CounterTask.call(this);
|
|
34
|
+
|
|
35
|
+
this.last_metering = -1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
SystemKubeTask.prototype = new CounterTask();
|
|
39
|
+
SystemKubeTask.prototype.constructor = SystemKubeTask;
|
|
40
|
+
SystemKubeTask.prototype.process = function (p) {
|
|
41
|
+
p.cpu_cores = 1; // static one core in nodejs
|
|
42
|
+
p.host_ip = SecurityMaster.IP;
|
|
43
|
+
var now = Date.now();
|
|
44
|
+
p.cpu = 0;
|
|
45
|
+
p.mem = 0;
|
|
46
|
+
if (p.metering != 0) {
|
|
47
|
+
this.last_metering = p.metering;
|
|
48
|
+
} else {
|
|
49
|
+
p.metering = this.last_metering;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
module.exports = SystemKubeTask;
|