whatap 0.4.97 → 0.5.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 (39) hide show
  1. package/lib/conf/config-default.js +11 -3
  2. package/lib/conf/configure.js +32 -19
  3. package/lib/conf/log-config-default.js +37 -0
  4. package/lib/control/control-handler.js +19 -6
  5. package/lib/core/agent.js +12 -9
  6. package/lib/core/shimmer.js +98 -0
  7. package/lib/counter/task/agentinfo.js +1 -1
  8. package/lib/data/datapack-sender.js +22 -0
  9. package/lib/data/dataprofile-agent.js +17 -1
  10. package/lib/data/zipprofile.js +2 -2
  11. package/lib/logger.js +25 -1
  12. package/lib/logsink/line-log-util.js +87 -0
  13. package/lib/logsink/line-log.js +12 -0
  14. package/lib/logsink/log-sender.js +78 -0
  15. package/lib/logsink/log-tracer.js +40 -0
  16. package/lib/logsink/sender-util.js +51 -0
  17. package/lib/logsink/zip/zip-send.js +177 -0
  18. package/lib/net/paramdef.js +1 -0
  19. package/lib/net/security-master.js +10 -5
  20. package/lib/observers/global-observer.js +140 -0
  21. package/lib/observers/grpc-observer.js +339 -0
  22. package/lib/observers/http-observer.js +7 -7
  23. package/lib/observers/process-observer.js +57 -8
  24. package/lib/observers/redis-observer.js +69 -11
  25. package/lib/observers/websocket-observer.js +1 -1
  26. package/lib/pack/event-pack.js +1 -1
  27. package/lib/pack/log-sink-pack.js +139 -0
  28. package/lib/pack/packenum.js +3 -1
  29. package/lib/pack/zip-pack.js +0 -1
  30. package/lib/stat/{stat-remoteip.js → stat-remote-ip.js} +8 -8
  31. package/lib/stat/stat-remote-ipurl.js +88 -0
  32. package/lib/stat/timingsender.js +4 -1
  33. package/lib/topology/link.js +63 -0
  34. package/lib/topology/nodeinfo.js +123 -0
  35. package/lib/topology/status-detector.js +111 -0
  36. package/lib/util/compare-util.js +131 -0
  37. package/lib/util/kube-util.js +3 -3
  38. package/lib/util/linkedset.js +278 -0
  39. package/package.json +2 -2
@@ -11,7 +11,7 @@ function num(k, defValue){
11
11
  };
12
12
  function bool(k, defValue){
13
13
  var v=process.env[k];
14
- return v?Boolean(v):defValue;
14
+ return v ? (v === 'true') : defValue;
15
15
  };
16
16
  function str(k, defValue){
17
17
  var v=process.env[k];
@@ -154,8 +154,8 @@ var ConfigDefault = {
154
154
  "httpc_not_found_ignore": bool('httpc_not_found_ignore', false),
155
155
  "httpc_not_found_ignore_time": num('httpc_not_found_ignore', 300000),
156
156
  "ignore_sql_error_code_set": str('ignore_sql_error_code_set', ''),
157
- "ignore_nextjs_build_file_enabled": bool('ignore_nextjs_build_file_enabled', true),
158
- "ignore_nextjs_build_file_path": str('ignore_nextjs_build_file_path', '/_next/'),
157
+ "ignore_build_file_enabled": bool('ignore_build_file_enabled', true),
158
+ "ignore_build_file_path": str('ignore_build_file_path', '/_next/'),
159
159
 
160
160
  //2017.05.02 AUTO ONAME
161
161
  "auto_oname_enabled" : bool('auto_oname_enabled',false),
@@ -256,6 +256,14 @@ var ConfigDefault = {
256
256
  "cloud_platform":str('cloud_platform', 'kic'),
257
257
  "cloud_platform_chk":str('cloud_platform_chk', 'kr-central-1'),
258
258
  "cloud_platform_httpc":str('cloud_platform_httpc', 'http://169.254.169.254/latest/meta-data/placement/availability-zone'),
259
+
260
+ "stat_ipurl_enabled": bool("stat_ipurl_enabled", false),
261
+ "stat_ipurl_max_count": num("stat_ipurl_max_count", 10000),
262
+
263
+ "grpc_profile_enabled": bool("grpc_profile_enabled", true),
264
+ "grpc_profile_stream_client_enabled": bool("grpc_profile_stream_client_enabled", true),
265
+ "grpc_profile_stream_server_enabled": bool("grpc_profile_stream_server_enabled", true),
266
+ "grpc_profile_ignore_method": bool("grpc_profile_ignore_method", true),
259
267
  };
260
268
 
261
269
  ConfigDefault._hook_method_ignore_prefix = ConfigDefault.hook_method_ignore_prefixes.split(',');
@@ -17,6 +17,7 @@ var DataInputX = require('./../io/data-inputx'),
17
17
  StringUtil = require('./../util/string-util'),
18
18
  Cypher = require('./../util/cypher'),
19
19
  ConfigDefault = require("./config-default"),
20
+ LogConfigDefault = require("./log-config-default"),
20
21
  ConfSysMon = require('./conf-sys-mon'),
21
22
  MapValue = require('./../value/map-value'),
22
23
  IntKeyLinkedMap = require('./../util/intkey-linkedmap'),
@@ -27,6 +28,7 @@ var Configuration = function() {
27
28
  var self = this;
28
29
  EventEmitter.call(this);
29
30
  this.apply(ConfigDefault);
31
+ this.apply(LogConfigDefault);
30
32
 
31
33
  this.inx = 0;
32
34
  this._customProps = {};
@@ -52,7 +54,7 @@ var applyEmptyConf=false;
52
54
  Configuration.prototype.reload = function(cb) {
53
55
  var self = this;
54
56
 
55
- this.getPropertyFilePath( function(err, propertyFile) {
57
+ this.getPropertyFilePath( function(err, propertyFile) {
56
58
  if(err) {
57
59
  if(applyEmptyConf==false){
58
60
  applyEmptyConf=true;
@@ -63,14 +65,21 @@ Configuration.prototype.reload = function(cb) {
63
65
  defKeys.forEach(function (key) {
64
66
  if(ConfigDefault[key]) {
65
67
  p[key] = ConfigDefault[key];
66
- }
68
+ }
69
+ });
70
+ var logDefKeys = Object.keys(LogConfigDefault);
71
+ logDefKeys.forEach(function (key) {
72
+ if(LogConfigDefault[key]) {
73
+ p[key] = LogConfigDefault[key];
74
+ }
67
75
  });
76
+
68
77
  if(process.env.WHATAP_SERVER_HOST){
69
78
  p['whatap.server.host']=process.env.WHATAP_SERVER_HOST;
70
- }
79
+ }
71
80
  if(process.env.WHATAP_LICENSE){
72
81
  p['license']=process.env.WHATAP_LICENSE;
73
- }
82
+ }
74
83
  self.apply(p);
75
84
  updatePrivate(self);
76
85
  if(cb) cb();
@@ -111,8 +120,8 @@ Configuration.prototype.reload = function(cb) {
111
120
 
112
121
  oldKeys.forEach(function (key) {
113
122
  if(newKeys.indexOf(key) < 0) {
114
- if(ConfigDefault[key] != null) {
115
- self[key] = ConfigDefault[key];
123
+ if(ConfigDefault[key] !== null || LogConfigDefault[key] !== null) {
124
+ self[key] = ConfigDefault[key] !== null ? ConfigDefault[key] : LogConfigDefault[key];
116
125
  } else {
117
126
  delete self[key];
118
127
  }
@@ -121,6 +130,10 @@ Configuration.prototype.reload = function(cb) {
121
130
  require('../logger').print("WHATAP-203", "Config file reloaded", false);
122
131
  }
123
132
 
133
+ if(!self._customProps['license'] && process.env.WHATAP_LICENSE)
134
+ self._customProps['license'] = process.env.WHATAP_LICENSE;
135
+ if(!self._customProps['whatap.server.host'] && process.env.WHATAP_SERVER_HOST)
136
+ self._customProps['whatap.server.host'] = process.env.WHATAP_SERVER_HOST;
124
137
  self.apply( self._customProps );
125
138
  updatePrivate(self);
126
139
  if(cb) cb();
@@ -150,10 +163,10 @@ Configuration.prototype.apply = function(properties) {
150
163
  var ips = Array.from(set);
151
164
  this.whatap_server_host = ips;
152
165
 
153
- if( this.getProperty('whatap_micro_enabled') === true || process.env.WHATAP_MICRO_ENABLED === "true"){
166
+ if( this.getProperty('whatap_micro_enabled', false) === true || process.env.WHATAP_MICRO_ENABLED === "true"){
154
167
  this.kubeNodeName(properties);
155
168
  }
156
-
169
+
157
170
  ConfSysMon.apply(properties);
158
171
  };
159
172
 
@@ -170,12 +183,12 @@ Configuration.prototype.kubeNodeName = function(properties){
170
183
 
171
184
  this.ONODE_NAME = this.getProperty("whatap.onode");
172
185
  if (!this.ONODE_NAME || (this.ONODE_NAME && this.ONODE_NAME.length < 1)) {
173
- this.ONODE_NAME = process.env['NODE_NAME'];
186
+ this.ONODE_NAME = process.env['NODE_NAME'] || process.env['WHATAP_ONODE'];
174
187
  }
175
188
  if (!this.ONODE_NAME || (this.ONODE_NAME && this.ONODE_NAME.length < 1)) {
176
189
  this.ONODE_NAME = process.env["NODE_IP"];
177
190
  }
178
- this.ONODE = StringUtil.isEmpty(this.ONODE_NAME) ? 0 : HashUtil.hash(this.ONODE_NAME);
191
+ this.ONODE = StringUtil.isEmpty(this.ONODE_NAME) ? 0 : HashUtil.hashFromString(this.ONODE_NAME);
179
192
  secu.ONODE = this.ONODE;
180
193
  secu.ONODE_NAME = this.ONODE_NAME;
181
194
  }
@@ -197,7 +210,7 @@ Configuration.prototype.getPropertyFilePath = function(cb) {
197
210
 
198
211
  var default_conf = WHATAP_CONF+".conf";
199
212
  var configFile = this.getProperty('whatap.config', default_conf);
200
-
213
+
201
214
  var confFullPathFile=path.join(confDir, configFile);
202
215
  fs.access(confFullPathFile, function (err) {
203
216
  if (err) {
@@ -230,10 +243,10 @@ Configuration.prototype.saveProperty = function(keyValues){
230
243
 
231
244
  if(!self._customProps['whatap.server.host'] && process.env.WHATAP_SERVER_HOST){
232
245
  self._customProps['whatap.server.host']=process.env.WHATAP_SERVER_HOST;
233
- }
246
+ }
234
247
  if(!self._customProps['license'] && process.env.WHATAP_LICENSE){
235
248
  self._customProps['license']=process.env.WHATAP_LICENSE;
236
- }
249
+ }
237
250
  var writeContents = '';
238
251
  for(var k in self._customProps){
239
252
  var v = self._customProps[k];
@@ -256,7 +269,7 @@ Configuration.prototype.setProperty = function(key, value) {
256
269
  this.emit(key, value);
257
270
  };
258
271
  Configuration.prototype.getProperty = function(key, defaultValue) {
259
- if(!this[key]){
272
+ if(this[key] === undefined){
260
273
  return defaultValue;
261
274
  } else{
262
275
  return this[key];
@@ -301,11 +314,11 @@ Configuration.prototype.isIgnoreLog = function (id) {
301
314
  };
302
315
  Configuration.prototype.setSocketChk = function (socket) {
303
316
  if(socket.whatapId == undefined) {
304
- socket.whatapId = (new Date()).getTime().toString(36) + Math.random().toString(36).slice(2);
305
- //require('../logger').print("WHATAP-TEST", 'Socket whatapId : ' + socket.whatapId, false);
306
- }
317
+ socket.whatapId = (new Date()).getTime().toString(36) + Math.random().toString(36).slice(2);
318
+ //require('../logger').print("WHATAP-TEST", 'Socket whatapId : ' + socket.whatapId, false);
319
+ }
307
320
  //else {
308
- // require('../logger').print("WHATAP-TEST", '[REUSE] Socket whatapId : ' + socket.whatapId, false);
321
+ // require('../logger').print("WHATAP-TEST", '[REUSE] Socket whatapId : ' + socket.whatapId, false);
309
322
  //}
310
323
  if(this.socketChk.get(socket.whatapId) == null) {
311
324
  this.socketChk.put(socket.whatapId , socket.whatapId);
@@ -319,7 +332,7 @@ Configuration.prototype.getStringSet = function (key, defaultValue, deli) {
319
332
 
320
333
  var arr = value.split(deli);
321
334
  for(var i=0; i<arr.length; i++) {
322
- var x = arr[i].trim();
335
+ var x = arr[i].trim();
323
336
  if(x)set.add(replaceCarriageReturns(x));
324
337
  }
325
338
  return set;
@@ -0,0 +1,37 @@
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 num(k, defValue){
8
+ var v=process.env[k];
9
+ return v?Number(v):defValue;
10
+ };
11
+ function bool(k, defValue){
12
+ var v=process.env[k];
13
+ return v?Boolean(v):defValue;
14
+ };
15
+ function str(k, defValue){
16
+ var v=process.env[k];
17
+ return v?v:defValue;
18
+ };
19
+ var LogConfigDefault = {
20
+ "logsink_enabled": bool("logsink_enabled", false),
21
+ "logsink_zip_enabled": bool("logsink_zip_enabled", false),
22
+ "logsink_category_stdout": "AppStdOut",
23
+ "logsink_category_stderr": "AppStdErr",
24
+ "logsink_queue_size": num("logsink_queue_size", 500),
25
+ "logsink_limit_content_enabled": bool("logsink_limit_content_enabled", true),
26
+ "logsink_limit_content_length": num("logsink_limit_content_length", 10000),
27
+ "logsink_max_content_log_enabled": bool("logsink_max_content_log_enabled", true),
28
+ "logsink_max_content_alert_enabled": bool("logsink_max_content_alert_enabled", false),
29
+ "logsink_max_content_alert_silent_time": num("logsink_max_content_alert_silent_time", 10000),
30
+ "logsink_trace_txid_enabled": bool("logsink_trace_txid_enabled", true),
31
+ "logsink_trace_mtid_enabled": bool("logsink_trace_mtid_enabled", true),
32
+ "logsink_high_secure_enabled": bool("logsink_high_secure_enabled", false),
33
+ "debug_logsink_zip_enabled": bool("debug_logsink_zip_enabled", false),
34
+ "logsink_max_buffer_size": num("logsink_max_buffer_size", 1024*64),
35
+ "logsink_max_wait_time": num("logsink_max_wait_time", 2000)
36
+ };
37
+ module.exports = LogConfigDefault;
@@ -15,7 +15,9 @@ var PackageCtrHelper = require('./packagectr-helper'),
15
15
  TextValue = require('../value/text-value'),
16
16
  ResourceProfile = require('../util/resourceprofile'),
17
17
  TraceContextManager = require('../trace/trace-context-manager'),
18
- Logger = require('../logger');
18
+ Logger = require('../logger'),
19
+ StatusDetector = require('../topology/status-detector'),
20
+ BlobValue = require('../value/blob-value');
19
21
 
20
22
  var ControlHandler = function () {
21
23
  this.queue = new RequestQueue(100);
@@ -26,17 +28,17 @@ ControlHandler.prototype.add = function (p /* Pack */) {
26
28
  this.process(p);
27
29
  };
28
30
 
29
- ControlHandler.prototype.process = function (p) {
31
+ ControlHandler.prototype.process = async function (p) {
30
32
  switch (p.getPackType()) {
31
33
  case PackEnum.PARAMETER:
32
- this.handle(p);
34
+ await this.handle(p);
33
35
  break;
34
36
  default:
35
37
  Logger.printError('WHATAP-203', 'Unknown pack received ' + p, new Error('Unknown pack'));
36
38
  }
37
39
  };
38
40
 
39
- ControlHandler.prototype.handle = function (p) {
41
+ ControlHandler.prototype.handle = async function (p) {
40
42
  var self = this;
41
43
  if (!this._dataPackSender) {
42
44
  this._dataPackSender = require('../data/datapack-sender');
@@ -115,7 +117,7 @@ ControlHandler.prototype.handle = function (p) {
115
117
  }
116
118
  break;
117
119
  case ParamDef.LOADED_CLASS_REDEFINE:
118
- self._dataPackSender.sendResponseHide(p.getResponse());
120
+ self._dataPackSender.sendResponseHide(p.getResponse());
119
121
  break;
120
122
  case ParamDef.NODE_MODULE_DEPENDENCY:
121
123
 
@@ -181,7 +183,7 @@ ControlHandler.prototype.handle = function (p) {
181
183
  var key = en.nextElement();
182
184
  var val = mv.getText(key);
183
185
  props[key] = val
184
- }
186
+ }
185
187
  Configure.saveProperty(props);
186
188
  } catch (e) {
187
189
  p.putValue("error", e.toString())
@@ -222,6 +224,17 @@ ControlHandler.prototype.handle = function (p) {
222
224
  self._dataPackSender.sendResponseHide(p.getResponse());
223
225
  });
224
226
  break;
227
+ case ParamDef.GET_TOPOLOGY:
228
+ try {
229
+ const node = await new StatusDetector().process();
230
+ if (node) {
231
+ p.putValue("node", new BlobValue(node.toBytes()));
232
+ }
233
+ this._dataPackSender.sendResponseHide(p.getResponse());
234
+ } catch (e) {
235
+ Logger.printError('WHATAP-203', 'Node Module Dependency ', e, true);
236
+ }
237
+ break;
225
238
  }
226
239
  }
227
240
 
package/lib/core/agent.js CHANGED
@@ -29,7 +29,8 @@ var Interceptor = require('./interceptor').Interceptor,
29
29
  ThriftObserver = require('../observers/thrift-observer').ThriftObserver,
30
30
  PromiseObserver = require('../observers/promise-observer').PromiseObserver,
31
31
  PgSqlObserver = require('../observers/pgsql-observer').PgSqlObserver,
32
- ScheduleObserver = require('../observers/schedule-observer').ScheduleObserver;
32
+ ScheduleObserver = require('../observers/schedule-observer').ScheduleObserver,
33
+ GRpcObserver = require('../observers/grpc-observer').GRpcObserver;
33
34
 
34
35
  var Configuration = require('./../conf/configure'),
35
36
  SecurityMaster = require('./../net/security-master'),
@@ -52,7 +53,8 @@ var Configuration = require('./../conf/configure'),
52
53
  require('../stat/stat-tranx');
53
54
  require('../stat/stat-sql');
54
55
  require('../stat/stat-httpc');
55
- require('../stat/stat-remoteip');
56
+ require('../stat/stat-remote-ip');
57
+ require('../stat/stat-remote-ipurl');
56
58
  require('../stat/stat-useragent');
57
59
  require('../stat/timingsender');
58
60
 
@@ -101,21 +103,21 @@ NodeAgent.prototype.findRoot = function () {
101
103
  };
102
104
  NodeAgent.prototype.init = function(cb) {
103
105
  var self = this;
104
- if(self._initialized) {
105
- return;
106
+ if(self._initialized) {
107
+ return;
106
108
  }
107
109
  self._initialized = true;
108
110
  self.starttime = Date.now();
109
111
 
110
112
  self.findRoot();
111
-
113
+
112
114
  Logger.initializer.process();
113
115
  Logger.print('WHATAP-001', 'Start initialize WhaTap Agent... Root[' + self._conf['app.root'] + ']', true);
114
116
 
115
117
  if(self._conf['app.root'] == null || self._conf['app.root'].length == 0) {
116
118
  return Logger.print("WHATAP-001", "Can not find application root directory", true);
117
119
  }
118
-
120
+
119
121
  NodeUtil.getPackageJson();
120
122
  PackageCtrHelper.dynamicHook();
121
123
 
@@ -130,7 +132,7 @@ NodeAgent.prototype.init = function(cb) {
130
132
  Logger.print("WHATAP-REQLOG" , "ReqLog Init Start !!!! " , false);
131
133
  RequestLog.initializer.process();
132
134
  }
133
-
135
+
134
136
  self._securityMaster.run( function (err) {
135
137
  if(err) {
136
138
  Logger.printError('WHATAP-104', 'Failed to connect to whatap server', err, false);
@@ -178,7 +180,7 @@ NodeAgent.prototype.initOK = function(cb) {
178
180
  self._counterManager.run();
179
181
  PluginLoaderManager.start();
180
182
  }
181
-
183
+
182
184
  WhatapUtil.printWhatap();
183
185
  self.connectCount = 0;
184
186
  self.setLoopTime = 5000;
@@ -265,7 +267,8 @@ NodeAgent.prototype.loadObserves = function() {
265
267
  observes.push(PromiseObserver);
266
268
  observes.push(PgSqlObserver);
267
269
  observes.push(ScheduleObserver);
268
-
270
+ // observes.push(GRpcObserver);
271
+
269
272
  var packageToObserve = {};
270
273
  observes.forEach(function(observeObj) {
271
274
  var observe = new observeObj(agent);
@@ -0,0 +1,98 @@
1
+ 'use strict'
2
+
3
+ function isFunction (funktion) {
4
+ return typeof funktion === 'function'
5
+ }
6
+
7
+ function defineProperty (obj, name, value) {
8
+ var enumerable = !!obj[name] && obj.propertyIsEnumerable(name)
9
+ Object.defineProperty(obj, name, {
10
+ configurable: true,
11
+ enumerable: enumerable,
12
+ writable: true,
13
+ value: value
14
+ })
15
+ }
16
+
17
+ var shimmer = function () {
18
+ }
19
+
20
+ var wrap = function (nodule, name, wrapper) {
21
+ if (!nodule || !nodule[name]) {
22
+ return;
23
+ }
24
+
25
+ if (!wrapper) {
26
+ return;
27
+ }
28
+
29
+ if (!isFunction(nodule[name]) || !isFunction(wrapper)) {
30
+ return
31
+ }
32
+
33
+ var original = nodule[name]
34
+ var wrapped = wrapper(original, name)
35
+
36
+ defineProperty(wrapped, '__original', original)
37
+ defineProperty(wrapped, '__unwrap', function () {
38
+ if (nodule[name] === wrapped) defineProperty(nodule, name, original)
39
+ })
40
+ defineProperty(wrapped, '__wrapped', true)
41
+
42
+ defineProperty(nodule, name, wrapped)
43
+ return wrapped
44
+ }
45
+
46
+ function unwrap (nodule, name) {
47
+ if (!nodule || !nodule[name]) {
48
+ return
49
+ }
50
+
51
+ if (!nodule[name].__unwrap) {
52
+ } else {
53
+ return nodule[name].__unwrap()
54
+ }
55
+ }
56
+
57
+ function massWrap (nodules, names, wrapper) {
58
+ if (!nodules) {
59
+ return
60
+ } else if (!Array.isArray(nodules)) {
61
+ nodules = [nodules]
62
+ }
63
+
64
+ if (!(names && Array.isArray(names))) {
65
+ return
66
+ }
67
+
68
+ nodules.forEach(function (nodule) {
69
+ names.forEach(function (name) {
70
+ wrap(nodule, name, wrapper)
71
+ })
72
+ })
73
+ }
74
+
75
+ function massUnwrap (nodules, names) {
76
+ if (!nodules) {
77
+ return
78
+ } else if (!Array.isArray(nodules)) {
79
+ nodules = [nodules]
80
+ }
81
+
82
+ if (!(names && Array.isArray(names))) {
83
+ return
84
+ }
85
+
86
+ nodules.forEach(function (nodule) {
87
+ names.forEach(function (name) {
88
+ unwrap(nodule, name)
89
+ })
90
+ })
91
+ }
92
+
93
+ shimmer.wrap = wrap;
94
+ shimmer.unwrap = unwrap;
95
+ shimmer.massWrap = massWrap;
96
+ shimmer.massUnwrap = massUnwrap;
97
+
98
+ module.exports = shimmer;
@@ -96,7 +96,7 @@ AgentInfo.prototype.checkAutoScaleIn = function() {
96
96
  var e = new EventPack();
97
97
  e.title = "SILENT_SHUTDOWN";
98
98
  e.level = EventLevel.INFO;
99
- DataPackSender.send(e);
99
+ DataPackSender.sendPack(e);
100
100
  }
101
101
  }
102
102
 
@@ -159,10 +159,30 @@ var sendStatRemoteIpPack = function(p){
159
159
  return sendPack(p);
160
160
  };
161
161
 
162
+ var sendStatRemoteIpUrlPack = function(p){
163
+ return sendPack(p);
164
+ };
165
+
162
166
  var sendStatUserAgentPack = function(p){
163
167
  return sendPack(p);
164
168
  };
165
169
 
170
+ var sendLogSinkPack = function(p){
171
+ if (p == null)
172
+ return;
173
+
174
+ p.pcode = secuMaster.PCODE;
175
+ p.oid = secuMaster.OID;
176
+ p.okind=secuMaster.OKIND;
177
+ p.onode=secuMaster.ONODE;
178
+
179
+ if (conf.getProperty('logsink_high_secure_enabled', false)) {
180
+ TcpRequestMgr.add(NetFlag.SECURE_CYPHER, p);
181
+ }else{
182
+ TcpRequestMgr.add(NetFlag.SECURE_HIDE, p);
183
+ }
184
+ };
185
+
166
186
  var sendEventPack = function(p){
167
187
  return sendPack(p);
168
188
  };
@@ -245,7 +265,9 @@ var DataPackSender = {
245
265
  sendStatHttpcPack : sendStatHttpcPack,
246
266
  sendStatErrorPack : sendStatErrorPack,
247
267
  sendStatRemoteIpPack : sendStatRemoteIpPack,
268
+ sendStatRemoteIpUrlPack : sendStatRemoteIpUrlPack,
248
269
  sendStatUserAgentPack : sendStatUserAgentPack,
270
+ sendLogSinkPack : sendLogSinkPack,
249
271
 
250
272
  sendRealtimeUserPack : sendRealtimeUserPack,
251
273
  sendEventPack : sendEventPack,
@@ -6,11 +6,12 @@
6
6
 
7
7
  var DataPackSender = require('./datapack-sender'),
8
8
  StatTranX = require('../stat/stat-tranx'),
9
- StatRemoteIp = require('../stat/stat-remoteip'),
9
+ StatRemoteIp = require('../stat/stat-remote-ip'),
10
10
  StatUserAgent = require('../stat/stat-useragent'),
11
11
  StatTranxDomain = require('../stat/stat-tx-domain'),
12
12
  StatTranxMtCaller = require('../stat/stat-tx-caller'),
13
13
  StatTranxReferer = require('../stat/stat-tx-referer'),
14
+ StatRemoteIpUrl = require('../stat/stat-remote-ipurl'),
14
15
  conf = require('../conf/configure'),
15
16
  HashUtil = require('../util/hashutil'),
16
17
  EventLevel = require('../data/event-level'),
@@ -20,9 +21,13 @@ var DataPackSender = require('./datapack-sender'),
20
21
 
21
22
  var ZipProfile = require('./zipprofile');
22
23
  var profile_zip_enabled = conf.getProperty('profile_zip_enabled', false);
24
+ var stat_ipurl_enabled = conf.getProperty('stat_ipurl_enabled', false);
23
25
  conf.on('profile_zip_enabled', function(newProperty) {
24
26
  profile_zip_enabled = newProperty;
25
27
  });
28
+ conf.on('stat_ipurl_enabled', function(newProperty) {
29
+ stat_ipurl_enabled = newProperty;
30
+ });
26
31
 
27
32
  var DataProfileAgent = {
28
33
  last_reject : 0,
@@ -32,6 +37,17 @@ var DataProfileAgent = {
32
37
  StatUserAgent.incUserAgent(ctx.userAgent);
33
38
 
34
39
  var transaction = profile.service;
40
+ if(stat_ipurl_enabled && ctx.remoteIp){
41
+ var tc = StatRemoteIpUrl.getService(ctx.remoteIp, ctx.service_hash);
42
+ if (tc) {
43
+ tc.count++;
44
+ if (tc.errorLevel >= EventLevel.WARNING) {
45
+ tc.error++;
46
+ }
47
+ tc.time += transaction.elapsed;
48
+ }
49
+ }
50
+
35
51
  if(conf.stat_domain_enabled && ctx.http_host_hash!=0) {
36
52
  StatTranxDomain.add(ctx.http_host_hash, ctx.service_hash, transaction.elapsed, ctx.error != 0);
37
53
  }
@@ -185,12 +185,12 @@ class ZipProfile {
185
185
  }
186
186
 
187
187
  startProcessQueue() {
188
- if (!this.processing) {
188
+ if (!this.isProcessing) {
189
189
  this.processQueue()
190
190
  }
191
191
  }
192
192
  stopProcessQueue() {
193
- this.processing = false;
193
+ this.isProcessing = false;
194
194
  }
195
195
  }
196
196
 
package/lib/logger.js CHANGED
@@ -168,6 +168,12 @@
168
168
  console.log('[WHATAP]Logger Error - WHATAP ROOT DIR IS NULL!!!!!!!!!');
169
169
  return;
170
170
  }
171
+ if(conf.getProperty('log_root', null)){
172
+ root = conf.getProperty('log_root', null);
173
+ if(fs.existsSync(root) == false) {
174
+ fs.mkdirSync(root, {recursive: true});
175
+ }
176
+ }
171
177
  var dir = path.join(root, 'logs');
172
178
  if(fs.existsSync(dir) == false) {
173
179
  fs.mkdirSync(dir);
@@ -188,8 +194,14 @@
188
194
  if(conf.log_rotation_enabled === false || conf.log_enabled === false) { return; }
189
195
  if(conf.log_keep_days <= 0) { return; }
190
196
 
197
+ var root = conf['app.root'];
198
+ if(conf.getProperty('log_root', null)){
199
+ root = conf.getProperty('log_root', null);
200
+ if(fs.existsSync(root) == false) {
201
+ fs.mkdirSync(root, {recursive: true});
202
+ }
203
+ }
191
204
  var nowUnit = DateUtil.getDateUnit(),
192
- root = conf['app.root'],
193
205
  dir = path.join(root, 'logs'),
194
206
  log_prefix = WHATAP_CONF+"-";
195
207
 
@@ -233,6 +245,12 @@
233
245
 
234
246
 
235
247
  var root = conf['app.root'];
248
+ if(conf.getProperty('log_root', null)){
249
+ root = conf.getProperty('log_root', null);
250
+ if(fs.existsSync(root) == false) {
251
+ fs.mkdirSync(root, {recursive: true});
252
+ }
253
+ }
236
254
  if(root==null ){
237
255
  return null;
238
256
  }
@@ -276,6 +294,12 @@
276
294
  var o = new MapValue();
277
295
  if(conf.log_file_enabled === false ) { return o; }
278
296
  var root = conf['app.root'];
297
+ if(conf.getProperty('log_root', null)){
298
+ root = conf.getProperty('log_root', null);
299
+ if(fs.existsSync(root) == false) {
300
+ fs.mkdirSync(root, {recursive: true});
301
+ }
302
+ }
279
303
  if(root==null){
280
304
  return o;
281
305
  }