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
|
@@ -0,0 +1,51 @@
|
|
|
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 Long = require('long');
|
|
8
|
+
|
|
9
|
+
function MeterSocketio() {
|
|
10
|
+
|
|
11
|
+
if(typeof MeterSocketio.instance === 'object') {
|
|
12
|
+
return MeterSocketio.instance;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
this.total_connected = 0;
|
|
16
|
+
this.connected_count = 0;
|
|
17
|
+
this.received_count =0;
|
|
18
|
+
this.received_data =0;
|
|
19
|
+
this.sent_count =0;
|
|
20
|
+
this.sent_data =0;
|
|
21
|
+
|
|
22
|
+
MeterSocketio.instance = this;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
MeterSocketio.prototype.connected = function (count) {
|
|
26
|
+
this.total_connected += count;
|
|
27
|
+
this.connected_count += count;
|
|
28
|
+
};
|
|
29
|
+
MeterSocketio.prototype.disconnected = function () {
|
|
30
|
+
this.connected_count--;
|
|
31
|
+
};
|
|
32
|
+
MeterSocketio.prototype.receive = function (connectid, data) {
|
|
33
|
+
if(typeof data === 'string') {
|
|
34
|
+
this.received_data += data.length;
|
|
35
|
+
this.received_count ++;
|
|
36
|
+
} else if(typeof data === 'object') {
|
|
37
|
+
this.received_data += JSON.stringify(data).length;
|
|
38
|
+
this.received_count ++;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
MeterSocketio.prototype.send = function (connectid, data) {
|
|
42
|
+
if(typeof data === 'string') {
|
|
43
|
+
this.sent_data += data.length;
|
|
44
|
+
this.sent_count ++;
|
|
45
|
+
} else if(typeof data === 'object') {
|
|
46
|
+
this.sent_data += JSON.stringify(data).length;
|
|
47
|
+
this.sent_count ++;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
module.exports = new MeterSocketio();
|
|
@@ -0,0 +1,71 @@
|
|
|
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 conf = require('../../conf/configure'),
|
|
8
|
+
IntIntMap = require('../../util/intint-map'),
|
|
9
|
+
Long = require('long');
|
|
10
|
+
var IntKeyLinkedMap = require('../../util/intkey-linkedmap');
|
|
11
|
+
|
|
12
|
+
function Bucket() {
|
|
13
|
+
this.count = 0;
|
|
14
|
+
this.time = 0;
|
|
15
|
+
this.error = 0;
|
|
16
|
+
|
|
17
|
+
this.fetch_count = 0;
|
|
18
|
+
this.fetch_time = 0;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
this.db_conn_active = new IntIntMap(7, 1);
|
|
22
|
+
this.db_conn_idle = new IntIntMap(7, 1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function MeterSql() {
|
|
26
|
+
this.bucket = new Bucket();
|
|
27
|
+
this.stat = new IntKeyLinkedMap(500, 1).setMax(500);
|
|
28
|
+
this.stat.create = function (key) {
|
|
29
|
+
return new Bucket();
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
MeterSql.prototype.add = function (dbc, elapsed, err) {
|
|
34
|
+
|
|
35
|
+
var b = this.bucket;
|
|
36
|
+
b.count++;
|
|
37
|
+
b.time +=elapsed;
|
|
38
|
+
if(err) {
|
|
39
|
+
b.error++;
|
|
40
|
+
}
|
|
41
|
+
if(conf.sql_dbc_meter_enabled && dbc!=0) {
|
|
42
|
+
b = this.stat.intern(dbc);
|
|
43
|
+
b.count++;
|
|
44
|
+
|
|
45
|
+
b.time += elapsed;
|
|
46
|
+
if (err) {
|
|
47
|
+
b.error++;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
MeterSql.prototype.getBucketReset = function () {
|
|
52
|
+
var b = this.bucket;
|
|
53
|
+
this.bucket = new Bucket();
|
|
54
|
+
return b;
|
|
55
|
+
};
|
|
56
|
+
MeterSql.prototype.resetStat = function () {
|
|
57
|
+
if(this.stat.size() > 0){
|
|
58
|
+
this.stat.clear();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
MeterSql.prototype.addFetch = function (dbc, count, time) {
|
|
62
|
+
this.bucket.fetch_count += count;
|
|
63
|
+
this.bucket.fetch_time += time;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
MeterSql.prototype.setConnection = function (active, idle, hash) {
|
|
67
|
+
this.bucket.db_conn_active.put(hash, active);
|
|
68
|
+
this.bucket.db_conn_idle.put(hash, idle);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports = new MeterSql();
|
|
@@ -0,0 +1,58 @@
|
|
|
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 conf = require('../../conf/configure'),
|
|
8
|
+
LongKeyLinkedMap = require('../../util/longkey-linkedmap'),
|
|
9
|
+
HyperLogLog = require('../../util/cardinality/hyperloglog'),
|
|
10
|
+
Long = require('long');
|
|
11
|
+
|
|
12
|
+
var add = function (userid) {
|
|
13
|
+
if(conf.trace_user_enabled == false) { return; }
|
|
14
|
+
|
|
15
|
+
if(userid instanceof Long && userid.isZero() == false) {
|
|
16
|
+
meterUser.users.putLast(userid, Date.now());
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var addActive = function (userid) {
|
|
21
|
+
if(conf.trace_user_enabled == false) { return; }
|
|
22
|
+
|
|
23
|
+
if(userid instanceof Long && userid.isZero() == false) {
|
|
24
|
+
meterUser.users.put(userid, Date.now());
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var getRealtimeUsers = function () {
|
|
29
|
+
var max_think_time = conf.realtime_user_thinktime_max;
|
|
30
|
+
var now = Date.now();
|
|
31
|
+
|
|
32
|
+
var loglog = new HyperLogLog();
|
|
33
|
+
if(meterUser.users.size() == 0) {
|
|
34
|
+
return loglog;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var en = meterUser.users.entries();
|
|
38
|
+
while(en.hasMoreElements()) {
|
|
39
|
+
var e = en.nextElement();
|
|
40
|
+
if(now - e.getValue() > max_think_time) {
|
|
41
|
+
meterUser.users.remove(e.getKey());
|
|
42
|
+
} else {
|
|
43
|
+
loglog.offer(e.getKey());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return loglog;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var meterUser = {
|
|
51
|
+
MAX_USERS : 70000,
|
|
52
|
+
users : new LongKeyLinkedMap().setMax(70000),
|
|
53
|
+
add : add,
|
|
54
|
+
addActive : addActive,
|
|
55
|
+
getRealtimeUsers : getRealtimeUsers
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = meterUser;
|
|
@@ -0,0 +1,183 @@
|
|
|
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
|
+
function Meter() {
|
|
8
|
+
this.BUCKET_SIZE = 301;
|
|
9
|
+
this.initTime = Math.round(Date.now() / 1000);
|
|
10
|
+
this.lastTime = this.initTime;
|
|
11
|
+
this.lastOffset = this.initTime % this.BUCKET_SIZE;
|
|
12
|
+
// this.clear = function() {};
|
|
13
|
+
};
|
|
14
|
+
Meter.prototype.getPosition = function() {
|
|
15
|
+
var currentTime = Math.round(Date.now() / 1000);
|
|
16
|
+
if (currentTime != this.lastTime) {
|
|
17
|
+
for (i = 0; i < (currentTime - this.lastTime) && i < this.BUCKET_SIZE; i++) {
|
|
18
|
+
this.lastOffset = (this.lastOffset + 1 >= this.BUCKET_SIZE) ? 0
|
|
19
|
+
: this.lastOffset + 1;
|
|
20
|
+
this.clear(this.lastOffset);
|
|
21
|
+
}
|
|
22
|
+
this.lastTime = currentTime;
|
|
23
|
+
this.lastOffset = this.lastTime % this.BUCKET_SIZE;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return this.lastOffset;
|
|
27
|
+
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Meter.prototype.check = function(period) {
|
|
31
|
+
if (period >= this.BUCKET_SIZE)
|
|
32
|
+
period = this.BUCKET_SIZE - 1;
|
|
33
|
+
return period;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
Meter.prototype.getTime = function() {
|
|
37
|
+
return new Date().getTme() / 1000;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
Meter.prototype.desc = function(pos) {
|
|
41
|
+
if (pos === 0)
|
|
42
|
+
pos = this.BUCKET_SIZE - 1;
|
|
43
|
+
else
|
|
44
|
+
pos--;
|
|
45
|
+
return pos;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function MeterService() {
|
|
49
|
+
if (typeof MeterService.instance === "object") {
|
|
50
|
+
return MeterService.instance;
|
|
51
|
+
}
|
|
52
|
+
this.txCount = new Array(this.BUCKET_SIZE);
|
|
53
|
+
this.errCount = new Array(this.BUCKET_SIZE);
|
|
54
|
+
this.txDuration = new Array(this.BUCKET_SIZE);
|
|
55
|
+
|
|
56
|
+
for ( var i = 0; i < this.BUCKET_SIZE; i++) {
|
|
57
|
+
this.txCount[i] = 0;
|
|
58
|
+
this.errCount[i] = 0;
|
|
59
|
+
this.txDuration[i] = 0;
|
|
60
|
+
}
|
|
61
|
+
MeterService.instance = this;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
MeterService.prototype = new Meter();
|
|
65
|
+
|
|
66
|
+
MeterService.prototype.clear = function(offset) {
|
|
67
|
+
this.txCount[offset] = 0;
|
|
68
|
+
this.errCount[offset] = 0;
|
|
69
|
+
this.txDuration[offset] = 0;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
MeterService.prototype.add = function(elapsed, err) {
|
|
73
|
+
|
|
74
|
+
var pos = this.getPosition();
|
|
75
|
+
this.txCount[pos]++;
|
|
76
|
+
this.txDuration[pos] += elapsed;
|
|
77
|
+
if (err)
|
|
78
|
+
this.errCount[pos]++;
|
|
79
|
+
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
MeterService.prototype.getTPS = function(period) {
|
|
83
|
+
period = this.check(period);
|
|
84
|
+
var pos = this.getPosition();
|
|
85
|
+
|
|
86
|
+
var sum = 0;
|
|
87
|
+
for ( var i = 0; i < period; i++, pos = this.desc(pos)) {
|
|
88
|
+
sum += this.txCount[pos];
|
|
89
|
+
}
|
|
90
|
+
return (sum / period);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
MeterService.prototype.getElapsedTime = function(period) {
|
|
94
|
+
period = this.check(period);
|
|
95
|
+
var pos = this.getPosition();
|
|
96
|
+
|
|
97
|
+
var sum = 0;
|
|
98
|
+
var cnt = 0;
|
|
99
|
+
for ( var i = 0; i < period; i++, pos = this.desc(pos)) {
|
|
100
|
+
sum += this.txDuration[pos];
|
|
101
|
+
cnt += this.txCount[pos];
|
|
102
|
+
}
|
|
103
|
+
return ((cnt === 0) ? 0 : sum / cnt);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
MeterService.prototype.getError = function(period) {
|
|
107
|
+
period = this.check(period);
|
|
108
|
+
var pos = this.getPosition();
|
|
109
|
+
|
|
110
|
+
var cnt = 0;
|
|
111
|
+
var err = 0;
|
|
112
|
+
for ( var i = 0; i < period; i++, pos = this.desc(pos)) {
|
|
113
|
+
cnt += this.txCount[pos];
|
|
114
|
+
err += this.errCount[pos];
|
|
115
|
+
}
|
|
116
|
+
return ((cnt === 0) ? 0 : ((err / cnt) * 100.0));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
MeterService.prototype.getServiceCount = function(period) {
|
|
120
|
+
period = this.check(period);
|
|
121
|
+
var pos = this.getPosition();
|
|
122
|
+
|
|
123
|
+
var sum = 0;
|
|
124
|
+
for ( var i = 0; i < period; i++, pos = this.desc(pos)) {
|
|
125
|
+
sum += this.txCount[pos];
|
|
126
|
+
}
|
|
127
|
+
return sum;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
MeterService.prototype.getServiceError = function(period) {
|
|
131
|
+
period = this.check(period);
|
|
132
|
+
var pos = this.getPosition();
|
|
133
|
+
|
|
134
|
+
var sum = 0;
|
|
135
|
+
for ( var i = 0; i < period; i++, pos = this.desc(pos)) {
|
|
136
|
+
sum += this.errCount[pos];
|
|
137
|
+
}
|
|
138
|
+
return sum;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
function MeterResource() {
|
|
142
|
+
this.value = new Array(this.BUCKET_SIZE);
|
|
143
|
+
this.count = new Array(this.BUCKET_SIZE);
|
|
144
|
+
|
|
145
|
+
for ( var i = 0; i < this.BUCKET_SIZE; i++) {
|
|
146
|
+
this.value[i] = 0;
|
|
147
|
+
this.count[i] = 0;
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
};
|
|
152
|
+
MeterResource.prototype = new Meter();
|
|
153
|
+
|
|
154
|
+
MeterResource.prototype.clear = function(offset) {
|
|
155
|
+
this.value[offset] = 0;
|
|
156
|
+
this.count[offset] = 0;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
MeterResource.prototype.add = function(value) {
|
|
160
|
+
var pos = this.getPosition();
|
|
161
|
+
this.value[pos] += value;
|
|
162
|
+
this.count[pos]++;
|
|
163
|
+
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
MeterResource.prototype.getAvg = function(period) {
|
|
167
|
+
var period = this.check(period);
|
|
168
|
+
var pos = this.getPosition();
|
|
169
|
+
var count = 0;
|
|
170
|
+
var sum = 0;
|
|
171
|
+
|
|
172
|
+
for ( var i = 0; i < period; i++, pos = this.desc(pos)) {
|
|
173
|
+
sum += this.value[pos];
|
|
174
|
+
count += this.count[pos];
|
|
175
|
+
}
|
|
176
|
+
if (count === 0) {
|
|
177
|
+
return 0;
|
|
178
|
+
}
|
|
179
|
+
return sum / count;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
module.exports.MeterService = MeterService;
|
|
183
|
+
module.exports.MeterResource = MeterResource;
|
|
@@ -4,40 +4,91 @@
|
|
|
4
4
|
* can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var CounterTask = require('./counter-task'),
|
|
8
|
+
StatSql = require('../../stat/stat-sql'),
|
|
9
|
+
conf = require('../../conf/configure'),
|
|
8
10
|
TraceContextManager = require('../../trace/trace-context-manager'),
|
|
11
|
+
MeterActiveX = require('../meter/meter-activex'),
|
|
12
|
+
ActiveStackPack = require('../../pack/activestack-pack'),
|
|
13
|
+
ActiveStackStep = require('../../step/activestack-step'),
|
|
14
|
+
DataPackSender = require('../../data/datapack-sender'),
|
|
15
|
+
DataTextAgent = require('../../data/datatext-agent'),
|
|
16
|
+
MeterUsers = require('../meter/meter-users'),
|
|
9
17
|
KeyGen = require('../../util/keygen'),
|
|
10
18
|
HashUtil = require('../../util/hashutil'),
|
|
19
|
+
ResourceProfile = require('../../util/resourceprofile'),
|
|
11
20
|
Logger = require('../../logger'),
|
|
12
21
|
Long = require('long');
|
|
13
22
|
|
|
14
|
-
function ActiveTransaction() {
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
function ActiveTransaction() {
|
|
24
|
+
CounterTask.call(this);
|
|
25
|
+
this.last_stack_sec = 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ActiveTransaction.prototype = new CounterTask();
|
|
29
|
+
ActiveTransaction.prototype.constructor = ActiveTransaction;
|
|
30
|
+
ActiveTransaction.prototype.process = function (p) {
|
|
31
|
+
|
|
32
|
+
p.active_tx_slice = [0, 0, 0];
|
|
33
|
+
p.active_stat = new Array(5).fill(0);
|
|
34
|
+
|
|
35
|
+
var activeX = null;
|
|
36
|
+
if (conf.actx_meter_enabled) {
|
|
37
|
+
activeX = MeterActiveX;
|
|
38
|
+
activeX.reinit();
|
|
39
|
+
}
|
|
40
|
+
|
|
17
41
|
var en = TraceContextManager.getContextEnumeration();
|
|
18
42
|
try {
|
|
19
43
|
while (en.hasMoreElements()) {
|
|
20
44
|
var ctx = en.nextElement();
|
|
21
|
-
if (
|
|
22
|
-
|
|
45
|
+
if (ctx == null) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
var elapsed = ctx.getElapsedTime();
|
|
49
|
+
if (elapsed < conf.trace_active_transaction_yellow_time) {
|
|
50
|
+
p.active_tx_slice[0]++;
|
|
51
|
+
} else if (elapsed < conf.trace_active_transaction_red_time) {
|
|
52
|
+
p.active_tx_slice[1]++;
|
|
53
|
+
} else {
|
|
54
|
+
p.active_tx_slice[2]++;
|
|
55
|
+
if (elapsed >= conf.trace_active_transaction_hang_time) {
|
|
56
|
+
p.act_svc_hang++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
p.active_tx_count++;
|
|
60
|
+
if (activeX) {
|
|
61
|
+
activeX.addTx(ctx.mcaller_pcode, ctx.mcaller_okind, ctx.mcaller_oid);
|
|
62
|
+
var httpc = ctx.active_httpc_hash;
|
|
63
|
+
if (httpc != 0) {
|
|
64
|
+
activeX.addHttpc(httpc);
|
|
65
|
+
} else {
|
|
66
|
+
var dbc = ctx.active_dbc;
|
|
67
|
+
if (dbc != 0) {
|
|
68
|
+
activeX.addSql(dbc);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
23
71
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
if (ctx.active_sqlhash != 0) {
|
|
75
|
+
p.active_stat[1]++; // sql
|
|
76
|
+
} else if (ctx.active_httpc_hash != 0) {
|
|
77
|
+
p.active_stat[2]++; // httpc
|
|
28
78
|
} else if (ctx.db_opening) {
|
|
29
|
-
|
|
79
|
+
p.active_stat[3]++; // dbc
|
|
30
80
|
} else if (ctx.socket_connecting) {
|
|
31
|
-
|
|
81
|
+
p.active_stat[4]++; // socket
|
|
32
82
|
} else {
|
|
33
|
-
|
|
83
|
+
p.active_stat[0]++; // method
|
|
34
84
|
}
|
|
85
|
+
|
|
86
|
+
MeterUsers.addActive(ctx.userid);
|
|
35
87
|
}
|
|
36
|
-
return stats;
|
|
37
88
|
} catch (e) {
|
|
38
|
-
Logger.printError("WHATAP-
|
|
39
|
-
return stats;
|
|
89
|
+
Logger.printError("WHATAP-071", 'Active Transaction(process)', e)
|
|
40
90
|
}
|
|
91
|
+
|
|
41
92
|
};
|
|
42
93
|
|
|
43
|
-
module.exports =
|
|
94
|
+
module.exports = ActiveTransaction;
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
SecurityMaster = require('../../net/security-master'),
|
|
11
|
+
TraceContextManager = require('../../trace/trace-context-manager'),
|
|
12
|
+
MeterActiveX = require('../meter/meter-activex'),
|
|
13
|
+
ActiveStackPack = require('../../pack/activestack-pack'),
|
|
14
|
+
ParamPack = require('../../pack/param-pack'),
|
|
15
|
+
EventPack = require('../../pack/event-pack'),
|
|
16
|
+
ActiveStackStep = require('../../step/activestack-step'),
|
|
17
|
+
DataPackSender = require('../../data/datapack-sender'),
|
|
18
|
+
DataTextAgent = require('../../data/datatext-agent').agent,
|
|
19
|
+
EventLevel = require('../../data/event-level'),
|
|
20
|
+
MeterUsers = require('../meter/meter-users'),
|
|
21
|
+
KeyGen = require('../../util/keygen'),
|
|
22
|
+
TextTypes = require('../../lang/text-types'),
|
|
23
|
+
ResourceProfile = require('../../util/resourceprofile'),
|
|
24
|
+
Logger = require('../../logger'),
|
|
25
|
+
HashUtil = require('../../util/hashutil'),
|
|
26
|
+
KubeUtil = require('../../util/kube-util'),
|
|
27
|
+
DateUtil = require('../../util/dateutil'),
|
|
28
|
+
fs = require('fs'),
|
|
29
|
+
PiiMask = require('../../pii/pii-mask');
|
|
30
|
+
|
|
31
|
+
function AgentInfo() {
|
|
32
|
+
CounterTask.call(this);
|
|
33
|
+
|
|
34
|
+
this.startTime = Date.now();
|
|
35
|
+
this.last_name_sent = 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
AgentInfo.prototype = new CounterTask();
|
|
39
|
+
AgentInfo.prototype.constructor = AgentInfo;
|
|
40
|
+
AgentInfo.prototype.process = function (p) {
|
|
41
|
+
// PiiMask.update();
|
|
42
|
+
|
|
43
|
+
p.starttime = Date.now();
|
|
44
|
+
/*
|
|
45
|
+
if (p.starttime > this.startTime + DateUtil.MILLIS_PER_FIVE_MINUTE) {
|
|
46
|
+
this.startTime = now + DateUtil.MILLIS_PER_HOUR * 12;
|
|
47
|
+
|
|
48
|
+
DataPackSender.sendBoot(AgentInfo.info);
|
|
49
|
+
// ComponentsVersions.send();
|
|
50
|
+
}*/
|
|
51
|
+
|
|
52
|
+
this.sendName(p.starttime);
|
|
53
|
+
|
|
54
|
+
p.containerKey = KubeUtil.container_key;
|
|
55
|
+
|
|
56
|
+
this.checkAutoScaleIn();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
AgentInfo.prototype.sendName = function(now /* long */){
|
|
60
|
+
if (now - this.last_name_sent < DateUtil.MILLIS_PER_FIVE_MINUTE) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.last_name_sent = now;
|
|
64
|
+
|
|
65
|
+
var sm = SecurityMaster;
|
|
66
|
+
if (sm.ONAME != null) {
|
|
67
|
+
DataTextAgent.add(TextTypes.ONAME, sm.OID, sm.ONAME);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (sm.OKIND != 0) {
|
|
71
|
+
DataTextAgent.add(TextTypes.OKIND_NAME, sm.OKIND, sm.OKIND_NAME);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (sm.ONODE != 0) {
|
|
75
|
+
DataTextAgent.add(TextTypes.ONODE_NAME, sm.ONODE, sm.ONODE_NAME);
|
|
76
|
+
}
|
|
77
|
+
if (KubeUtil.container_key != 0) {
|
|
78
|
+
DataTextAgent.add(TextTypes.CONTAINER_ID, KubeUtil.container_key, KubeUtil.container_id);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (conf.simula_agent_count > 0) {
|
|
82
|
+
for (var i = 0; i < conf.simula_agent_count; i++) {
|
|
83
|
+
var oname = sm.ONAME + "#" + i;
|
|
84
|
+
var ohash = HashUtil.hashFromString(oname);
|
|
85
|
+
DataTextAgent.add(TextTypes.ONAME, ohash, oname);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if(conf.mtrace_spec != undefined && conf.mtrace_spec.length >0) {
|
|
90
|
+
DataTextAgent.add(TextTypes.MTRACE_SPEC, conf.mtrace_spec_hash, conf.mtrace_spec);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
AgentInfo.prototype.checkAutoScaleIn = function() {
|
|
95
|
+
var home = conf["whatap.home"];
|
|
96
|
+
var file = fs.existsSync(home, process.pid + ".shutdown");
|
|
97
|
+
if (file) {
|
|
98
|
+
var e = new EventPack();
|
|
99
|
+
e.title = "SILENT_SHUTDOWN";
|
|
100
|
+
e.level = EventLevel.INFO;
|
|
101
|
+
DataPackSender.sendPack(e);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = AgentInfo;
|
|
106
|
+
|
|
107
|
+
|