whatap 0.4.78 → 0.4.80

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 (216) hide show
  1. package/.vscode/keep-context.json +3 -3
  2. package/README.md +51 -51
  3. package/bindings/darwin/x64/whatap.node +0 -0
  4. package/bindings/linux/ia32/whatap.node +0 -0
  5. package/bindings/linux/x64/whatap.node +0 -0
  6. package/help.txt +10 -10
  7. package/index.js +8 -8
  8. package/lib/conf/conf-sys-mon.js +100 -100
  9. package/lib/conf/config-default.js +238 -238
  10. package/lib/conf/configure.js +423 -423
  11. package/lib/conf/license.js +41 -41
  12. package/lib/control/cmd-config.js +23 -23
  13. package/lib/control/control-handler.js +344 -344
  14. package/lib/control/packagectr-helper.js +149 -149
  15. package/lib/core/agent.js +329 -328
  16. package/lib/core/interceptor.js +142 -142
  17. package/lib/core/request-agent.js +26 -26
  18. package/lib/counter/counter-manager.js +127 -127
  19. package/lib/counter/meter/meter-activex.js +66 -66
  20. package/lib/counter/meter/meter-httpc.js +57 -57
  21. package/lib/counter/meter/meter-resource.js +9 -9
  22. package/lib/counter/meter/meter-service.js +167 -167
  23. package/lib/counter/meter/meter-socket.io.js +50 -50
  24. package/lib/counter/meter/meter-sql.js +70 -70
  25. package/lib/counter/meter/meter-users.js +57 -57
  26. package/lib/counter/meter.js +183 -183
  27. package/lib/counter/task/activetransaction.js +93 -93
  28. package/lib/counter/task/agentinfo.js +105 -105
  29. package/lib/counter/task/counter-task.js +9 -9
  30. package/lib/counter/task/gcstat.js +34 -34
  31. package/lib/counter/task/heapmem.js +24 -24
  32. package/lib/counter/task/httpc.js +75 -75
  33. package/lib/counter/task/proc-cpu.js +28 -28
  34. package/lib/counter/task/realtimeuser.js +30 -30
  35. package/lib/counter/task/res/systemECSTask.js +54 -54
  36. package/lib/counter/task/res/systemKubeTask.js +52 -52
  37. package/lib/counter/task/res/util/awsEcsClientThread.js +166 -166
  38. package/lib/counter/task/res/util/linuxProcStatUtil.js +13 -13
  39. package/lib/counter/task/res-sys-cpu.js +61 -61
  40. package/lib/counter/task/service.js +201 -201
  41. package/lib/counter/task/socketio.js +29 -29
  42. package/lib/counter/task/sql.js +104 -104
  43. package/lib/counter/task/systemperf.js +42 -42
  44. package/lib/data/datapack-sender.js +256 -256
  45. package/lib/data/dataprofile-agent.js +136 -136
  46. package/lib/data/datatext-agent.js +135 -135
  47. package/lib/data/event-level.js +15 -15
  48. package/lib/data/test.js +48 -48
  49. package/lib/env/constants.js +20 -20
  50. package/lib/kube/kube-client.js +143 -143
  51. package/lib/lang/text-types.js +58 -58
  52. package/lib/logger.js +319 -319
  53. package/lib/net/netflag.js +54 -54
  54. package/lib/net/paramdef.js +40 -40
  55. package/lib/net/receiver.js +65 -65
  56. package/lib/net/security-master.js +182 -173
  57. package/lib/net/sender.js +140 -140
  58. package/lib/net/tcp-return.js +17 -17
  59. package/lib/net/tcp-session.js +285 -285
  60. package/lib/net/tcpreq-client-proxy.js +69 -69
  61. package/lib/net/tcprequest-mgr.js +57 -57
  62. package/lib/observers/cluster-observer.js +21 -21
  63. package/lib/observers/express-observer.js +214 -214
  64. package/lib/observers/file-observer.js +184 -184
  65. package/lib/observers/global-observer.js +30 -30
  66. package/lib/observers/http-observer.js +704 -704
  67. package/lib/observers/maria-observer.js +382 -382
  68. package/lib/observers/memcached-observer.js +55 -55
  69. package/lib/observers/mongo-observer.js +262 -265
  70. package/lib/observers/mongodb-observer.js +197 -197
  71. package/lib/observers/mongoose-observer.js +83 -83
  72. package/lib/observers/mssql-observer.js +205 -205
  73. package/lib/observers/mysql-observer.js +436 -394
  74. package/lib/observers/net-observer.js +72 -72
  75. package/lib/observers/pgsql-observer.js +295 -295
  76. package/lib/observers/process-observer.js +25 -25
  77. package/lib/observers/promise-observer.js +31 -31
  78. package/lib/observers/redis-observer.js +156 -109
  79. package/lib/observers/schedule-observer.js +66 -66
  80. package/lib/observers/socket.io-observer.js +54 -54
  81. package/lib/observers/stream-observer.js +19 -19
  82. package/lib/observers/thrift-observer.js +196 -196
  83. package/lib/pack/activestack-pack.js +54 -54
  84. package/lib/pack/counter-pack.js +649 -649
  85. package/lib/pack/errorsnap-pack.js +68 -68
  86. package/lib/pack/event-pack.js +53 -53
  87. package/lib/pack/hitmap-pack.js +62 -62
  88. package/lib/pack/hitmap-pack1.js +146 -146
  89. package/lib/pack/netstat.js +14 -14
  90. package/lib/pack/pack.js +49 -49
  91. package/lib/pack/packenum.js +60 -60
  92. package/lib/pack/param-pack.js +213 -213
  93. package/lib/pack/profile-pack.js +48 -48
  94. package/lib/pack/realtimeuser-pack.js +40 -40
  95. package/lib/pack/stat-general-pack.js +95 -95
  96. package/lib/pack/staterror-pack.js +119 -119
  97. package/lib/pack/stathttpc-pack.js +66 -66
  98. package/lib/pack/stathttpc-rec.js +78 -78
  99. package/lib/pack/statremote-pack.js +45 -45
  100. package/lib/pack/statservice-pack.js +62 -62
  101. package/lib/pack/statservice-pack1.js +87 -87
  102. package/lib/pack/statservice-rec.js +292 -292
  103. package/lib/pack/statservice-rec_dep.js +151 -151
  104. package/lib/pack/statsql-pack.js +69 -69
  105. package/lib/pack/statsql-rec.js +100 -100
  106. package/lib/pack/statuseragent-pack.js +43 -43
  107. package/lib/pack/tagcount-pack.js +398 -398
  108. package/lib/pack/tagctr.js +14 -14
  109. package/lib/pack/text-pack.js +49 -49
  110. package/lib/pack/time-count.js +25 -25
  111. package/lib/pack/websocket.js +14 -14
  112. package/lib/plugin/plugin-loadermanager.js +56 -56
  113. package/lib/plugin/plugin.js +75 -75
  114. package/lib/requestlog.js +326 -326
  115. package/lib/service/tx-record.js +288 -284
  116. package/lib/stat/stat-error.js +116 -116
  117. package/lib/stat/stat-httpc.js +97 -97
  118. package/lib/stat/stat-remoteip.js +46 -46
  119. package/lib/stat/stat-sql.js +112 -112
  120. package/lib/stat/stat-tranx.js +57 -57
  121. package/lib/stat/stat-tx-caller.js +159 -159
  122. package/lib/stat/stat-tx-domain.js +110 -110
  123. package/lib/stat/stat-tx-referer.js +111 -111
  124. package/lib/stat/stat-useragent.js +48 -48
  125. package/lib/stat/timingsender.js +72 -72
  126. package/lib/step/activestack-step.js +37 -37
  127. package/lib/step/dbc-step.js +35 -35
  128. package/lib/step/http-stepx.js +66 -66
  129. package/lib/step/message-step.js +39 -39
  130. package/lib/step/method-stepx.js +46 -46
  131. package/lib/step/resultset-step.js +39 -39
  132. package/lib/step/securemsg-step.js +43 -43
  133. package/lib/step/socket-step.js +46 -46
  134. package/lib/step/sql-stepx.js +67 -67
  135. package/lib/step/sqlxtype.js +15 -15
  136. package/lib/step/step.js +65 -65
  137. package/lib/step/stepenum.js +53 -53
  138. package/lib/trace/local-context.js +13 -13
  139. package/lib/trace/parsed-sql.js +13 -13
  140. package/lib/trace/profile-collector.js +70 -70
  141. package/lib/trace/serviceurl-pattern-detector.js +117 -117
  142. package/lib/trace/trace-context-manager.js +195 -195
  143. package/lib/trace/trace-context.js +134 -134
  144. package/lib/util/anylist.js +102 -102
  145. package/lib/util/array-util.js +100 -100
  146. package/lib/util/bitutil.js +27 -27
  147. package/lib/util/cardinality/hyperloglog.js +105 -105
  148. package/lib/util/cardinality/murmurhash.js +31 -31
  149. package/lib/util/cardinality/registerset.js +74 -74
  150. package/lib/util/config-util.js +17 -17
  151. package/lib/util/cypher.js +89 -89
  152. package/lib/util/datetimehelper.js +237 -229
  153. package/lib/util/dateutil.js +110 -106
  154. package/lib/util/errordata.js +20 -20
  155. package/lib/util/escape-literal-sql.js +342 -342
  156. package/lib/util/hashutil2.js +126 -126
  157. package/lib/util/hexa32.js +57 -57
  158. package/lib/util/index.js +78 -78
  159. package/lib/util/intint-map.js +47 -47
  160. package/lib/util/intkey-linkedmap.js +26 -26
  161. package/lib/util/intkey-map.js +25 -25
  162. package/lib/util/intset.js +82 -82
  163. package/lib/util/iputil.js +119 -119
  164. package/lib/util/iputil_x.js +526 -526
  165. package/lib/util/keygen.js +17 -17
  166. package/lib/util/kube-util.js +72 -72
  167. package/lib/util/longint-linkedmap.js +35 -35
  168. package/lib/util/longkey-linkedmap.js +25 -25
  169. package/lib/util/longlong-linkedmap.js +37 -37
  170. package/lib/util/nodeutil.js +67 -67
  171. package/lib/util/oidutil.js +96 -93
  172. package/lib/util/paramsecurity.js +78 -78
  173. package/lib/util/pathtree.js +172 -172
  174. package/lib/util/pre-process.js +13 -13
  175. package/lib/util/process-seq.js +165 -165
  176. package/lib/util/property-util.js +35 -35
  177. package/lib/util/request-queue.js +42 -42
  178. package/lib/util/requestdouble-queue.js +72 -72
  179. package/lib/util/resourceprofile.js +156 -156
  180. package/lib/util/seedrandom.js +242 -242
  181. package/lib/util/stop-watch.js +29 -29
  182. package/lib/util/string-util.js +9 -9
  183. package/lib/util/stringkey-linkedmap.js +28 -28
  184. package/lib/util/stringnum-linkedmap.js +31 -31
  185. package/lib/util/stringset.js +65 -65
  186. package/lib/util/system-util.js +9 -9
  187. package/lib/util/userid-util.js +57 -57
  188. package/lib/util/utils.js +67 -67
  189. package/lib/value/blob-value.js +61 -61
  190. package/lib/value/boolean-value.js +51 -51
  191. package/lib/value/decimal-value.js +71 -71
  192. package/lib/value/double-summary.js +105 -105
  193. package/lib/value/double-value.js +50 -50
  194. package/lib/value/float-array.js +59 -59
  195. package/lib/value/float-value.js +64 -64
  196. package/lib/value/int-array.js +59 -59
  197. package/lib/value/int-map-value.js +151 -151
  198. package/lib/value/int-value.js +64 -64
  199. package/lib/value/ip4-value.js +83 -83
  200. package/lib/value/list-value.js +136 -136
  201. package/lib/value/long-array.js +59 -59
  202. package/lib/value/long-summary.js +105 -105
  203. package/lib/value/map-value.js +175 -175
  204. package/lib/value/metric-value.js +157 -157
  205. package/lib/value/null-value.js +42 -42
  206. package/lib/value/number-value.js +34 -34
  207. package/lib/value/summary-value.js +29 -29
  208. package/lib/value/text-array.js +117 -117
  209. package/lib/value/text-value.js +59 -59
  210. package/lib/value/texthash-value.js +49 -49
  211. package/lib/value/value.js +14 -14
  212. package/lib/value/valueenum.js +99 -99
  213. package/logs/whatap-20230906.log +54 -0
  214. package/package.json +28 -28
  215. package/whatap.conf +1 -1
  216. package/logs/whatap-20230616.log +0 -13
@@ -1,174 +1,183 @@
1
- /**
2
- * Copyright 2016 the WHATAP project authors. All rights reserved.
3
- * Use of this source code is governed by a license that
4
- * can be found in the LICENSE file.
5
- */
6
-
7
- var DataInputX = require('./../io/data-inputx'),
8
- License = require('./../conf/license'),
9
- Cypher = require('./../util/cypher'),
10
- IPUtil = require('./../util/iputil'),
11
- OidUtil = require('./../util/oidutil'),
12
- ProcessSeq = require('./../util/process-seq'),
13
- HashUtil = require('./../util/hashutil');
14
-
15
- var cluster = require('cluster');
16
-
17
- var lastOid = 0;
18
-
19
- var SecurityMaster = {
20
- ONAME: '',
21
- IP: 0,
22
- PCODE: 0,
23
- OKIND : 0,
24
- OKIND_NAME : null,
25
- ONODE : 0,
26
- ONODE_NAME : null,
27
- OID: 0 ,
28
- run : function(cb){
29
- var conf = require('./../conf/configure');
30
- if( this.resetLicense( conf.license )) {
31
- require('../logger').print('WHATAP-110', "[pcode=" + this.PCODE
32
- + ",SECURE_KEY=" + this.SECURE_KEY.toString('hex')
33
- + "]", false);
34
- this.getClusterId(cb);
35
- } else {
36
- if(cb) cb(new Error('Invalid license'));
37
- }
38
- },
39
- resetLicense: function(lic /* String */){
40
- try {
41
- var key = License.getKey(lic);
42
- if(key.pcode == null || key.security_key == null) {
43
- throw new Error('Invalid license');
44
- }
45
- this.PCODE = key.pcode;
46
- this.SECURE_KEY = key.security_key;
47
- this.cypher = new Cypher(this.SECURE_KEY, 0);
48
- return true;
49
- } catch(e) {
50
- require('../logger').printError('WHATAP-606', 'LicenseKey is invalid ' + lic, e, true);
51
- }
52
- return false;
53
- },
54
- updateLocalIp: function(myIp){
55
- process.env["whatap.ip"] = myIp;
56
- this.IP = 0;
57
- },
58
- decideAgentOnameOid: function(myIp) {
59
- var Configuration = require('./../conf/configure');
60
- Configuration.setProperty('whatap.ip', myIp);
61
-
62
- this.IP = IPUtil.stringToInt(myIp);
63
- var port = Configuration.getProperty("whatap.port");
64
- OidUtil.setIp(IPUtil.intToString(this.IP));
65
- OidUtil.setPort(port);
66
- OidUtil.setPid(process.pid);
67
- OidUtil.setHostName(require('os').hostname());
68
- //OidUtil.setType(Configuration.getProperty("whatap.type", "NODE"));
69
- OidUtil.setType(process.env.name || Configuration.getProperty("whatap.type", "NODE"));
70
-
71
- var name_pattern;
72
- if(require('cluster').isMaster){
73
- name_pattern=process.env.WHATAP_NAME || "{type}-{ip2}-{ip3}";
74
- }else{
75
- name_pattern=process.env.WHATAP_NAME || "{type}{cluster}-{ip2}-{ip3}";
76
- var cid = Configuration.getProperty('node.clusterId');
77
- OidUtil.setCluster(cid);
78
- }
79
-
80
- var okindStr= process.env.WHATAP_OKIND || Configuration.getProperty('whatap.okind');
81
- if(okindStr && okindStr.length>0){
82
- this.OKIND = HashUtil.hashFromString(okindStr);
83
- this.OKIND_NAME=okindStr;
84
- }else{
85
- this.OKIND = 0;
86
- this.OKIND_NAME=null;
87
- }
88
-
89
- var onodeStr= process.env.WHATAP_ONODE || Configuration.getProperty('whatap.onode');
90
- if(onodeStr && onodeStr.length>0){
91
- this.ONODE = HashUtil.hashFromString(onodeStr);
92
- this.ONODE_NAME=onodeStr;
93
- }else{
94
- this.ONODE = 0;
95
- this.ONODE_NAME=null;
96
- }
97
-
98
- //OidUtil.setCmd(Configuration.getProperty("sun.java.command"));
99
- this.ONAME = OidUtil.mkOname(Configuration.getProperty("whatap.name", name_pattern));
100
- this.OID = OidUtil.mkOid(this.ONAME);
101
-
102
- if (lastOid != this.OID) {
103
- lastOid = this.OID;
104
- require('../logger').print('WHATAP-968', "OID: " + this.OID + " ONAME: " + this.ONAME + " IP: " + IPUtil.intToString(this.IP), false);
105
- }
106
- },
107
- setAgentOnameOid :function (oname, myIp) {
108
- var Configuration = require('./../conf/configure');
109
- Configuration.setProperty('whatap.ip', myIp);
110
-
111
- this.IP = IPUtil.stringToInt(myIp);//DataInputX.toInt(IPUtil.toBytes(myIp), 0);
112
- var port = Configuration.getProperty("whatap.port");
113
- OidUtil.setIp(IPUtil.intToString(this.IP));
114
- OidUtil.setPort(port);
115
- OidUtil.setPid(process.pid);
116
- OidUtil.setHostName(require('os').hostname());
117
- if(require('cluster').isMaster){
118
- OidUtil.setType(Configuration.getProperty("whatap.type", "NODE"));
119
- }else{
120
- OidUtil.setType(Configuration.getProperty("whatap.type", "NODE"+ Configuration.getProperty('node.clusterId') ) );
121
- }
122
-
123
- OidUtil.setCmd(Configuration.getProperty("sun.java.command"));
124
- this.ONAME = oname;
125
- this.OID = OidUtil.mkOid(this.ONAME);
126
-
127
- var okindStr= process.env.WHATAP_OKIND || Configuration.getProperty('whatap.okind');
128
- if(okindStr && okindStr.length>0){
129
- this.OKIND = HashUtil.hashFromString(okindStr);
130
- this.OKIND_NAME=okindStr;
131
- }else{
132
- this.OKIND = 0;
133
- this.OKIND_NAME=null;
134
- }
135
- var onodeStr= process.env.WHATAP_ONODE || Configuration.getProperty('whatap.onode');
136
- if(onodeStr && onodeStr.length>0){
137
- this.ONODE = HashUtil.hashFromString(onodeStr);
138
- this.ONODE_NAME=onodeStr;
139
- }else{
140
- this.ONODE = 0;
141
- this.ONODE_NAME=null;
142
- }
143
-
144
- if (lastOid != this.OID) {
145
- lastOid = this.OID;
146
- require('../logger').print('WHATAP-168', "OID: " + this.OID + " ONAME: " + this.ONAME + " IP: " + IPUtil.intToString(this.IP), false);
147
- }
148
- },
149
- getClusterId: function(cb){
150
- var conf = require('./../conf/configure');
151
- if(cluster.isMaster){
152
- //console.log('현재 프로젝트는 MASTER 입니다!!!!');
153
- conf.setProperty('node.clusterId', '');
154
- if(cb) cb();
155
- }else{
156
- conf.setProperty('node.clusterId', cluster.worker.id);
157
- if(cb) cb();
158
- //console.log('현재 프로젝트는 ' + cluster.worker.id + ' 입니다!!!!');
159
- /*
160
- ProcessSeq('whatap').accessAuth(function(pseq){
161
- if(!pseq){
162
- return;
163
- }
164
- var conf = require('./../conf/configure');
165
- conf.setProperty('node.clusterId', pseq);
166
- if(cb) cb();
167
- });
168
- */
169
- }
170
-
171
- }
172
- };
173
-
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 DataInputX = require('./../io/data-inputx'),
8
+ License = require('./../conf/license'),
9
+ Cypher = require('./../util/cypher'),
10
+ IPUtil = require('./../util/iputil'),
11
+ OidUtil = require('./../util/oidutil'),
12
+ ProcessSeq = require('./../util/process-seq'),
13
+ HashUtil = require('./../util/hashutil');
14
+
15
+ var cluster = require('cluster');
16
+ const Configuration = require("../conf/configure");
17
+
18
+ var lastOid = 0;
19
+
20
+ var SecurityMaster = {
21
+ ONAME: '',
22
+ IP: 0,
23
+ PCODE: 0,
24
+ OKIND : 0,
25
+ OKIND_NAME : null,
26
+ ONODE : 0,
27
+ ONODE_NAME : null,
28
+ OID: 0 ,
29
+ run : function(cb){
30
+ var conf = require('./../conf/configure');
31
+ if( this.resetLicense( conf.license )) {
32
+ require('../logger').print('WHATAP-110', "[pcode=" + this.PCODE
33
+ + ",SECURE_KEY=" + this.SECURE_KEY.toString('hex')
34
+ + "]", false);
35
+ this.getClusterId(cb);
36
+ } else {
37
+ if(cb) cb(new Error('Invalid license'));
38
+ }
39
+ },
40
+ resetLicense: function(lic /* String */){
41
+ try {
42
+ var key = License.getKey(lic);
43
+ if(key.pcode == null || key.security_key == null) {
44
+ throw new Error('Invalid license');
45
+ }
46
+ this.PCODE = key.pcode;
47
+ this.SECURE_KEY = key.security_key;
48
+ this.cypher = new Cypher(this.SECURE_KEY, 0);
49
+ return true;
50
+ } catch(e) {
51
+ require('../logger').printError('WHATAP-606', 'LicenseKey is invalid ' + lic, e, true);
52
+ }
53
+ return false;
54
+ },
55
+ updateLocalIp: function(myIp){
56
+ process.env["whatap.ip"] = myIp;
57
+ this.IP = 0;
58
+ },
59
+ decideAgentOnameOid: function(myIp) {
60
+ var Configuration = require('./../conf/configure');
61
+ Configuration.setProperty('whatap.ip', myIp);
62
+
63
+ this.IP = IPUtil.stringToInt(myIp);
64
+ var port = Configuration.getProperty("whatap.port");
65
+ OidUtil.setIp(IPUtil.intToString(this.IP));
66
+ OidUtil.setPort(port);
67
+ OidUtil.setPid(process.pid);
68
+ OidUtil.setHostName(require('os').hostname());
69
+ //OidUtil.setType(Configuration.getProperty("whatap.type", "NODE"));
70
+ OidUtil.setType(process.env.name || Configuration.getProperty("whatap.type", "NODE"));
71
+
72
+ var name_pattern;
73
+ if(Configuration.getProperty('whatap_micro_enabled') === true){
74
+ name_pattern = process.env.WHATAP_NAME || "{okind}-{ip2}-{ip3}";
75
+ }else if(require('cluster').isMaster){
76
+ name_pattern=process.env.WHATAP_NAME || "{type}-{ip2}-{ip3}";
77
+ }else{
78
+ name_pattern=process.env.WHATAP_NAME || "{type}{cluster}-{ip2}-{ip3}";
79
+ var cid = Configuration.getProperty('node.clusterId');
80
+ OidUtil.setCluster(cid);
81
+ }
82
+
83
+ var okindStr= process.env.WHATAP_OKIND || Configuration.getProperty('whatap.okind');
84
+ if(okindStr && okindStr.length>0){
85
+ this.OKIND = HashUtil.hashFromString(okindStr);
86
+ this.OKIND_NAME=okindStr;
87
+ OidUtil.setOkind(okindStr);
88
+ }else{
89
+ this.OKIND = 0;
90
+ this.OKIND_NAME=null;
91
+ }
92
+
93
+ if(Configuration.getProperty('whatap_micro_enabled') === false) {
94
+ var onodeStr= process.env.WHATAP_ONODE || Configuration.getProperty('whatap.onode');
95
+ if(onodeStr && onodeStr.length>0){
96
+ this.ONODE = HashUtil.hashFromString(onodeStr);
97
+ this.ONODE_NAME=onodeStr;
98
+ }else{
99
+ this.ONODE = 0;
100
+ this.ONODE_NAME=null;
101
+ }
102
+ }
103
+
104
+ //OidUtil.setCmd(Configuration.getProperty("sun.java.command"));
105
+ this.ONAME = OidUtil.mkOname(Configuration.getProperty("whatap.name", name_pattern));
106
+ this.OID = OidUtil.mkOid(this.ONAME);
107
+
108
+ if (lastOid != this.OID) {
109
+ lastOid = this.OID;
110
+ require('../logger').print('WHATAP-968', "OID: " + this.OID + " ONAME: " + this.ONAME + " IP: " + IPUtil.intToString(this.IP), false);
111
+ }
112
+ },
113
+ setAgentOnameOid :function (oname, myIp) {
114
+ var Configuration = require('./../conf/configure');
115
+ Configuration.setProperty('whatap.ip', myIp);
116
+
117
+ this.IP = IPUtil.stringToInt(myIp);//DataInputX.toInt(IPUtil.toBytes(myIp), 0);
118
+ var port = Configuration.getProperty("whatap.port");
119
+ OidUtil.setIp(IPUtil.intToString(this.IP));
120
+ OidUtil.setPort(port);
121
+ OidUtil.setPid(process.pid);
122
+ OidUtil.setHostName(require('os').hostname());
123
+ if(require('cluster').isMaster){
124
+ OidUtil.setType(Configuration.getProperty("whatap.type", "NODE"));
125
+ }else{
126
+ OidUtil.setType(Configuration.getProperty("whatap.type", "NODE"+ Configuration.getProperty('node.clusterId') ) );
127
+ }
128
+
129
+ OidUtil.setCmd(Configuration.getProperty("sun.java.command"));
130
+ this.ONAME = oname;
131
+ this.OID = OidUtil.mkOid(this.ONAME);
132
+
133
+ var okindStr= process.env.WHATAP_OKIND || Configuration.getProperty('whatap.okind');
134
+ if(okindStr && okindStr.length>0){
135
+ this.OKIND = HashUtil.hashFromString(okindStr);
136
+ this.OKIND_NAME=okindStr;
137
+ }else{
138
+ this.OKIND = 0;
139
+ this.OKIND_NAME=null;
140
+ }
141
+
142
+ if(Configuration.getProperty('whatap_micro_enabled') === false) {
143
+ var onodeStr= process.env.WHATAP_ONODE || Configuration.getProperty('whatap.onode');
144
+ if(onodeStr && onodeStr.length>0){
145
+ this.ONODE = HashUtil.hashFromString(onodeStr);
146
+ this.ONODE_NAME=onodeStr;
147
+ }else{
148
+ this.ONODE = 0;
149
+ this.ONODE_NAME=null;
150
+ }
151
+ }
152
+
153
+ if (lastOid != this.OID) {
154
+ lastOid = this.OID;
155
+ require('../logger').print('WHATAP-168', "OID: " + this.OID + " ONAME: " + this.ONAME + " IP: " + IPUtil.intToString(this.IP), false);
156
+ }
157
+ },
158
+ getClusterId: function(cb){
159
+ var conf = require('./../conf/configure');
160
+ if(cluster.isMaster){
161
+ //console.log('현재 프로젝트는 MASTER 입니다!!!!');
162
+ conf.setProperty('node.clusterId', '');
163
+ if(cb) cb();
164
+ }else{
165
+ conf.setProperty('node.clusterId', cluster.worker.id);
166
+ if(cb) cb();
167
+ //console.log('현재 프로젝트는 ' + cluster.worker.id + ' 입니다!!!!');
168
+ /*
169
+ ProcessSeq('whatap').accessAuth(function(pseq){
170
+ if(!pseq){
171
+ return;
172
+ }
173
+ var conf = require('./../conf/configure');
174
+ conf.setProperty('node.clusterId', pseq);
175
+ if(cb) cb();
176
+ });
177
+ */
178
+ }
179
+
180
+ }
181
+ };
182
+
174
183
  module.exports = SecurityMaster;
package/lib/net/sender.js CHANGED
@@ -1,141 +1,141 @@
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
- DataOutputX = require('./../io/data-outputx'),
9
- EventPack = require('./../pack/event-pack'),
10
- PackEnum = require('./../pack/packenum'),
11
- EventLevel = require('./../data/event-level'),
12
- NetFlag = require('./netflag').NetFlag,
13
- TcpSession = require('./tcp-session'),
14
- Logger = require('../logger'),
15
- Long = require('long');
16
-
17
- var Sender = function(agent, requestMgr){
18
- this._agent = agent;
19
- this._mgr = requestMgr;
20
- this.next_time_sync = Date.now() + conf.getProperty('time_sync_interval_ms', 300000);
21
- this.isProcessing = false;
22
- this.ddd=Date.now()%100000;
23
- };
24
-
25
- Sender.prototype.startCheckQueue = function(){
26
- var self = this;
27
- if(this._interval) return;
28
- this.cypher_level = conf.cypher_level;
29
- this._interval = setInterval(function(){
30
- self.start();
31
- }, 100, 'whatap');
32
- };
33
- Sender.prototype.stopCheckQueue = function(){
34
- if(this._interval){
35
- clearInterval(this._interval);
36
- delete this._interval;
37
- }
38
- };
39
- Sender.prototype.start = function(){
40
- var self = this;
41
- this.isProcessing = true;
42
- var hasNext = self._mgr.pool.hasNext();
43
-
44
- if(!hasNext) {
45
- if(this._interval){
46
- return ;
47
- }else{
48
- this.startCheckQueue();
49
- }
50
- }
51
- this.stopCheckQueue();
52
- self.send();
53
-
54
- };
55
-
56
- Sender.prototype.send = function(){
57
- var self = this;
58
- var w = TcpSession;
59
- var p = self._mgr.pool.get();
60
- if(p == null) {return this.startCheckQueue();}
61
- if(w.out == null) {return this.startCheckQueue();}
62
-
63
- if(this.cypher_level != conf.cypher_level) {
64
- this.cypher_level = conf.cypher_level;
65
- w.close();
66
- return;
67
- }
68
- var len = 0;
69
- try{
70
- var now = Date.now();
71
- if( now > self.next_time_sync ){
72
- self.next_time_sync = now + conf.getProperty('time_sync_interval_ms', 300000);
73
- w.send(NetFlag.TIME_SYNC, DataOutputX.toBytesLong(Long.fromValue(now)));
74
- }
75
- if(conf.debug_tcpsend){
76
- try{
77
- var qsize=JSON.stringify(self._mgr.pool.size());
78
- var packName= PackEnum.PACK_NAME[p.pack.getPackType()] ;
79
- var m = packName + "\t" +qsize;
80
- Logger.printAll("TCPSEND", m);
81
- }catch(e){
82
- Logger.printError('WHATAP-251', 'Sender(send)', e);
83
- }
84
- }
85
-
86
- p.pack.apType = 2;
87
-
88
- if(conf.cypher_level == 0){
89
- var b = DataOutputX.toBytesPack(p.pack);
90
- w.send(p.flag, b);
91
- len = b.length;
92
- } else {
93
- switch( NetFlag.getSecureMask(p.flag) ) {
94
- case NetFlag.SECURE_HIDE:
95
- if(conf.cypher != null){
96
- var b = DataOutputX.toBytesPack(p.pack);
97
- b = conf.cypher.hide(b);
98
- len = b.length;
99
- w.send(p.flag, b);
100
- }
101
- break;
102
- case NetFlag.SECURE_CYPHER:
103
- if(conf.cypher !== null){
104
- var b = DataOutputX.toBytesPack(p.pack, conf.cypher_level / 8);
105
- b = conf.cypher.encryptBlock(b);
106
- len = b.length;
107
- w.send(p.flag, b);
108
- }
109
- break;
110
- default:
111
- var b = DataOutputX.toBytesPack(p.pack);
112
- w.send(p.flag, b);
113
- len = b.length;
114
- break;
115
- }
116
- }
117
-
118
- if(len > conf.net_send_max_bytes){
119
- var e = new EventPack();
120
- e.level = EventLevel.FATAL;
121
- errorOverflow(p.pack.constructor + '('+ p.pack.getPackType() + ')');
122
- return;
123
- }
124
-
125
- self._mgr.sendBytes += len;
126
- self._mgr.sendPack++;
127
- } catch(e) {
128
- Logger.printError('WHATAP-121', 'Sender error', e);
129
- }
130
-
131
- process.nextTick(function(){
132
- self.start();
133
- });
134
- };
135
- var errorOverflow = function(packName){
136
- var e = new EventPack();
137
- e.title = "NEW_OVERFLOW";
138
- e.message = "Too big data: " + packName;
139
- };
140
- //PackEnum.PACK_NAME[p.pack.getPackType()]
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
+ DataOutputX = require('./../io/data-outputx'),
9
+ EventPack = require('./../pack/event-pack'),
10
+ PackEnum = require('./../pack/packenum'),
11
+ EventLevel = require('./../data/event-level'),
12
+ NetFlag = require('./netflag').NetFlag,
13
+ TcpSession = require('./tcp-session'),
14
+ Logger = require('../logger'),
15
+ Long = require('long');
16
+
17
+ var Sender = function(agent, requestMgr){
18
+ this._agent = agent;
19
+ this._mgr = requestMgr;
20
+ this.next_time_sync = Date.now() + conf.getProperty('time_sync_interval_ms', 300000);
21
+ this.isProcessing = false;
22
+ this.ddd=Date.now()%100000;
23
+ };
24
+
25
+ Sender.prototype.startCheckQueue = function(){
26
+ var self = this;
27
+ if(this._interval) return;
28
+ this.cypher_level = conf.cypher_level;
29
+ this._interval = setInterval(function(){
30
+ self.start();
31
+ }, 100, 'whatap');
32
+ };
33
+ Sender.prototype.stopCheckQueue = function(){
34
+ if(this._interval){
35
+ clearInterval(this._interval);
36
+ delete this._interval;
37
+ }
38
+ };
39
+ Sender.prototype.start = function(){
40
+ var self = this;
41
+ this.isProcessing = true;
42
+ var hasNext = self._mgr.pool.hasNext();
43
+
44
+ if(!hasNext) {
45
+ if(this._interval){
46
+ return ;
47
+ }else{
48
+ this.startCheckQueue();
49
+ }
50
+ }
51
+ this.stopCheckQueue();
52
+ self.send();
53
+
54
+ };
55
+
56
+ Sender.prototype.send = function(){
57
+ var self = this;
58
+ var w = TcpSession;
59
+ var p = self._mgr.pool.get();
60
+ if(p == null) {return this.startCheckQueue();}
61
+ if(w.out == null) {return this.startCheckQueue();}
62
+
63
+ if(this.cypher_level != conf.cypher_level) {
64
+ this.cypher_level = conf.cypher_level;
65
+ w.close();
66
+ return;
67
+ }
68
+ var len = 0;
69
+ try{
70
+ var now = Date.now();
71
+ if( now > self.next_time_sync ){
72
+ self.next_time_sync = now + conf.getProperty('time_sync_interval_ms', 300000);
73
+ w.send(NetFlag.TIME_SYNC, DataOutputX.toBytesLong(Long.fromValue(now)));
74
+ }
75
+ if(conf.debug_tcpsend){
76
+ try{
77
+ var qsize=JSON.stringify(self._mgr.pool.size());
78
+ var packName= PackEnum.PACK_NAME[p.pack.getPackType()] ;
79
+ var m = packName + "\t" +qsize;
80
+ Logger.printAll("TCPSEND", m);
81
+ }catch(e){
82
+ Logger.printError('WHATAP-251', 'Sender(send)', e);
83
+ }
84
+ }
85
+
86
+ p.pack.apType = 2;
87
+
88
+ if(conf.cypher_level == 0){
89
+ var b = DataOutputX.toBytesPack(p.pack);
90
+ w.send(p.flag, b);
91
+ len = b.length;
92
+ } else {
93
+ switch( NetFlag.getSecureMask(p.flag) ) {
94
+ case NetFlag.SECURE_HIDE:
95
+ if(conf.cypher != null){
96
+ var b = DataOutputX.toBytesPack(p.pack);
97
+ b = conf.cypher.hide(b);
98
+ len = b.length;
99
+ w.send(p.flag, b);
100
+ }
101
+ break;
102
+ case NetFlag.SECURE_CYPHER:
103
+ if(conf.cypher !== null){
104
+ var b = DataOutputX.toBytesPack(p.pack, conf.cypher_level / 8);
105
+ b = conf.cypher.encryptBlock(b);
106
+ len = b.length;
107
+ w.send(p.flag, b);
108
+ }
109
+ break;
110
+ default:
111
+ var b = DataOutputX.toBytesPack(p.pack);
112
+ w.send(p.flag, b);
113
+ len = b.length;
114
+ break;
115
+ }
116
+ }
117
+
118
+ if(len > conf.net_send_max_bytes){
119
+ var e = new EventPack();
120
+ e.level = EventLevel.FATAL;
121
+ errorOverflow(p.pack.constructor + '('+ p.pack.getPackType() + ')');
122
+ return;
123
+ }
124
+
125
+ self._mgr.sendBytes += len;
126
+ self._mgr.sendPack++;
127
+ } catch(e) {
128
+ Logger.printError('WHATAP-121', 'Sender error', e);
129
+ }
130
+
131
+ process.nextTick(function(){
132
+ self.start();
133
+ });
134
+ };
135
+ var errorOverflow = function(packName){
136
+ var e = new EventPack();
137
+ e.title = "NEW_OVERFLOW";
138
+ e.message = "Too big data: " + packName;
139
+ };
140
+ //PackEnum.PACK_NAME[p.pack.getPackType()]
141
141
  module.exports = Sender;