whatap 1.0.2 → 1.0.3-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +77 -33
  2. package/agent/darwin/arm64/whatap_nodejs +0 -0
  3. package/agent/linux/amd64/whatap_nodejs +0 -0
  4. package/agent/linux/arm64/whatap_nodejs +0 -0
  5. package/build.txt +4 -0
  6. package/lib/conf/config-default.js +3 -10
  7. package/lib/conf/configure.js +349 -369
  8. package/lib/conf/license.js +1 -1
  9. package/lib/control/packagectr-helper.js +3 -34
  10. package/lib/core/agent.js +888 -176
  11. package/lib/core/interceptor.js +6 -6
  12. package/lib/core/shimmer.js +36 -82
  13. package/lib/counter/counter-manager.js +8 -79
  14. package/lib/counter/task/activetransaction.js +17 -68
  15. package/lib/io/data-inputx.js +3 -13
  16. package/lib/io/data-outputx.js +206 -268
  17. package/lib/logger.js +6 -6
  18. package/lib/net/security-master.js +20 -139
  19. package/lib/observers/apollo-server-observer.js +27 -33
  20. package/lib/observers/global-observer.js +80 -155
  21. package/lib/observers/http-observer.js +236 -666
  22. package/lib/observers/ioredis-observer.js +294 -0
  23. package/lib/observers/maria-observer.js +362 -204
  24. package/lib/observers/mongodb-observer.js +226 -169
  25. package/lib/observers/mongoose-observer.js +323 -518
  26. package/lib/observers/mssql-observer.js +418 -177
  27. package/lib/observers/mysql-observer.js +449 -342
  28. package/lib/observers/mysql2-observer.js +358 -396
  29. package/lib/observers/oracle-observer.js +384 -559
  30. package/lib/observers/pgsql-observer.js +489 -231
  31. package/lib/observers/prisma-observer.js +92 -303
  32. package/lib/observers/process-observer.js +35 -79
  33. package/lib/observers/redis-observer.js +331 -166
  34. package/lib/observers/socket.io-observer.js +187 -226
  35. package/lib/observers/websocket-observer.js +301 -175
  36. package/lib/pack/counter-pack.js +0 -3
  37. package/lib/pack/log-sink-pack.js +52 -14
  38. package/lib/pack/tagcount-pack.js +4 -4
  39. package/lib/{counter/task → system}/gc-action.js +74 -27
  40. package/lib/trace/trace-context-manager.js +25 -113
  41. package/lib/trace/trace-context.js +7 -21
  42. package/lib/trace/trace-httpc.js +11 -17
  43. package/lib/trace/trace-sql.js +21 -29
  44. package/lib/udp/async_sender.js +119 -0
  45. package/lib/udp/index.js +17 -0
  46. package/lib/udp/packet_enum.js +52 -0
  47. package/lib/udp/packet_queue.js +69 -0
  48. package/lib/udp/packet_type_enum.js +33 -0
  49. package/lib/udp/param_def.js +72 -0
  50. package/lib/udp/udp_session.js +336 -0
  51. package/lib/util/escape-literal-sql.js +5 -5
  52. package/lib/util/hashutil.js +18 -18
  53. package/lib/util/keygen.js +3 -0
  54. package/lib/util/linkedset.js +2 -1
  55. package/lib/util/nodeutil.js +1 -2
  56. package/lib/util/sql-util.js +178 -0
  57. package/lib/util/trace-helper.js +91 -0
  58. package/lib/util/transfer.js +58 -0
  59. package/lib/value/map-value.js +2 -3
  60. package/package.json +5 -9
  61. package/whatap.conf +4 -1
  62. package/lib/conf/conf-sys-mon.js +0 -101
  63. package/lib/control/cmd-config.js +0 -24
  64. package/lib/control/control-handler.js +0 -367
  65. package/lib/core/request-agent.js +0 -27
  66. package/lib/counter/meter/meter-activex.js +0 -67
  67. package/lib/counter/meter/meter-httpc.js +0 -57
  68. package/lib/counter/meter/meter-resource.js +0 -9
  69. package/lib/counter/meter/meter-service.js +0 -168
  70. package/lib/counter/meter/meter-socket.io.js +0 -51
  71. package/lib/counter/meter/meter-sql.js +0 -71
  72. package/lib/counter/meter/meter-users.js +0 -58
  73. package/lib/counter/meter.js +0 -183
  74. package/lib/counter/task/agentinfo.js +0 -107
  75. package/lib/counter/task/gcstat.js +0 -34
  76. package/lib/counter/task/heapmem.js +0 -25
  77. package/lib/counter/task/httpc.js +0 -76
  78. package/lib/counter/task/metering-info.js +0 -125
  79. package/lib/counter/task/proc-cpu.js +0 -29
  80. package/lib/counter/task/realtimeuser.js +0 -31
  81. package/lib/counter/task/res/systemECSTask.js +0 -39
  82. package/lib/counter/task/res/systemKubeTask.js +0 -53
  83. package/lib/counter/task/res/util/awsEcsClientThread.js +0 -218
  84. package/lib/counter/task/res/util/linuxProcStatUtil.js +0 -14
  85. package/lib/counter/task/res-sys-cpu.js +0 -62
  86. package/lib/counter/task/service.js +0 -202
  87. package/lib/counter/task/socketio.js +0 -30
  88. package/lib/counter/task/sql.js +0 -105
  89. package/lib/counter/task/systemperf.js +0 -43
  90. package/lib/data/datapack-sender.js +0 -289
  91. package/lib/data/dataprofile-agent.js +0 -162
  92. package/lib/data/datatext-agent.js +0 -135
  93. package/lib/data/event-level.js +0 -15
  94. package/lib/data/test.js +0 -49
  95. package/lib/data/zipprofile.js +0 -197
  96. package/lib/env/constants.js +0 -21
  97. package/lib/error/error-handler.js +0 -437
  98. package/lib/kube/kube-client.js +0 -144
  99. package/lib/lang/text-types.js +0 -58
  100. package/lib/logsink/line-log-util.js +0 -87
  101. package/lib/logsink/line-log.js +0 -12
  102. package/lib/logsink/log-sender.js +0 -78
  103. package/lib/logsink/log-tracer.js +0 -40
  104. package/lib/logsink/sender-util.js +0 -56
  105. package/lib/logsink/zip/zip-send.js +0 -177
  106. package/lib/net/netflag.js +0 -55
  107. package/lib/net/receiver.js +0 -66
  108. package/lib/net/sender.js +0 -141
  109. package/lib/net/tcp-return.js +0 -18
  110. package/lib/net/tcp-session.js +0 -286
  111. package/lib/net/tcpreq-client-proxy.js +0 -70
  112. package/lib/net/tcprequest-mgr.js +0 -58
  113. package/lib/observers/cluster-observer.js +0 -22
  114. package/lib/observers/express-observer.js +0 -215
  115. package/lib/observers/file-observer.js +0 -184
  116. package/lib/observers/grpc-observer.js +0 -336
  117. package/lib/observers/memcached-observer.js +0 -56
  118. package/lib/observers/mongo-observer.js +0 -317
  119. package/lib/observers/net-observer.js +0 -77
  120. package/lib/observers/promise-observer.js +0 -31
  121. package/lib/observers/schedule-observer.js +0 -67
  122. package/lib/observers/stream-observer.js +0 -19
  123. package/lib/observers/thrift-observer.js +0 -197
  124. package/lib/pack/activestack-pack.js +0 -55
  125. package/lib/pack/apenum.js +0 -8
  126. package/lib/pack/errorsnap-pack.js +0 -69
  127. package/lib/pack/event-pack.js +0 -54
  128. package/lib/pack/hitmap-pack.js +0 -63
  129. package/lib/pack/hitmap-pack1.js +0 -152
  130. package/lib/pack/netstat.js +0 -15
  131. package/lib/pack/otype.js +0 -7
  132. package/lib/pack/profile-pack.js +0 -49
  133. package/lib/pack/realtimeuser-pack.js +0 -41
  134. package/lib/pack/stat-general-pack.js +0 -96
  135. package/lib/pack/staterror-pack.js +0 -120
  136. package/lib/pack/stathttpc-pack.js +0 -66
  137. package/lib/pack/stathttpc-rec.js +0 -78
  138. package/lib/pack/statremote-pack.js +0 -46
  139. package/lib/pack/statservice-pack.js +0 -63
  140. package/lib/pack/statservice-pack1.js +0 -88
  141. package/lib/pack/statservice-rec.js +0 -292
  142. package/lib/pack/statservice-rec_dep.js +0 -151
  143. package/lib/pack/statsql-pack.js +0 -69
  144. package/lib/pack/statsql-rec.js +0 -100
  145. package/lib/pack/statuseragent-pack.js +0 -44
  146. package/lib/pack/tagctr.js +0 -15
  147. package/lib/pack/text-pack.js +0 -50
  148. package/lib/pack/time-count.js +0 -25
  149. package/lib/pack/websocket.js +0 -15
  150. package/lib/pack/zip-pack.js +0 -70
  151. package/lib/pii/pii-item.js +0 -31
  152. package/lib/pii/pii-mask.js +0 -174
  153. package/lib/plugin/plugin-loadermanager.js +0 -57
  154. package/lib/plugin/plugin.js +0 -75
  155. package/lib/service/tx-record.js +0 -332
  156. package/lib/stat/stat-error.js +0 -116
  157. package/lib/stat/stat-httpc.js +0 -98
  158. package/lib/stat/stat-remote-ip.js +0 -46
  159. package/lib/stat/stat-remote-ipurl.js +0 -88
  160. package/lib/stat/stat-sql.js +0 -113
  161. package/lib/stat/stat-tranx.js +0 -58
  162. package/lib/stat/stat-tx-caller.js +0 -160
  163. package/lib/stat/stat-tx-domain.js +0 -111
  164. package/lib/stat/stat-tx-referer.js +0 -112
  165. package/lib/stat/stat-useragent.js +0 -48
  166. package/lib/stat/timingsender.js +0 -76
  167. package/lib/step/activestack-step.js +0 -38
  168. package/lib/step/dbc-step.js +0 -36
  169. package/lib/step/http-stepx.js +0 -67
  170. package/lib/step/message-step.js +0 -40
  171. package/lib/step/method-stepx.js +0 -45
  172. package/lib/step/resultset-step.js +0 -40
  173. package/lib/step/securemsg-step.js +0 -44
  174. package/lib/step/socket-step.js +0 -46
  175. package/lib/step/sql-stepx.js +0 -68
  176. package/lib/step/sqlxtype.js +0 -16
  177. package/lib/step/step.js +0 -66
  178. package/lib/step/stepenum.js +0 -54
  179. package/lib/topology/link.js +0 -63
  180. package/lib/topology/nodeinfo.js +0 -123
  181. package/lib/topology/status-detector.js +0 -111
  182. package/lib/util/anylist.js +0 -103
  183. package/lib/util/cardinality/hyperloglog.js +0 -106
  184. package/lib/util/cardinality/murmurhash.js +0 -31
  185. package/lib/util/cardinality/registerset.js +0 -75
  186. package/lib/util/errordata.js +0 -21
  187. package/lib/util/iputil_x.js +0 -527
  188. package/lib/util/kube-util.js +0 -73
  189. package/lib/util/paramsecurity.js +0 -80
  190. package/lib/util/pre-process.js +0 -13
  191. package/lib/util/process-seq.js +0 -166
  192. package/lib/util/property-util.js +0 -36
  193. package/lib/util/request-queue.js +0 -70
  194. package/lib/util/requestdouble-queue.js +0 -72
  195. package/lib/util/resourceprofile.js +0 -157
  196. package/lib/util/stop-watch.js +0 -30
  197. package/lib/util/system-util.js +0 -10
  198. package/lib/util/userid-util.js +0 -57
@@ -1,51 +0,0 @@
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();
@@ -1,71 +0,0 @@
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();
@@ -1,58 +0,0 @@
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;
@@ -1,183 +0,0 @@
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;
@@ -1,107 +0,0 @@
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
-
@@ -1,34 +0,0 @@
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
-
@@ -1,25 +0,0 @@
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;
@@ -1,76 +0,0 @@
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;