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,218 @@
|
|
|
1
|
+
var http = require('http');
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2016 the WHATAP project authors. All rights reserved.
|
|
4
|
+
* Use of this source code is governed by a license that
|
|
5
|
+
* can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var CounterTask = require('../../counter-task'),
|
|
9
|
+
conf = require('../../../../conf/configure'),
|
|
10
|
+
Logger = require('../../../../logger'),
|
|
11
|
+
DateUtil = require('../../../../util/dateutil');
|
|
12
|
+
|
|
13
|
+
function AwsEcsClientThread() {
|
|
14
|
+
if (typeof AwsEcsClientThread.instance === "object") {
|
|
15
|
+
return AwsEcsClientThread.instance;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
this.millicore = 0;
|
|
19
|
+
this.last_milli_check = 0;
|
|
20
|
+
this.check = AwsEcsClientThread.CHECK_MAX;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
this.cpu = 0;
|
|
24
|
+
this.cpu_sys = 0;
|
|
25
|
+
this.cpu_user = 0;
|
|
26
|
+
this.mem_pct = 0;
|
|
27
|
+
|
|
28
|
+
var self = this;
|
|
29
|
+
setTimeout(function () {
|
|
30
|
+
self.run();
|
|
31
|
+
}, 100);
|
|
32
|
+
AwsEcsClientThread.instance = this;
|
|
33
|
+
};
|
|
34
|
+
AwsEcsClientThread.prototype = new AwsEcsClientThread();
|
|
35
|
+
|
|
36
|
+
AwsEcsClientThread.prototype.run = function () {
|
|
37
|
+
var self = this;
|
|
38
|
+
try {
|
|
39
|
+
if (conf.aws_ecs_enabled) {
|
|
40
|
+
self.intervalIndex = setInterval(function () {
|
|
41
|
+
var meta_uri = process.env["ECS_CONTAINER_METADATA_URI"];
|
|
42
|
+
if (meta_uri != null) {
|
|
43
|
+
self.getCpuLimit(meta_uri);
|
|
44
|
+
self.process(meta_uri);
|
|
45
|
+
}
|
|
46
|
+
}, conf.getProperty('aws_ecs_stat_interval', 3000));
|
|
47
|
+
}
|
|
48
|
+
} catch (e) {
|
|
49
|
+
Logger.printError('WHATAP ECS-ERR ', 'run exception', e, true);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AwsEcsClientThread.prototype.stop = function () {
|
|
54
|
+
if (this.intervalIndex) {
|
|
55
|
+
clearInterval(this.intervalIndex);
|
|
56
|
+
this.intervalIndex = undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
AwsEcsClientThread.prototype.getCpuLimit = function (meta_uri) {
|
|
61
|
+
var self = this;
|
|
62
|
+
|
|
63
|
+
if (this.check < 0)
|
|
64
|
+
return;
|
|
65
|
+
var now = Date.now();
|
|
66
|
+
if (now - DateUtil.MILLIS_PER_HOUR * 8 < this.last_milli_check)
|
|
67
|
+
return;
|
|
68
|
+
|
|
69
|
+
// var json = JSON.parse('{"DockerId":"e9950915-abaa-467f-9898-3bd0d4e6d0aa","Name":"web-application","DockerName":"ecs-web-application-1","Image":"nginx:latest","ImageID":"sha256:123456789abcdef...","Labels":{"com.amazonaws.ecs.cluster":"default","com.amazonaws.ecs.task-arn":"arn:aws:ecs:us-east-1:123456789012:task/default/1234567890abcdef","com.amazonaws.ecs.task-definition-family":"web-application","com.amazonaws.ecs.task-definition-version":"1"},"DesiredStatus":"RUNNING","KnownStatus":"RUNNING","Limits":{"CPU":256,"Memory":512},"CreatedAt":"2024-01-01T00:00:00.000Z","StartedAt":"2024-01-01T00:00:01.000Z","Type":"NORMAL","Networks":[{"NetworkMode":"awsvpc","IPv4Addresses":["172.31.10.100"],"AttachmentIndex":0,"MACAddress":"0a:1b:2c:3d:4e:5f","IPv4SubnetCIDRBlock":"172.31.0.0/20","DomainNameServers":["169.254.169.253"],"DomainNameSearchList":["us-east-1.compute.internal"],"PrivateDNSName":"ip-172-31-10-100.us-east-1.compute.internal","SubnetGatewayIpv4Address":"172.31.0.1/20"}],"ContainerARN":"arn:aws:ecs:us-east-1:123456789012:container/1234567890abcdef","LogDriver":"awslogs","LogOptions":{"awslogs-group":"/ecs/web-application","awslogs-region":"us-east-1","awslogs-stream":"ecs/web-application/1234567890abcdef"}}');
|
|
70
|
+
// 2025-01-23 ECS fargate
|
|
71
|
+
// var json = JSON.parse('{"DockerId":"a663f01570b14228b0795db9c8d11e16-2785547837","Name":"test_container","DockerName":"test_container","Image":"whataphub/ecs_sample:v0.0.4","ImageID":"sha256:748b5cd202288478bbdbd4baf8fe17c8b660163c24c513db5ccbe7a1bdcae0e0","Labels":{"com.amazonaws.ecs.cluster":"arn:aws:ecs:ap-northeast-2:592247757306:cluster/ecs_sample","com.amazonaws.ecs.container-name":"test_container","com.amazonaws.ecs.task-arn":"arn:aws:ecs:ap-northeast-2:592247757306:task/ecs_sample/a663f01570b14228b0795db9c8d11e16","com.amazonaws.ecs.task-definition-family":"ecs_task_sample","com.amazonaws.ecs.task-definition-version":"4"},"DesiredStatus":"RUNNING","KnownStatus":"RUNNING","Limits":{"CPU":2},"CreatedAt":"2025-01-23T04:42:03.843875803Z","StartedAt":"2025-01-23T04:42:03.843875803Z","Type":"NORMAL","Networks":[{"NetworkMode":"awsvpc","IPv4Addresses":["172.31.63.147"]}]}');
|
|
72
|
+
// if (json && json["Limits"]) {
|
|
73
|
+
// this.millicore = json.Limits.CPU;
|
|
74
|
+
// if (this.millicore < 128) {
|
|
75
|
+
// this.millicore *= 1024;
|
|
76
|
+
// }
|
|
77
|
+
// Logger.print("SysCPU", " ECS CPU Limits : " + (this.millicore / 1024) + "core", false)
|
|
78
|
+
// }
|
|
79
|
+
|
|
80
|
+
read(meta_uri, function(json){
|
|
81
|
+
if (json && json["Limits"]) {
|
|
82
|
+
this.millicore = json.Limits.CPU;
|
|
83
|
+
if (this.millicore < 128) {
|
|
84
|
+
this.millicore *= 1024;
|
|
85
|
+
}
|
|
86
|
+
Logger.print("WHATAP-811", "ECS CPU Limits : " + (this.millicore / 1024) + "core", false)
|
|
87
|
+
}
|
|
88
|
+
}, function(){
|
|
89
|
+
self.millicore = 0;
|
|
90
|
+
if (--self.check >= 0) {
|
|
91
|
+
Logger.printError('WHATAP-819' , 'not receive limit cpu', e , true);
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
AwsEcsClientThread.prototype.process = function (meta_uri) {
|
|
97
|
+
var self = this;
|
|
98
|
+
|
|
99
|
+
fetch(meta_uri + '/stats', {timeout: 3000})
|
|
100
|
+
.then(response => response.text())
|
|
101
|
+
.then(stats => {
|
|
102
|
+
if (!stats || stats.length === 0) {
|
|
103
|
+
self.reset();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// let stats = '{"blkio_stats":{"io_merged_recursive":[],"io_queue_recursive":[],"io_service_bytes_recursive":[{"major":259,"minor":3,"op":"Read","value":0},{"major":259,"minor":3,"op":"Write","value":45514752},{"major":259,"minor":3,"op":"Sync","value":4268032},{"major":259,"minor":3,"op":"Async","value":41246720},{"major":259,"minor":3,"op":"Discard","value":0},{"major":259,"minor":3,"op":"Total","value":45514752}],"io_service_time_recursive":[],"io_serviced_recursive":[{"major":259,"minor":3,"op":"Read","value":0},{"major":259,"minor":3,"op":"Write","value":342},{"major":259,"minor":3,"op":"Sync","value":272},{"major":259,"minor":3,"op":"Async","value":70},{"major":259,"minor":3,"op":"Discard","value":0},{"major":259,"minor":3,"op":"Total","value":342}],"io_time_recursive":[],"io_wait_time_recursive":[],"sectors_recursive":[]},"cpu_stats":{"cpu_usage":{"percpu_usage":[5585610339,5944268076],"total_usage":15373171220,"usage_in_kernelmode":2150000000,"usage_in_usermode":7990000000},"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"id":"10b741d47dc649d5b321f83c7c14c950-441560335","memory_stats":{"limit":9223372036854772000,"max_usage":246165504,"stats":{"active_anon":0,"active_file":27439104,"cache":56365056,"dirty":0,"hierarchical_memory_limit":2147483648,"hierarchical_memsw_limit":9223372036854772000,"inactive_anon":98267136,"inactive_file":28925952,"mapped_file":0,"pgfault":303666,"pgmajfault":0,"pgpgin":199749,"pgpgout":161965,"rss":98402304,"rss_huge":0,"total_active_anon":0,"total_active_file":27439104,"total_cache":56365056,"total_dirty":0,"total_inactive_anon":98267136,"total_inactive_file":28925952,"total_mapped_file":0,"total_pgfault":303666,"total_pgmajfault":0,"total_pgpgin":199749,"total_pgpgout":161965,"total_rss":98402304,"total_rss_huge":0,"total_unevictable":0,"total_writeback":135168,"unevictable":0,"writeback":135168},"usage":168361984},"name":"simple-user-app","networks":{"eth1":{"rx_bytes":1604876131,"rx_dropped":0,"rx_errors":0,"rx_packets":1076062,"tx_bytes":6252490,"tx_dropped":0,"tx_errors":0,"tx_packets":74457}},"num_procs":0,"pids_stats":{},"precpu_stats":{"cpu_usage":{"percpu_usage":[5570558410,5925648831],"total_usage":15328276321,"usage_in_kernelmode":2140000000,"usage_in_usermode":7970000000},"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"preread":"2023-05-30T11:29:20.720196524Z","read":"2023-05-30T11:29:30.719936356Z","storage_stats":{}}';
|
|
108
|
+
// 2025-01-23 ECS fargate
|
|
109
|
+
// var stats = '{"read":"2025-01-23T04:42:03.844081622Z","preread":"0001-01-01T00:00:00Z","pids_stats":{},"blkio_stats":{"io_service_bytes_recursive":[],"io_serviced_recursive":[],"io_queue_recursive":[],"io_service_time_recursive":[],"io_wait_time_recursive":[],"io_merged_recursive":[],"io_time_recursive":[],"sectors_recursive":[]},"num_procs":0,"storage_stats":{},"cpu_stats":{"cpu_usage":{"total_usage":33451672,"percpu_usage":[22728826,10722846],"usage_in_kernelmode":10000000,"usage_in_usermode":20000000},"system_cpu_usage":397640000000,"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"precpu_stats":{"cpu_usage":{"total_usage":0,"usage_in_kernelmode":0,"usage_in_usermode":0},"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"memory_stats":{"usage":765952,"max_usage":5267456,"stats":{"active_anon":0,"active_file":0,"cache":0,"dirty":0,"hierarchical_memory_limit":4294967296,"hierarchical_memsw_limit":9223372036854771712,"inactive_anon":135168,"inactive_file":0,"mapped_file":0,"pgfault":2112,"pgmajfault":0,"pgpgin":1452,"pgpgout":1452,"rss":270336,"rss_huge":0,"total_active_anon":0,"total_active_file":0,"total_cache":0,"total_dirty":0,"total_inactive_anon":135168,"total_inactive_file":0,"total_mapped_file":0,"total_pgfault":2112,"total_pgmajfault":0,"total_pgpgin":1452,"total_pgpgout":1452,"total_rss":270336,"total_rss_huge":0,"total_unevictable":0,"total_writeback":0,"unevictable":0,"writeback":0},"limit":9223372036854771712},"name":"test_container","id":"a663f01570b14228b0795db9c8d11e16-2785547837","networks":{"eth1":{"rx_bytes":463375353,"rx_packets":310281,"rx_errors":0,"rx_dropped":0,"tx_bytes":250514,"tx_packets":2681,"tx_errors":0,"tx_dropped":0}}}';
|
|
110
|
+
// var stats = '{"read":"2025-01-23T04:52:53.853606208Z","preread":"2025-01-23T04:52:43.853359478Z","pids_stats":{},"blkio_stats":{"io_service_bytes_recursive":[],"io_serviced_recursive":[],"io_queue_recursive":[],"io_service_time_recursive":[],"io_wait_time_recursive":[],"io_merged_recursive":[],"io_time_recursive":[],"sectors_recursive":[]},"num_procs":0,"storage_stats":{},"cpu_stats":{"cpu_usage":{"total_usage":8111895890,"percpu_usage":[3973083470,4138812420],"usage_in_kernelmode":2220000000,"usage_in_usermode":5910000000},"system_cpu_usage":1692450000000,"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"precpu_stats":{"cpu_usage":{"total_usage":8023476115,"percpu_usage":[3922781879,4100694236],"usage_in_kernelmode":2180000000,"usage_in_usermode":5820000000},"system_cpu_usage":1672470000000,"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"memory_stats":{"usage":66977792,"max_usage":98480128,"stats":{"active_anon":0,"active_file":0,"cache":0,"dirty":0,"hierarchical_memory_limit":4294967296,"hierarchical_memsw_limit":9223372036854771712,"inactive_anon":61906944,"inactive_file":0,"mapped_file":0,"pgfault":463386,"pgmajfault":0,"pgpgin":147477,"pgpgout":132323,"rss":62042112,"rss_huge":0,"total_active_anon":0,"total_active_file":0,"total_cache":0,"total_dirty":0,"total_inactive_anon":61906944,"total_inactive_file":0,"total_mapped_file":0,"total_pgfault":463386,"total_pgmajfault":0,"total_pgpgin":147477,"total_pgpgout":132323,"total_rss":62042112,"total_rss_huge":0,"total_unevictable":0,"total_writeback":0,"unevictable":0,"writeback":0},"limit":9223372036854771712},"name":"test_container","id":"a663f01570b14228b0795db9c8d11e16-2785547837","networks":{"eth1":{"rx_bytes":463489958,"rx_packets":311334,"rx_errors":0,"rx_dropped":0,"tx_bytes":1962223,"tx_packets":4432,"tx_errors":0,"tx_dropped":0}}}'
|
|
111
|
+
const o = JSON.parse(stats);
|
|
112
|
+
|
|
113
|
+
if (conf.getProperty('debug_aws_ecs_enabled', false)) {
|
|
114
|
+
Logger.print("AwsEcsClient", 30, "meta_uri=" + meta_uri + " stats\n" + JSON.stringify(o, null, 4));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const precpu_stats = o.precpu_stats || {};
|
|
118
|
+
const cpu_stats = o.cpu_stats || {};
|
|
119
|
+
const memory_stats = o.memory_stats || {};
|
|
120
|
+
|
|
121
|
+
const system_cpu_usage = delta(precpu_stats, cpu_stats, "system_cpu_usage");
|
|
122
|
+
|
|
123
|
+
if (system_cpu_usage > 0) {
|
|
124
|
+
const precpu_usage = precpu_stats.cpu_usage || {};
|
|
125
|
+
const cpu_usage = cpu_stats.cpu_usage || {};
|
|
126
|
+
|
|
127
|
+
const usage_tot = delta(precpu_usage, cpu_usage, "total_usage");
|
|
128
|
+
const usage_sys = delta(precpu_usage, cpu_usage, "usage_in_kernelmode");
|
|
129
|
+
const usage_usr = delta(precpu_usage, cpu_usage, "usage_in_usermode");
|
|
130
|
+
|
|
131
|
+
self.cpu = (usage_tot * 100.0) / system_cpu_usage;
|
|
132
|
+
self.cpu_sys = (usage_sys * 100.0) / system_cpu_usage;
|
|
133
|
+
self.cpu_user = (usage_usr * 100.0) / system_cpu_usage;
|
|
134
|
+
} else {
|
|
135
|
+
self.reset();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (memory_stats) {
|
|
139
|
+
const mem_usage = memory_stats.usage || 0;
|
|
140
|
+
const memory_stats_stats = memory_stats.stats;
|
|
141
|
+
|
|
142
|
+
if (memory_stats_stats) {
|
|
143
|
+
const mem_limit = memory_stats_stats.hierarchical_memory_limit || 0;
|
|
144
|
+
self.mem_pct = (mem_usage * 100.0) / mem_limit;
|
|
145
|
+
} else {
|
|
146
|
+
self.mem_pct = 0;
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
self.mem_pct = 0;
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
.catch(error => {
|
|
153
|
+
Logger.printError("WHATAP-819", "ECS Process error: " + error, false)
|
|
154
|
+
self.reset();
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
AwsEcsClientThread.prototype.reset = function () {
|
|
159
|
+
this.cpu = 0;
|
|
160
|
+
this.cpu_sys = 0;
|
|
161
|
+
this.cpu_user = 0;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// reset 함수 추가
|
|
165
|
+
AwsEcsClientThread.prototype.reset = function () {
|
|
166
|
+
this.cpu = 0;
|
|
167
|
+
this.cpu_sys = 0;
|
|
168
|
+
this.cpu_user = 0;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
AwsEcsClientThread.CHECK_MAX = 3;
|
|
172
|
+
|
|
173
|
+
function read(url, succ, fail) {
|
|
174
|
+
http.get(url, function (res) {
|
|
175
|
+
var statusCode = res.statusCode;
|
|
176
|
+
|
|
177
|
+
if (statusCode !== 200) {
|
|
178
|
+
if (fail) fail();
|
|
179
|
+
|
|
180
|
+
Logger.printError('WHATAP-999', 'read http call (not 200) ', e, true);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
res.setEncoding('utf8');
|
|
185
|
+
|
|
186
|
+
var rawData = '';
|
|
187
|
+
res.on('data', function (chunk) {
|
|
188
|
+
rawData += chunk;
|
|
189
|
+
});
|
|
190
|
+
res.on('end', function () {
|
|
191
|
+
try {
|
|
192
|
+
var stats = JSON.parse(rawData);
|
|
193
|
+
if (succ) succ(stats);
|
|
194
|
+
} catch (e) {
|
|
195
|
+
if (fail) fail(e);
|
|
196
|
+
Logger.printError('WHATAP-999', 'read http call (not application/json) ', e, true);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}).on('error', (e) => {
|
|
200
|
+
if (fail) fail(e);
|
|
201
|
+
Logger.printError('WHATAP-999', 'read http call ', e, true);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function delta(j1, j2, key) {
|
|
206
|
+
if (!j1 || !j2)
|
|
207
|
+
return 0;
|
|
208
|
+
|
|
209
|
+
var v1 = j1[key];
|
|
210
|
+
var v2 = j2[key];
|
|
211
|
+
|
|
212
|
+
if(v1 && v2)
|
|
213
|
+
return v2 - v1;
|
|
214
|
+
else
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
module.exports = new AwsEcsClientThread();
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
// ResSysCpuPack= require('../../pack/ResSysCpu-pack'),
|
|
10
|
+
SystemECSTask = require('./res/systemECSTask'),
|
|
11
|
+
SystemKubeTask = require('./res/systemKubeTask'),
|
|
12
|
+
ConfSysMon = require('../../conf/conf-sys-mon'),
|
|
13
|
+
DataPackSender = require('../../data/datapack-sender'),
|
|
14
|
+
Long = require('long');
|
|
15
|
+
|
|
16
|
+
function ResSysCpu() {
|
|
17
|
+
// this.systype = ConfSysMon.SysType.NONE;
|
|
18
|
+
this.update();
|
|
19
|
+
}
|
|
20
|
+
ResSysCpu.prototype = new CounterTask();
|
|
21
|
+
ResSysCpu.prototype.constructor = ResSysCpu;
|
|
22
|
+
ResSysCpu.prototype.process = function (p) {
|
|
23
|
+
|
|
24
|
+
this.init();
|
|
25
|
+
|
|
26
|
+
if(this.sysmon) this.sysmon.process(p);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
ResSysCpu.prototype.init = function () {
|
|
30
|
+
// // WatchDog을 시작시킴
|
|
31
|
+
// if (ConfWatchLog.watchlog_enabled) {
|
|
32
|
+
// WatchLogManager.getInstance();
|
|
33
|
+
// GcWatchManager.getInstance();
|
|
34
|
+
// }
|
|
35
|
+
// if (conf.WHATAP_MICRO_ENABLED) {
|
|
36
|
+
// KubeClient.getInstance();
|
|
37
|
+
// }
|
|
38
|
+
// if (ConfSysMon.aws_ecs_enabled) {
|
|
39
|
+
// AwsEcsClientThread.getInstance();
|
|
40
|
+
// }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ResSysCpu.prototype.update = function () {
|
|
44
|
+
var thisType = ConfSysMon.findType();
|
|
45
|
+
|
|
46
|
+
if (this.systype == thisType)
|
|
47
|
+
return;
|
|
48
|
+
this.systype = thisType;
|
|
49
|
+
|
|
50
|
+
switch (thisType) {
|
|
51
|
+
case ConfSysMon.SysType.ECS:
|
|
52
|
+
this.sysmon = new SystemECSTask();
|
|
53
|
+
Logger.print('WHATAP SysCpu ' , "System CPU collected by 'ECS' task", undefined , true);
|
|
54
|
+
break;
|
|
55
|
+
case ConfSysMon.SysType.KUBE:
|
|
56
|
+
this.sysmon = new SystemKubeTask();
|
|
57
|
+
Logger.print('WHATAP SysCpu ' , "System CPU collected by 'KUBE", undefined , true);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = ResSysCpu;
|
|
@@ -0,0 +1,202 @@
|
|
|
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
|
+
MeterService = require('../meter/meter-service').MeterService,
|
|
9
|
+
MeterActiveX = require('../meter/meter-activex'),
|
|
10
|
+
DataPackSender = require('../../data/datapack-sender'),
|
|
11
|
+
IntKeyLinkedMap = require('../../util/intkey-linkedmap'),
|
|
12
|
+
LinkedMap = require('../../util/linkedmap'),
|
|
13
|
+
conf = require('../../conf/configure'),
|
|
14
|
+
Long = require('long');
|
|
15
|
+
|
|
16
|
+
function Item(tps, rtime) {
|
|
17
|
+
this.tps = tps || 0;
|
|
18
|
+
this.rtime = rtime || 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function Service() {
|
|
22
|
+
CounterTask.call(this);
|
|
23
|
+
this.avg30 = new IntKeyLinkedMap(7, 1).setMax(6);
|
|
24
|
+
|
|
25
|
+
this.calcTpsResp = function (p, basetime /*Long*/ ) {
|
|
26
|
+
// var basetime = basetime.toString(); /*Long to String*/
|
|
27
|
+
var t = 0,
|
|
28
|
+
r = 0,
|
|
29
|
+
r90 = 0,
|
|
30
|
+
c = 0,
|
|
31
|
+
en = this.avg30.entries(),
|
|
32
|
+
key, val;
|
|
33
|
+
|
|
34
|
+
while (en.hasMoreElements()) {
|
|
35
|
+
var entry = en.nextElement();
|
|
36
|
+
key = entry.getKey();
|
|
37
|
+
val = entry.getValue();
|
|
38
|
+
if (key >= basetime) {
|
|
39
|
+
c++;
|
|
40
|
+
t += val.tps;
|
|
41
|
+
r += val.rtime;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (c > 0) {
|
|
46
|
+
p.tps = parseFloat(t / c);
|
|
47
|
+
p.resp_time = parseInt(r / c);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
Service.prototype = new CounterTask();
|
|
52
|
+
Service.prototype.constructor = Service;
|
|
53
|
+
Service.prototype.process = function (p) {
|
|
54
|
+
|
|
55
|
+
var b = MeterService.getBucket();
|
|
56
|
+
p.service_count = b.count;
|
|
57
|
+
p.service_time = b.timesum;
|
|
58
|
+
p.service_error = b.error;
|
|
59
|
+
|
|
60
|
+
p.apdex_satisfied = b.count_satisfied;
|
|
61
|
+
p.apdex_tolerated = b.count_tolerated;
|
|
62
|
+
p.apdex_total = b.count;
|
|
63
|
+
|
|
64
|
+
if (conf.tx_caller_meter_enabled) {
|
|
65
|
+
tx_caller_meter(p);
|
|
66
|
+
}
|
|
67
|
+
if (conf.actx_meter_enabled) {
|
|
68
|
+
tx_caller_active_meter(p);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (p.duration > 0) {
|
|
72
|
+
if (b.count <= 0) {
|
|
73
|
+
this.avg30.put(p.time, new Item(0, 0));
|
|
74
|
+
} else {
|
|
75
|
+
this.avg30.put(p.time, new Item(b.count / p.duration, b.timesum / b.count));
|
|
76
|
+
}
|
|
77
|
+
this.calcTpsResp(p, p.time - 30000);
|
|
78
|
+
}
|
|
79
|
+
var hp = b.hitmap;
|
|
80
|
+
|
|
81
|
+
b.reset();
|
|
82
|
+
hp.time = p.time;
|
|
83
|
+
|
|
84
|
+
DataPackSender.sendHitMapPack1(hp);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
function createLinkedMap() {
|
|
88
|
+
var m = new LinkedMap(309, 1).setMax(307);
|
|
89
|
+
m.hash = function (k) {
|
|
90
|
+
if (k._hash_) {
|
|
91
|
+
return k._hash_;
|
|
92
|
+
}
|
|
93
|
+
var result = 1;
|
|
94
|
+
result = 31 * result + k.pcode;
|
|
95
|
+
result = 31 * result + k.okind;
|
|
96
|
+
|
|
97
|
+
k._hash_ = result;
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
m.equals = function (k1, k2) {
|
|
101
|
+
return k1.pcode === k2.pcode && k1.okind === k2.okind;
|
|
102
|
+
};
|
|
103
|
+
return m;
|
|
104
|
+
}
|
|
105
|
+
function tx_caller_meter(p) {
|
|
106
|
+
var meter = MeterService;
|
|
107
|
+
if (meter.stat.size() > 0) {
|
|
108
|
+
p.txcaller_oid_meter = new IntKeyLinkedMap();
|
|
109
|
+
var en = meter.stat.keys();
|
|
110
|
+
for (var i = 0; i < 300 && en.hasMoreElements(); i++) {
|
|
111
|
+
var key = en.nextElement();
|
|
112
|
+
var b = meter.stat.get(key);
|
|
113
|
+
p.txcaller_oid_meter.put(key, {
|
|
114
|
+
time: b.timesum,
|
|
115
|
+
count: b.count,
|
|
116
|
+
error: b.error,
|
|
117
|
+
actx: 0
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (meter.statByGroup.size() > 0) {
|
|
122
|
+
p.txcaller_group_meter = createLinkedMap();
|
|
123
|
+
var en = meter.statByGroup.keys();
|
|
124
|
+
for (var i = 0; i < 300 && en.hasMoreElements(); i++) {
|
|
125
|
+
var key = en.nextElement();
|
|
126
|
+
var b = meter.statByGroup.get(key);
|
|
127
|
+
p.txcaller_group_meter.put(key, {
|
|
128
|
+
time: b.timesum,
|
|
129
|
+
count: b.count,
|
|
130
|
+
error: b.error,
|
|
131
|
+
actx: 0
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
p.txcaller_unknown = {
|
|
136
|
+
count: meter.unknown.count,
|
|
137
|
+
error: meter.unknown.error,
|
|
138
|
+
time: meter.unknown.timesum,
|
|
139
|
+
actx: 0
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
meter.resetStat();
|
|
143
|
+
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
function tx_caller_active_meter(p) {
|
|
147
|
+
var meter = MeterActiveX;
|
|
148
|
+
if (meter.statByOid.size() > 0) {
|
|
149
|
+
if (p.txcaller_oid_meter == null) {
|
|
150
|
+
p.txcaller_oid_meter = new IntKeyLinkedMap();
|
|
151
|
+
}
|
|
152
|
+
var en = meter.statByOid.keys();
|
|
153
|
+
for (var i = 0; i < 300 && en.hasMoreElements(); i++) {
|
|
154
|
+
var key = en.nextElement();
|
|
155
|
+
var b = meter.statByOid.get(key);
|
|
156
|
+
var org = p.txcaller_oid_meter.get(key);
|
|
157
|
+
if (org) {
|
|
158
|
+
org.actx = b;
|
|
159
|
+
} else {
|
|
160
|
+
p.txcaller_oid_meter.put(key, {
|
|
161
|
+
time: 0,
|
|
162
|
+
count: 0,
|
|
163
|
+
error: 0,
|
|
164
|
+
actx: b
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (meter.statByGroup.size() > 0) {
|
|
170
|
+
if (p.txcaller_group_meter == null) {
|
|
171
|
+
p.txcaller_group_meter = createLinkedMap();
|
|
172
|
+
}
|
|
173
|
+
var en = meter.statByGroup.keys();
|
|
174
|
+
for (var i = 0; i < 300 && en.hasMoreElements(); i++) {
|
|
175
|
+
var key = en.nextElement();
|
|
176
|
+
var b = meter.statByGroup.get(key);
|
|
177
|
+
var org = p.txcaller_group_meter.get(key);
|
|
178
|
+
if (org) {
|
|
179
|
+
org.actx = b;
|
|
180
|
+
} else {
|
|
181
|
+
p.txcaller_group_meter.put(key, {
|
|
182
|
+
time: 0,
|
|
183
|
+
count: 0,
|
|
184
|
+
error: 0,
|
|
185
|
+
actx: b
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if(p.txcaller_unknown){
|
|
191
|
+
p.txcaller_unknown.actx = meter.unknown;
|
|
192
|
+
} else {
|
|
193
|
+
p.txcaller_unknown = {
|
|
194
|
+
count: 0,
|
|
195
|
+
error: 0,
|
|
196
|
+
time: 0,
|
|
197
|
+
actx :meter.unknown
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
module.exports = Service;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
MeterSocketio = require('../meter/meter-socket.io'),
|
|
9
|
+
WEBSOCKET = require('../../pack/websocket'),
|
|
10
|
+
Long = require('long');
|
|
11
|
+
|
|
12
|
+
function Socketio() {
|
|
13
|
+
CounterTask.call(this);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Socketio.prototype = new CounterTask();
|
|
17
|
+
Socketio.prototype.constructor = Socketio;
|
|
18
|
+
Socketio.prototype.process = function (p) {
|
|
19
|
+
if(MeterSocketio.connected_count > 0) {
|
|
20
|
+
if(p.websocket == null) {
|
|
21
|
+
p.websocket = new WEBSOCKET();
|
|
22
|
+
}
|
|
23
|
+
p.websocket.count = MeterSocketio.connected_count;
|
|
24
|
+
p.websocket.in = MeterSocketio.received_data;
|
|
25
|
+
p.websocket.out = MeterSocketio.sent_data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module.exports = Socketio;
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
MeterSql = require('../meter/meter-sql'),
|
|
9
|
+
MeterActiveX = require('../meter/meter-activex'),
|
|
10
|
+
IntKeyLinkedMap = require('../../util/intkey-linkedmap'),
|
|
11
|
+
conf = require('../../conf/configure'),
|
|
12
|
+
IntIntMap = require('../../util/intint-map');
|
|
13
|
+
|
|
14
|
+
function Sql() {
|
|
15
|
+
CounterTask.call(this);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Sql.prototype = new CounterTask();
|
|
19
|
+
Sql.prototype.constructor = CounterTask;
|
|
20
|
+
Sql.prototype.process = function (p) {
|
|
21
|
+
var sql = MeterSql.getBucketReset();
|
|
22
|
+
|
|
23
|
+
p.sql_time = sql.time;
|
|
24
|
+
p.sql_count = sql.count;
|
|
25
|
+
p.sql_error = sql.error;
|
|
26
|
+
|
|
27
|
+
p.sql_fetch_count = sql.fetch_count;
|
|
28
|
+
p.sql_fetch_time = sql.fetch_time;
|
|
29
|
+
|
|
30
|
+
if(sql.db_conn_active.size() > 0 || sql.db_conn_idle.size() > 0) {
|
|
31
|
+
if(p.db_num_active == null) {
|
|
32
|
+
p.db_num_active = new IntIntMap(7, 1);
|
|
33
|
+
p.db_num_idle = new IntIntMap(7, 1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var enumer_acvive = sql.db_conn_active.entries();
|
|
37
|
+
while(enumer_acvive.hasMoreElements()) {
|
|
38
|
+
var entry = enumer_acvive.nextElement();
|
|
39
|
+
p.db_num_active.add(entry.key, entry.value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var enumer_idle = sql.db_conn_idle.entries();
|
|
43
|
+
while(enumer_idle.hasMoreElements()) {
|
|
44
|
+
var entry = enumer_idle.nextElement();
|
|
45
|
+
p.db_num_idle.add(entry.key, entry.value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
if (conf.sql_dbc_meter_enabled) {
|
|
50
|
+
sql_meter(p);
|
|
51
|
+
}
|
|
52
|
+
if (conf.actx_meter_enabled) {
|
|
53
|
+
sql_actx_meter(p);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
function sql_meter(p){
|
|
58
|
+
if (MeterSql.stat.size() > 0) {
|
|
59
|
+
p.sql_meter = new IntKeyLinkedMap();
|
|
60
|
+
var en = MeterSql.stat.keys();
|
|
61
|
+
for (var i = 0; i < 100 && en.hasMoreElements(); i++) {
|
|
62
|
+
var key = en.nextElement();
|
|
63
|
+
var b = MeterSql.stat.get(key);
|
|
64
|
+
if(b != null) {
|
|
65
|
+
p.sql_meter.put(key, {
|
|
66
|
+
time: b.time,
|
|
67
|
+
count: b.count,
|
|
68
|
+
error: b.error,
|
|
69
|
+
actx : 0,
|
|
70
|
+
fetch_count: b.fetch_count,
|
|
71
|
+
fetch_time: b.fetch_time
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
MeterSql.resetStat();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function sql_actx_meter(p) {
|
|
79
|
+
var meter = MeterActiveX;
|
|
80
|
+
if (meter.stat_sql.size() > 0) {
|
|
81
|
+
if (p.sql_meter == null) {
|
|
82
|
+
p.sql_meter = new IntKeyLinkedMap();
|
|
83
|
+
}
|
|
84
|
+
var en = meter.stat_sql.keys();
|
|
85
|
+
for (var i = 0; i < 100 && en.hasMoreElements(); i++) {
|
|
86
|
+
var key = en.nextElement();
|
|
87
|
+
var b = meter.stat_sql.get(key);
|
|
88
|
+
var org = p.sql_meter.get(key);
|
|
89
|
+
if (org) {
|
|
90
|
+
org.actx = b;
|
|
91
|
+
} else {
|
|
92
|
+
p.sql_meter.put(key, {
|
|
93
|
+
time: 0,
|
|
94
|
+
count: 0,
|
|
95
|
+
error: 0,
|
|
96
|
+
actx: b,
|
|
97
|
+
fetch_count: 0,
|
|
98
|
+
fetch_time: 0
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = Sql;
|