whatap 0.5.26 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/agent/darwin/arm64/whatap_nodejs +0 -0
  2. package/agent/linux/amd64/whatap_nodejs +0 -0
  3. package/agent/linux/arm64/whatap_nodejs +0 -0
  4. package/build.txt +4 -0
  5. package/lib/conf/config-default.js +3 -10
  6. package/lib/conf/configure.js +349 -369
  7. package/lib/conf/license.js +1 -1
  8. package/lib/control/packagectr-helper.js +3 -34
  9. package/lib/core/agent.js +882 -176
  10. package/lib/core/interceptor.js +6 -6
  11. package/lib/core/shimmer.js +36 -82
  12. package/lib/counter/counter-manager.js +8 -79
  13. package/lib/counter/task/activetransaction.js +17 -68
  14. package/lib/io/data-inputx.js +3 -13
  15. package/lib/io/data-outputx.js +206 -268
  16. package/lib/logger.js +6 -6
  17. package/lib/net/security-master.js +20 -139
  18. package/lib/observers/apollo-server-observer.js +27 -33
  19. package/lib/observers/global-observer.js +80 -155
  20. package/lib/observers/http-observer.js +236 -666
  21. package/lib/observers/ioredis-observer.js +294 -0
  22. package/lib/observers/maria-observer.js +362 -204
  23. package/lib/observers/mongodb-observer.js +226 -169
  24. package/lib/observers/mongoose-observer.js +323 -518
  25. package/lib/observers/mssql-observer.js +418 -177
  26. package/lib/observers/mysql-observer.js +449 -342
  27. package/lib/observers/mysql2-observer.js +358 -396
  28. package/lib/observers/oracle-observer.js +384 -559
  29. package/lib/observers/pgsql-observer.js +489 -231
  30. package/lib/observers/prisma-observer.js +92 -303
  31. package/lib/observers/process-observer.js +35 -79
  32. package/lib/observers/redis-observer.js +331 -166
  33. package/lib/observers/socket.io-observer.js +187 -226
  34. package/lib/observers/websocket-observer.js +301 -175
  35. package/lib/pack/counter-pack.js +0 -3
  36. package/lib/pack/log-sink-pack.js +52 -14
  37. package/lib/pack/tagcount-pack.js +4 -4
  38. package/lib/{counter/task → system}/gc-action.js +74 -27
  39. package/lib/trace/trace-context-manager.js +25 -113
  40. package/lib/trace/trace-context.js +7 -21
  41. package/lib/trace/trace-httpc.js +11 -17
  42. package/lib/trace/trace-sql.js +21 -29
  43. package/lib/udp/async_sender.js +119 -0
  44. package/lib/udp/index.js +17 -0
  45. package/lib/udp/packet_enum.js +52 -0
  46. package/lib/udp/packet_queue.js +69 -0
  47. package/lib/udp/packet_type_enum.js +33 -0
  48. package/lib/udp/param_def.js +72 -0
  49. package/lib/udp/udp_session.js +336 -0
  50. package/lib/util/escape-literal-sql.js +5 -5
  51. package/lib/util/hashutil.js +18 -18
  52. package/lib/util/keygen.js +3 -0
  53. package/lib/util/linkedset.js +2 -1
  54. package/lib/util/nodeutil.js +1 -2
  55. package/lib/util/sql-util.js +178 -0
  56. package/lib/util/trace-helper.js +91 -0
  57. package/lib/util/transfer.js +58 -0
  58. package/lib/value/map-value.js +2 -3
  59. package/package.json +5 -10
  60. package/lib/conf/conf-sys-mon.js +0 -101
  61. package/lib/control/cmd-config.js +0 -24
  62. package/lib/control/control-handler.js +0 -367
  63. package/lib/core/request-agent.js +0 -27
  64. package/lib/counter/meter/meter-activex.js +0 -67
  65. package/lib/counter/meter/meter-httpc.js +0 -57
  66. package/lib/counter/meter/meter-resource.js +0 -9
  67. package/lib/counter/meter/meter-service.js +0 -168
  68. package/lib/counter/meter/meter-socket.io.js +0 -51
  69. package/lib/counter/meter/meter-sql.js +0 -71
  70. package/lib/counter/meter/meter-users.js +0 -58
  71. package/lib/counter/meter.js +0 -183
  72. package/lib/counter/task/agentinfo.js +0 -107
  73. package/lib/counter/task/gcstat.js +0 -34
  74. package/lib/counter/task/heapmem.js +0 -25
  75. package/lib/counter/task/httpc.js +0 -76
  76. package/lib/counter/task/metering-info.js +0 -125
  77. package/lib/counter/task/proc-cpu.js +0 -29
  78. package/lib/counter/task/realtimeuser.js +0 -31
  79. package/lib/counter/task/res/systemECSTask.js +0 -39
  80. package/lib/counter/task/res/systemKubeTask.js +0 -53
  81. package/lib/counter/task/res/util/awsEcsClientThread.js +0 -218
  82. package/lib/counter/task/res/util/linuxProcStatUtil.js +0 -14
  83. package/lib/counter/task/res-sys-cpu.js +0 -62
  84. package/lib/counter/task/service.js +0 -202
  85. package/lib/counter/task/socketio.js +0 -30
  86. package/lib/counter/task/sql.js +0 -105
  87. package/lib/counter/task/systemperf.js +0 -43
  88. package/lib/data/datapack-sender.js +0 -289
  89. package/lib/data/dataprofile-agent.js +0 -162
  90. package/lib/data/datatext-agent.js +0 -135
  91. package/lib/data/event-level.js +0 -15
  92. package/lib/data/test.js +0 -49
  93. package/lib/data/zipprofile.js +0 -197
  94. package/lib/env/constants.js +0 -21
  95. package/lib/error/error-handler.js +0 -437
  96. package/lib/kube/kube-client.js +0 -144
  97. package/lib/lang/text-types.js +0 -58
  98. package/lib/logsink/line-log-util.js +0 -87
  99. package/lib/logsink/line-log.js +0 -12
  100. package/lib/logsink/log-sender.js +0 -78
  101. package/lib/logsink/log-tracer.js +0 -40
  102. package/lib/logsink/sender-util.js +0 -56
  103. package/lib/logsink/zip/zip-send.js +0 -177
  104. package/lib/net/netflag.js +0 -55
  105. package/lib/net/receiver.js +0 -66
  106. package/lib/net/sender.js +0 -141
  107. package/lib/net/tcp-return.js +0 -18
  108. package/lib/net/tcp-session.js +0 -286
  109. package/lib/net/tcpreq-client-proxy.js +0 -70
  110. package/lib/net/tcprequest-mgr.js +0 -58
  111. package/lib/observers/cluster-observer.js +0 -22
  112. package/lib/observers/express-observer.js +0 -215
  113. package/lib/observers/file-observer.js +0 -184
  114. package/lib/observers/grpc-observer.js +0 -336
  115. package/lib/observers/memcached-observer.js +0 -56
  116. package/lib/observers/mongo-observer.js +0 -317
  117. package/lib/observers/net-observer.js +0 -77
  118. package/lib/observers/promise-observer.js +0 -31
  119. package/lib/observers/schedule-observer.js +0 -67
  120. package/lib/observers/stream-observer.js +0 -19
  121. package/lib/observers/thrift-observer.js +0 -197
  122. package/lib/pack/activestack-pack.js +0 -55
  123. package/lib/pack/apenum.js +0 -8
  124. package/lib/pack/errorsnap-pack.js +0 -69
  125. package/lib/pack/event-pack.js +0 -54
  126. package/lib/pack/hitmap-pack.js +0 -63
  127. package/lib/pack/hitmap-pack1.js +0 -152
  128. package/lib/pack/netstat.js +0 -15
  129. package/lib/pack/otype.js +0 -7
  130. package/lib/pack/profile-pack.js +0 -49
  131. package/lib/pack/realtimeuser-pack.js +0 -41
  132. package/lib/pack/stat-general-pack.js +0 -96
  133. package/lib/pack/staterror-pack.js +0 -120
  134. package/lib/pack/stathttpc-pack.js +0 -66
  135. package/lib/pack/stathttpc-rec.js +0 -78
  136. package/lib/pack/statremote-pack.js +0 -46
  137. package/lib/pack/statservice-pack.js +0 -63
  138. package/lib/pack/statservice-pack1.js +0 -88
  139. package/lib/pack/statservice-rec.js +0 -292
  140. package/lib/pack/statservice-rec_dep.js +0 -151
  141. package/lib/pack/statsql-pack.js +0 -69
  142. package/lib/pack/statsql-rec.js +0 -100
  143. package/lib/pack/statuseragent-pack.js +0 -44
  144. package/lib/pack/tagctr.js +0 -15
  145. package/lib/pack/text-pack.js +0 -50
  146. package/lib/pack/time-count.js +0 -25
  147. package/lib/pack/websocket.js +0 -15
  148. package/lib/pack/zip-pack.js +0 -70
  149. package/lib/pii/pii-item.js +0 -31
  150. package/lib/pii/pii-mask.js +0 -174
  151. package/lib/plugin/plugin-loadermanager.js +0 -57
  152. package/lib/plugin/plugin.js +0 -75
  153. package/lib/service/tx-record.js +0 -332
  154. package/lib/stat/stat-error.js +0 -116
  155. package/lib/stat/stat-httpc.js +0 -98
  156. package/lib/stat/stat-remote-ip.js +0 -46
  157. package/lib/stat/stat-remote-ipurl.js +0 -88
  158. package/lib/stat/stat-sql.js +0 -113
  159. package/lib/stat/stat-tranx.js +0 -58
  160. package/lib/stat/stat-tx-caller.js +0 -160
  161. package/lib/stat/stat-tx-domain.js +0 -111
  162. package/lib/stat/stat-tx-referer.js +0 -112
  163. package/lib/stat/stat-useragent.js +0 -48
  164. package/lib/stat/timingsender.js +0 -76
  165. package/lib/step/activestack-step.js +0 -38
  166. package/lib/step/dbc-step.js +0 -36
  167. package/lib/step/http-stepx.js +0 -67
  168. package/lib/step/message-step.js +0 -40
  169. package/lib/step/method-stepx.js +0 -45
  170. package/lib/step/resultset-step.js +0 -40
  171. package/lib/step/securemsg-step.js +0 -44
  172. package/lib/step/socket-step.js +0 -46
  173. package/lib/step/sql-stepx.js +0 -68
  174. package/lib/step/sqlxtype.js +0 -16
  175. package/lib/step/step.js +0 -66
  176. package/lib/step/stepenum.js +0 -54
  177. package/lib/topology/link.js +0 -63
  178. package/lib/topology/nodeinfo.js +0 -123
  179. package/lib/topology/status-detector.js +0 -111
  180. package/lib/util/anylist.js +0 -103
  181. package/lib/util/cardinality/hyperloglog.js +0 -106
  182. package/lib/util/cardinality/murmurhash.js +0 -31
  183. package/lib/util/cardinality/registerset.js +0 -75
  184. package/lib/util/errordata.js +0 -21
  185. package/lib/util/iputil_x.js +0 -527
  186. package/lib/util/kube-util.js +0 -73
  187. package/lib/util/paramsecurity.js +0 -80
  188. package/lib/util/pre-process.js +0 -13
  189. package/lib/util/process-seq.js +0 -166
  190. package/lib/util/property-util.js +0 -36
  191. package/lib/util/request-queue.js +0 -70
  192. package/lib/util/requestdouble-queue.js +0 -72
  193. package/lib/util/resourceprofile.js +0 -157
  194. package/lib/util/stop-watch.js +0 -30
  195. package/lib/util/system-util.js +0 -10
  196. package/lib/util/userid-util.js +0 -57
@@ -1,113 +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
- const TABLE_MAX_SIZE = 5000;
8
-
9
- var LinkedMap = require('../util/linkedmap'),
10
- SqlRec = require('../pack/statsql-rec'),
11
- StatSqlPack = require('../pack/statsql-pack'),
12
- DataPackSender = require('../data/datapack-sender');
13
-
14
- function StatSql() {
15
- if(typeof StatSql.instance === 'object') {
16
- return StatSql.instance;
17
- }
18
-
19
- this.table = new LinkedMap(TABLE_MAX_SIZE + 1, 1).setMax(TABLE_MAX_SIZE);
20
- this.table.hash = function (k) {
21
- if(k._hash_){
22
- return k._hash_;
23
- }
24
- var result = 1;
25
- result = 31 * result + k.dbc;
26
- result = 31 * result + k.sql;
27
-
28
- k._hash_=result;
29
- return result;
30
- }
31
- this.table.equals = function (k1,k2) {
32
- return k1.dbc === k2.dbc && k1.sql === k2.sql;
33
- }
34
- this.table.create = function (key) {
35
- if(this.isFull()) {
36
- return null;
37
- }
38
- var rec = new SqlRec();
39
- rec.dbc = key.dbc;
40
- rec.sql = key.sql;
41
- rec.time_min = Number.MAX_SAFE_INTEGER;
42
- return rec;
43
- };
44
-
45
- StatSql.instance = this;
46
- }
47
- StatSql.prototype.getSql = function (dbc, sql) {
48
- var key = {dbc: dbc ,
49
- sql: sql
50
- };
51
- return this.table.intern(key);
52
- };
53
- StatSql.prototype.addFetch = function (dbc, sql, fetch, fetchTime) {
54
- if(sql === 0) {
55
- return;
56
- }
57
- var r = this.getSql(dbc, sql);
58
- if(r != null) {
59
- r.fetch_count += fetch;
60
- r.fetch_time += fetchTime;
61
- }
62
- };
63
- // StatSql.prototype.addUpdate = function (dbc, sql, updated) {
64
- // if(sql === 0) {
65
- // return;
66
- // }
67
- // var r = this.getSql(dbc, sql);
68
- // if(r != null) {
69
- // r.update_count = r.update_count.add(updated);
70
- // }
71
- // };
72
-
73
- StatSql.prototype.addSqlTime = function (urlHash, dbc, sql, time, isErr, updated) {
74
-
75
- urlHash = urlHash || 0;
76
- sql = sql || 0;
77
- time = time || 0;
78
- updated = updated || 0;
79
-
80
- if(sql === 0) {
81
- return;
82
- }
83
- var sqlRec = this.getSql(dbc, sql);
84
- if(sqlRec != null) {
85
- sqlRec.count_total++;
86
- sqlRec.time_sum +=time;
87
- sqlRec.time_std += time*time;
88
- sqlRec.time_min = Math.min(sqlRec.time_min, time);
89
- sqlRec.time_max = Math.max(sqlRec.time_max, time);
90
- if(isErr) {
91
- sqlRec.count_error++;
92
- }
93
- sqlRec.update_count +=updated;
94
- sqlRec.service = urlHash;
95
- }
96
- };
97
- StatSql.prototype.send = function (now) {
98
- if(this.table.size() === 0) {
99
- return;
100
- }
101
-
102
- var p = new StatSqlPack().setRecords(this.table.size(), this.table.values());
103
- p.time = now;
104
- this.table.clear();
105
- DataPackSender.sendStatSqlPack(p);
106
- };
107
- StatSql.prototype.clear = function () {
108
- this.table.clear();
109
- };
110
-
111
-
112
- //싱글톤으로 동작해야한다.
113
- module.exports = new StatSql();
@@ -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 IntKeyLinkedMap = require('../util/intkey-linkedmap'),
8
- TransactionRec = require('../pack/statservice-rec'),
9
- StatServicePack = require('../pack/statservice-pack'),
10
- StatServicePack1 = require('../pack/statservice-pack1'),
11
- conf = require('./../conf/configure'),
12
- Logger = require('../logger'),
13
- DataPackSender = require('../data/datapack-sender')
14
-
15
- const TABLE_MAX_SIZE = 5000;
16
-
17
- function StatTranx() {
18
- if(typeof StatTranx.instance === 'object') {
19
- return StatTranx.instance;
20
- }
21
-
22
- this.table = new IntKeyLinkedMap(TABLE_MAX_SIZE + 1, 1).setMax(TABLE_MAX_SIZE);
23
- this.table.create = function (hash) {
24
- if(this.isFull()) {
25
- return null;
26
- }
27
- var rec = new TransactionRec();
28
- rec.setUrlHash(hash);
29
- rec.time_min = Number.MAX_VALUE;
30
- return rec;
31
- };
32
-
33
- StatTranx.instance = this;
34
- }
35
-
36
- StatTranx.prototype.getService = function (hash) {
37
- return this.table.intern(hash);
38
- };
39
- StatTranx.prototype.send = function (now) {
40
- if(this.table.size() === 0) {
41
- return;
42
- }
43
- var p = undefined;
44
- if(conf.stat_service1_enabled){
45
- p = new StatServicePack1().setRecords(this.table.size(), this.table.values());
46
- p.spec = conf.mtrace_spec_hash;
47
- }else{
48
- p = new StatServicePack().setRecords(this.table.size(), this.table.values());
49
- }
50
- p.time = now;
51
- this.table.clear();
52
- DataPackSender.sendStatServicePack(p);
53
- };
54
- StatTranx.prototype.clear = function () {
55
- this.table.clear();
56
- };
57
-
58
- module.exports = new StatTranx();
@@ -1,160 +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 LinkedMap = require('../util/linkedmap'),
8
- AnyList = require('../util/anylist'),
9
- StatGeneralPack = require('../pack/stat-general-pack'),
10
- DataPackSender = require('../data/datapack-sender'),
11
- Logger = require('../logger'),
12
- HashUtil = require('../util/hashutil'),
13
- StringUtil = require('../util/string-util'),
14
- DataTextAgent = require('../data/datatext-agent'),
15
- conf = require('../conf/configure'),
16
- TimeCount = require('../pack/time-count');
17
-
18
- const TABLE_MAX_SIZE = 5000;
19
-
20
- function PK(caller_pcode, caller_okind, caller_spec, caller_url, url) {
21
- this.caller_pcode = caller_pcode;
22
- this.caller_okind = caller_okind;
23
- this.caller_spec = caller_spec ;
24
- this.caller_url = caller_url;
25
- this.url = url ;
26
- }
27
-
28
- PK.prototype.hashCode = function () {
29
- if(this._hash_){
30
- return this._hash_;
31
- }
32
- var prime = 31;
33
- var result = 1;
34
- result = prime * result + this.caller_pcode;
35
- result = prime * result + this.caller_okind;
36
- result = prime * result + this.caller_spec;
37
- result = prime * result + this.caller_url;
38
- result = prime * result + this.url;
39
- this._hash_=result;
40
- return result;
41
- };
42
- PK.prototype.equals = function (other) {
43
- if(this === other) {
44
- return true;
45
- }
46
- if(other == null) {
47
- return false;
48
- }
49
- if(other instanceof PK === false) {
50
- return false;
51
- }
52
- return this.caller_pcode === other.caller_pcode
53
- && this.caller_okind === other.caller_okind
54
- && this.caller_spec === other.caller_spec
55
- && this.caller_url === other.caller_url
56
- && this.url === other.url;
57
- };
58
-
59
-
60
- function StatTranxMtCaller() {
61
- if(typeof StatTranxMtCaller.instance === 'object') {
62
- return StatTranxMtCaller.instance;
63
- }
64
-
65
- this.table = new LinkedMap(TABLE_MAX_SIZE + 1 , 1).setMax(TABLE_MAX_SIZE);
66
- this.table.create = function (key) {
67
- if(this.size() >= TABLE_MAX_SIZE) {
68
- return null;
69
- }
70
- return new TimeCount();
71
- };
72
-
73
- conf.on('stat_mtrace_max_count', function(props){
74
- StatTranxMtCaller.instance.table.setMax(props);
75
- })
76
-
77
- StatTranxMtCaller.instance = this;
78
- }
79
-
80
- StatTranxMtCaller.prototype.getService = function (caller_pcode, caller_okind, caller_spec, caller_url,url) {
81
- return this.table.intern(new PK(caller_pcode,caller_okind,caller_spec, caller_url, url));
82
- };
83
- StatTranxMtCaller.prototype.add = function (caller_pcode, caller_spec, caller_url, url,
84
- time, isErr) {
85
- try {
86
- var rec = this.getService(caller_pcode, caller_spec, caller_url,url);
87
- if(rec) {
88
- rec.count++;
89
- if(isErr){
90
- rec.error++;
91
- }
92
- rec.toime +=time;
93
- }
94
- } catch(e) {
95
- Logger.printError("WHATAP-610", "StatTranxMtCaller add error", e, false);
96
- }
97
- };
98
- StatTranxMtCaller.prototype.send = function (now) {
99
- if(this.table.size() === 0) {
100
- return;
101
- }
102
- var mtrace_spec_hash = 0;
103
- // if(conf.mtrace_spec) {
104
- // mtrace_spec_hash = HashUtil.hash(conf.mtrace_spec);
105
- // DataTextAgent.MTRACE_SPEC.add(mtrace_spec_hash,conf.mtrace_spec);
106
- // }
107
- if( StringUtil.isNotEmpty(conf.mtrace_spec) ){
108
- DataTextAgent.MTRACE_SPEC.add(conf.mtrace_spec_hash, conf.mtrace_spec);
109
- }
110
-
111
- var rsize=this.table.size();
112
- var caller_pcode =new AnyList(AnyList.LONG, rsize); /*pcode=LONG*/
113
- var caller_okind =new AnyList(AnyList.INT, rsize);
114
- var caller_spec =new AnyList(AnyList.INT, rsize);
115
- var caller_url =new AnyList(AnyList.INT, rsize);
116
- var spec =new AnyList(AnyList.INT, rsize);
117
- var url =new AnyList(AnyList.INT, rsize);
118
- var count = new AnyList(AnyList.INT, rsize);
119
- var error = new AnyList(AnyList.INT, rsize);
120
- var time = new AnyList(AnyList.LONG, rsize);
121
-
122
- var en = this.table.entries();
123
- for (var i = 0; i<rsize && en.hasMoreElements(); i++) {
124
- var ent = en.nextElement();
125
- var k = ent.getKey();
126
- var v = ent.getValue();
127
-
128
- caller_pcode.put(i, k.caller_pcode);
129
- caller_okind.put(i, k.caller_okind);
130
- caller_spec.put(i, k.caller_spec);
131
- caller_url.put(i, k.caller_url);
132
- spec.put(i, mtrace_spec_hash);
133
- url.put(i, k.url);
134
- count.put(i, v.count);
135
- error.put(i, v.error);
136
- time.put(i, v.time);
137
- }
138
- this.table.clear();
139
-
140
- var out = new StatGeneralPack();
141
- out.put("caller_pcode", caller_pcode);
142
- out.put("caller_okind", caller_okind);
143
- out.put("caller_spec", caller_spec);
144
- out.put("caller_url", caller_url);
145
- out.put("spec", spec);
146
- out.put("url", url);
147
- out.put("count", count);
148
- out.put("error", error);
149
- out.put("time", time);
150
-
151
- out.id = "mt";
152
- out.time = now;
153
-
154
- DataPackSender.sendPack(out);
155
- };
156
- StatTranxMtCaller.prototype.clear = function () {
157
- this.table.clear();
158
- };
159
-
160
- module.exports = new StatTranxMtCaller();
@@ -1,111 +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 LinkedMap = require('../util/linkedmap'),
8
- AnyList = require('../util/anylist'),
9
- StatGeneralPack = require('../pack/stat-general-pack'),
10
- DataPackSender = require('../data/datapack-sender'),
11
- Logger = require('../logger'),
12
- TimeCount = require('../pack/time-count');
13
-
14
- const TABLE_MAX_SIZE = 5000;
15
-
16
- function PK(domain, url) {
17
- this.domain = domain || 0;
18
- this.url = url || 0;
19
- }
20
-
21
- PK.prototype.hashCode = function () {
22
- var prime = 31;
23
- var result = 1;
24
- result = prime * result + this.domain;
25
- result = prime * result + this.url;
26
- return result;
27
- };
28
- PK.prototype.equals = function (other) {
29
- if(this === other) {
30
- return true;
31
- }
32
- if(other == null) {
33
- return false;
34
- }
35
- return this.domain === other.domain && this.url === other.url;
36
- };
37
-
38
-
39
- function StatTranxDomain() {
40
- if(typeof StatTranxDomain.instance === 'object') {
41
- return StatTranxDomain.instance;
42
- }
43
-
44
- this.table = new LinkedMap(TABLE_MAX_SIZE + 1 , 1).setMax(TABLE_MAX_SIZE);
45
- this.table.create = function (key) {
46
- if(this.size() >= TABLE_MAX_SIZE) {
47
- return null;
48
- }
49
- return new TimeCount();
50
- };
51
- StatTranxDomain.instance = this;
52
- }
53
-
54
- StatTranxDomain.prototype.getService = function (domain, url) {
55
- return this.table.intern(new PK(domain,url));
56
- };
57
- StatTranxDomain.prototype.add = function (domain, url, time, isErr) {
58
- try {
59
- var rec = this.getService(domain, url);
60
- if(rec) {
61
- rec.count++;
62
- if(isErr){
63
- rec.error++;
64
- }
65
- rec.toime +=time;
66
- }
67
- } catch(e) {
68
- Logger.printError("WHATAP-610", "StatTranxDomain add error", e, false);
69
- }
70
- };
71
- StatTranxDomain.prototype.send = function (now) {
72
- if(this.table.size() === 0) {
73
- return;
74
- }
75
- var rsize=this.table.size();
76
- var domain =new AnyList(AnyList.INT, rsize);
77
- var url =new AnyList(AnyList.INT, rsize);
78
- var count = new AnyList(AnyList.INT, rsize);
79
- var error = new AnyList(AnyList.INT, rsize);
80
- var time = new AnyList(AnyList.LONG, rsize);
81
-
82
- var en = this.table.entries();
83
- for (var i = 0; i<rsize && en.hasMoreElements(); i++) {
84
- var ent = en.nextElement();
85
- var k = ent.getKey();
86
- var v = ent.getValue();
87
-
88
- domain.put(i, k.domain);
89
- url.put(i, k.url);
90
- count.put(i, v.count);
91
- error.put(i, v.error);
92
- time.put(i, v.time);
93
- }
94
- this.table.clear();
95
-
96
- var out = new StatGeneralPack();
97
- out.put("domain", domain);
98
- out.put("url", url);
99
- out.put("count", count);
100
- out.put("error", error);
101
- out.put("time", time);
102
-
103
- out.id = "dom";
104
- out.time = now;
105
- DataPackSender.sendPack(out);
106
- };
107
- StatTranxDomain.prototype.clear = function () {
108
- this.table.clear();
109
- };
110
-
111
- module.exports = new StatTranxDomain();
@@ -1,112 +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 LinkedMap = require('../util/linkedmap'),
8
- AnyList = require('../util/anylist'),
9
- StatGeneralPack = require('../pack/stat-general-pack'),
10
- DataPackSender = require('../data/datapack-sender'),
11
- Logger = require('../logger'),
12
- TimeCount = require('../pack/time-count');
13
-
14
- const TABLE_MAX_SIZE = 5000;
15
-
16
- function PK(referer, url) {
17
- this.referer = referer || 0;
18
- this.url = url || 0;
19
- }
20
-
21
- PK.prototype.hashCode = function () {
22
- var prime = 31;
23
- var result = 1;
24
- result = prime * result + this.referer;
25
- result = prime * result + this.url;
26
- return result;
27
- };
28
- PK.prototype.equals = function (other) {
29
- if(this === other) {
30
- return true;
31
- }
32
- if(other == null) {
33
- return false;
34
- }
35
- return this.referer === other.referer && this.url === other.url;
36
- };
37
-
38
-
39
- function StatTranxReferer() {
40
- if(typeof StatTranxReferer.instance === 'object') {
41
- return StatTranxReferer.instance;
42
- }
43
-
44
- this.table = new LinkedMap(TABLE_MAX_SIZE + 1 , 1).setMax(TABLE_MAX_SIZE);
45
- this.table.create = function (key) {
46
- if(this.size() >= TABLE_MAX_SIZE) {
47
- return null;
48
- }
49
- return new TimeCount();
50
- };
51
- StatTranxReferer.instance = this;
52
- }
53
-
54
- StatTranxReferer.prototype.getService = function (referer, url) {
55
- return this.table.intern(new PK(referer,url));
56
- };
57
- StatTranxReferer.prototype.add = function (referer, url, time, isErr) {
58
- try {
59
- var rec = this.getService(referer, url);
60
- if(rec) {
61
- rec.count++;
62
- if(isErr){
63
- rec.error++;
64
- }
65
- rec.time +=time;
66
- }
67
- } catch(e) {
68
- Logger.printError("WHATAP-610", "StatTranxReferer add error", e, false);
69
- }
70
- };
71
- StatTranxReferer.prototype.send = function (now) {
72
- if(this.table.size() === 0) {
73
- return;
74
- }
75
- var rsize=this.table.size();
76
- var referer =new AnyList(AnyList.INT, rsize);
77
- var url =new AnyList(AnyList.INT, rsize);
78
- var count = new AnyList(AnyList.INT, rsize);
79
- var error = new AnyList(AnyList.INT, rsize);
80
- var time = new AnyList(AnyList.LONG, rsize);
81
-
82
- var en = this.table.entries();
83
- for (var i = 0; i<rsize && en.hasMoreElements(); i++) {
84
- var ent = en.nextElement();
85
- var k = ent.getKey();
86
- var v = ent.getValue();
87
-
88
- referer.put(i, k.referer);
89
- url.put(i, k.url);
90
- count.put(i, v.count);
91
- error.put(i, v.error);
92
- time.put(i, v.time);
93
- }
94
- this.table.clear();
95
-
96
- var out = new StatGeneralPack();
97
-
98
- out.put("referer", referer);
99
- out.put("url", url);
100
- out.put("count", count);
101
- out.put("error", error);
102
- out.put("time", time);
103
-
104
- out.id = "referer";
105
- out.time = now;
106
- DataPackSender.sendPack(out);
107
- };
108
- StatTranxReferer.prototype.clear = function () {
109
- this.table.clear();
110
- };
111
-
112
- module.exports = new StatTranxReferer();
@@ -1,48 +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 IntIntMap = require('../util/intint-map'),
8
- StatUserAgentPack = require('../pack/statuseragent-pack'),
9
- DataPackSender = require('../data/datapack-sender'),
10
- Long = require('long');
11
-
12
- const TABLE_MAX_SIZE = 1000;
13
-
14
- function StatUserAgent() {
15
- if(typeof StatUserAgent.instance === 'object') {
16
- return StatUserAgent.instance;
17
- }
18
-
19
- this.table = new StatUserAgentPack();
20
- this.table.userAgents.setMax(TABLE_MAX_SIZE);
21
-
22
- StatUserAgent.instance = this;
23
- }
24
-
25
- StatUserAgent.prototype.incUserAgent = function (userAgent) {
26
- if(userAgent === 0) {
27
- return;
28
- }
29
- this.table.userAgents.addNoOver(userAgent, 1);
30
- };
31
- StatUserAgent.prototype.send = function (now) {
32
- if(this.table.userAgents.size() === 0) {
33
- return;
34
- }
35
-
36
- var p = this.table;
37
- p.time = now;
38
- DataPackSender.sendStatUserAgentPack(p);
39
-
40
- this.table = new StatUserAgentPack();
41
- this.table.userAgents.setMax(TABLE_MAX_SIZE);
42
-
43
- };
44
- StatUserAgent.prototype.clear = function () {
45
- this.table.userAgents.clear();
46
- };
47
-
48
- module.exports = new StatUserAgent();
@@ -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
-
8
- var StatError = require('./stat-error'),
9
- StatTranx = require('./stat-tranx'),
10
- StatSql = require('./stat-sql'),
11
- StatHttpc = require('./stat-httpc'),
12
- StatRemoteIp = require('./stat-remote-ip'),
13
- StatRemoteIpUrl = require('./stat-remote-ipurl'),
14
- StatUserAgent = require('./stat-useragent'),
15
- StatTranxMtCaller = require('./stat-tx-caller'),
16
- StatTranxDomain = require('./stat-tx-domain'),
17
- StatTranxReferer = require('./stat-tx-referer'),
18
- Logger = require('../logger'),
19
- DateUtil = require('./../util/dateutil');
20
-
21
- const MILLIS_FIVE_MINUTE = 5 * 60 * 1000;
22
-
23
- function TimingSender(){
24
- this.time = Date.now();
25
- this.run();
26
- this.intervalIndex = undefined;
27
- }
28
- TimingSender.prototype.run = function(){
29
- var lastUnit = getCurrentFiveMinUnit();
30
- if(this.intervalIndex){
31
- clearInterval(this.intervalIndex); this.intervalIndex = undefined;
32
- }
33
-
34
- this.intervalIndex = setInterval(function () {
35
- var nowUnit = getCurrentFiveMinUnit();
36
- if(nowUnit === lastUnit) { return; }
37
- try{
38
- lastUnit = nowUnit;
39
- var now = DateUtil.currentTime();
40
- var conf = require('../conf/configure');
41
-
42
- if(conf.stat_enabled) {
43
- StatTranx.send(now);
44
- StatSql.send(now);
45
- StatHttpc.send(now);
46
- StatRemoteIp.send(now);
47
- StatRemoteIpUrl.send(now);
48
- StatUserAgent.send(now);
49
- StatError.send(now);
50
- StatTranxDomain.send(now);
51
- StatTranxMtCaller.send(now);
52
- StatTranxReferer.send(now);
53
- } else {
54
- StatTranx.clear();
55
- StatSql.clear();
56
- StatHttpc.clear();
57
- StatRemoteIp.clear();
58
- StatRemoteIpUrl.clear();
59
- StatUserAgent.clear();
60
- StatError.clear();
61
- StatTranxDomain.clear();
62
- StatTranxMtCaller.clear();
63
- StatTranxReferer.clear();
64
- }
65
- }catch(e){
66
- Logger.printError('WHATAP-997', 'TimingSender (run)', e, true);
67
- }
68
-
69
- }, 1000);
70
- };
71
-
72
- function getCurrentFiveMinUnit() {
73
- return parseInt(DateUtil.currentTime() / MILLIS_FIVE_MINUTE) * MILLIS_FIVE_MINUTE
74
- }
75
-
76
- module.exports = new TimingSender();