forked from scouter-project/scouter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigure.java
More file actions
726 lines (677 loc) · 30.9 KB
/
Configure.java
File metadata and controls
726 lines (677 loc) · 30.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
/*
* Copyright 2015 the original author or authors.
* @https://github.com/scouter-project/scouter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package scouter.agent;
import scouter.Version;
import scouter.agent.netio.data.DataProxy;
import scouter.lang.conf.ConfObserver;
import scouter.lang.conf.ConfigValueUtil;
import scouter.lang.counters.CounterConstants;
import scouter.lang.value.ListValue;
import scouter.lang.value.MapValue;
import scouter.net.NetConstants;
import scouter.util.*;
import java.io.*;
import java.util.*;
public class Configure extends Thread {
public static boolean JDBC_REDEFINED = false;
private static Configure instance = null;
private long last_load_time = -1;
public Properties property = new Properties();
private boolean running = true;
private File propertyFile;
long last_check = 0;
public final static synchronized Configure getInstance() {
if (instance == null) {
instance = new Configure();
instance.setDaemon(true);
instance.setName(ThreadUtil.getName(instance));
instance.start();
}
return instance;
}
//Network
public String net_local_udp_ip = null;
public int net_local_udp_port;
public String net_collector_ip = "127.0.0.1";
public int net_collector_udp_port = NetConstants.SERVER_UDP_PORT;
public int net_collector_tcp_port = NetConstants.SERVER_TCP_PORT;
public int net_collector_tcp_session_count = 1;
public int net_collector_tcp_so_timeout_ms = 60000;
public int net_collector_tcp_connection_timeout_ms = 3000;
public int net_udp_packet_max_bytes = 60000;
public long net_udp_collection_interval_ms = 100;
//Object
public String obj_type = "";
public String obj_name = "";
public String obj_host_type = "";
public String obj_host_name = "";
public boolean obj_name_auto_pid_enabled = false;
public boolean obj_type_inherit_to_child_enabled = false;
//profile
public boolean profile_http_querystring_enabled;
public boolean profile_http_header_enabled;
public String profile_http_header_url_prefix = "/";
public boolean profile_http_parameter_enabled;
public String profile_http_parameter_url_prefix = "/";
public boolean profile_summary_mode_enabled = false;
public boolean profile_thread_cputime_enabled = false;
public boolean profile_socket_open_fullstack_enabled = false;
public int profile_socket_open_fullstack_port = 0;
public boolean profile_sqlmap_name_enabled = true;
public boolean profile_connection_open_enabled = true;
public boolean profile_connection_open_fullstack_enabled = false;
public boolean profile_connection_autocommit_status_enabled = false;
public boolean profile_method_enabled = true;
public int profile_step_max_count = 1024;
public boolean profile_fullstack_service_error_enabled = false;
public boolean profile_fullstack_apicall_error_enabled = false;
public boolean profile_fullstack_sql_error_enabled = false;
public boolean profile_fullstack_sql_commit_enabled = false;
public int profile_fullstack_max_lines = 0;
public boolean profile_sql_escape_enabled = true;
public boolean _profile_fullstack_sql_connection_enabled = false;
public boolean profile_fullstack_rs_leak_enabled = false;
public boolean profile_fullstack_stmt_leak_enabled = false;
//Trace
public int trace_user_mode = 2; // 0:Remote IP, 1:JSessionID, 2:SetCookie
public boolean trace_background_socket_enabled = true;
public String trace_service_name_header_key;
public String trace_service_name_get_key;
public String trace_service_name_post_key;
public long trace_activeserivce_yellow_time = 3000;
public long trace_activeservice_red_time = 8000;
public String trace_http_client_ip_header_key = "";
public boolean trace_interservice_enabled = false;
public String _trace_interservice_gxid_header_key = "X-Scouter-Gxid";
public boolean trace_response_gxid_enabled = false;
public String _trace_interservice_callee_header_key = "X-Scouter-Callee";
public String _trace_interservice_caller_header_key = "X-Scouter-Caller";
public String trace_user_session_key = "JSESSIONID";
public boolean _trace_auto_service_enabled = false;
public boolean _trace_auto_service_backstack_enabled = true;
public boolean trace_db2_enabled = true;
public boolean trace_webserver_enabled = false;
public String trace_webserver_name_header_key = "X-Forwarded-Host";
public String trace_webserver_time_header_key = "X-Forwarded-Time";
public int _trace_fullstack_socket_open_port = 0;
public boolean trace_rs_leak_enabled = false;
public boolean trace_stmt_leak_enabled = false;
//Dir
public File plugin_dir = new File("./plugin");
public File dump_dir = new File("./dump");
//public File mgr_agent_lib_dir = new File("./_scouter_");
//Manager
public String mgr_static_content_extensions = "js, htm, html, gif, png, jpg, css";
public String mgr_log_ignore_ids = "";
//Autodump
public boolean autodump_enabled = false;
public int autodump_trigger_active_service_cnt = 10000;
public long autodump_interval_ms = 30000;
public int autodump_level = 1; // 1:ThreadDump, 2:ActiveService, 3:ThreadList
public int autodump_stuck_thread_ms = 0;
//XLog
public int xlog_lower_bound_time_ms = 0;
public int xlog_error_jdbc_fetch_max = 10000;
public int xlog_error_sql_time_max_ms = 30000;
public boolean xlog_error_check_user_transaction_enabled = true;
//Alert
public int alert_message_length = 3000;
public long alert_send_interval_ms = 3000;
public int alert_perm_warning_pct = 90;
//Log
public boolean _log_asm_enabled;
public boolean _log_udp_xlog_enabled;
public boolean _log_udp_object_enabled;
public boolean _log_udp_counter_enabled;
public boolean _log_datasource_lookup_enabled = true;
public boolean _log_background_sql = false;
public String log_dir ="";
public boolean log_rotation_enabled =true;
public int log_keep_days =7;
public boolean _trace = false;
public boolean _trace_use_logger = false;
//Hook
public String hook_args_patterns = "";
public String hook_return_patterns = "";
public String hook_constructor_patterns = "";
public String hook_connection_open_patterns = "";
public String hook_context_classes = "javax/naming/InitialContext";
public String hook_method_patterns = "";
public String hook_method_ignore_prefixes = "get,set";
public String hook_method_ignore_classes = "";
public String hook_method_exclude_patterns = "";
private StringSet _hook_method_ignore_classes = new StringSet();
public boolean hook_method_access_public_enabled = true;
public boolean hook_method_access_private_enabled = false;
public boolean hook_method_access_protected_enabled = false;
public boolean hook_method_access_none_enabled = false;
public String hook_service_patterns = "";
public String hook_apicall_patterns = "";
public String hook_apicall_info_patterns = "";
public String hook_jsp_patterns = "";
public String hook_jdbc_pstmt_classes = "";
public String hook_jdbc_stmt_classes = "";
public String hook_jdbc_rs_classes = "";
public String hook_jdbc_wrapping_driver_patterns = "";
public String hook_add_fields = "";
public boolean _hook_serivce_enabled = true;
public boolean _hook_dbsql_enabled = true;
public boolean _hook_dbconn_enabled = true;
public boolean _hook_cap_enabled = true;
public boolean _hook_methods_enabled = true;
public boolean _hook_socket_enabled = true;
public boolean _hook_jsp_enabled = true;
public boolean _hook_async_enabled = true;
public boolean _hook_usertx_enabled = true;
public String _hook_direct_patch_classes = "";
public boolean _hook_spring_rest_enabled = false;
public String _hook_boot_prefix=null;
//Control
public boolean control_reject_service_enabled = false;
public int control_reject_service_max_count = 10000;
public boolean control_reject_redirect_url_enabled = false;
public String control_reject_text = "too many request!!";
public String control_reject_redirect_url = "/error.html";
// Counter
public boolean counter_enabled = true;
public long counter_recentuser_valid_ms = DateUtil.MILLIS_PER_FIVE_MINUTE;
public String counter_object_registry_path = "/tmp/scouter";
// SFA(Stack Frequency Analyzer)
public boolean sfa_dump_enabled = false;
public int sfa_dump_interval_ms = 10000;
//Summary
public boolean summary_enabled = true;
public boolean _summary_connection_leak_fullstack_enabled = false;
public int _summary_service_max_count = 5000;
public int _summary_sql_max_count = 5000;
public int _summary_api_max_count = 5000;
public int _summary_ip_max_count = 5000;
public int _summary_useragent_max_count = 5000;
public int _summary_error_max_count = 500;
public int _summary_enduser_nav_max_count = 5000;
public int _summary_enduser_ajax_max_count = 5000;
public int _summary_enduser_error_max_count = 5000;
//EndUser
public String enduser_trace_endpoint_url = "/_scouter_browser.jsp";
//Experimental(ignoreset)
public boolean __experimental = false;
public boolean __control_connection_leak_autoclose_enabled = false;
public boolean __ip_dummy_test = false;
//internal variables
private int objHash;
private String objName;
private int objHostHash;
private String objHostName;
private Set<String> static_contents = new HashSet<String>();
private StringSet log_ignore_set = new StringSet();
private String[] _hook_method_ignore_prefix = null;
private int _hook_method_ignore_prefix_len = 0;
private int hook_signature;
private int enduser_perf_endpoint_hash = HashUtil.hash(enduser_trace_endpoint_url);
/**
* sometimes call by sample application, at that time normally set some
* properties directly
*/
private Configure() {
Properties p = new Properties();
Map args = new HashMap();
args.putAll(System.getenv());
args.putAll(System.getProperties());
p.putAll(args);
this.property = p;
reload(false);
}
private Configure(boolean b) {
}
public void run() {
Logger.println("Version " + Version.getAgentFullVersion());
long dateUnit = DateUtil.getDateUnit();
while (running) {
reload(false);
// Text Data Reset..
long nowUnit = DateUtil.getDateUnit();
if (dateUnit != nowUnit) {
dateUnit = nowUnit;
DataProxy.reset();
}
ThreadUtil.sleep(3000);
}
}
public File getPropertyFile() {
if (propertyFile != null) {
return propertyFile;
}
String s = System.getProperty("scouter.config", "./scouter.conf");
propertyFile = new File(s.trim());
return propertyFile;
}
public synchronized boolean reload(boolean force) {
long now = System.currentTimeMillis();
if (force == false && now < last_check + 3000)
return false;
last_check = now;
File file = getPropertyFile();
if (file.lastModified() == last_load_time) {
return false;
}
last_load_time = file.lastModified();
Properties temp = new Properties();
if (file.canRead()) {
FileInputStream in = null;
try {
in = new FileInputStream(file);
temp.load(in);
} catch (Exception e) {
e.printStackTrace();
} finally {
FileUtil.close(in);
}
}
property = ConfigValueUtil.replaceSysProp(temp);
apply();
ConfObserver.run();
return true;
}
private void apply() {
this.profile_http_querystring_enabled = getBoolean("profile_http_querystring_enabled", false);
this.profile_http_header_enabled = getBoolean("profile_http_header_enabled", false);
this.profile_http_parameter_enabled = getBoolean("profile_http_parameter_enabled", false);
this.profile_summary_mode_enabled = getBoolean("profile_summary_mode_enabled", false);
this.xlog_lower_bound_time_ms = getInt("xlog_lower_bound_time_ms", 0);
this.trace_service_name_header_key = getValue("trace_service_name_header_key", null);
this.trace_service_name_get_key = getValue("trace_service_name_get_key");
this.trace_service_name_post_key = getValue("trace_service_name_post_key");
this.dump_dir = new File(getValue("dump_dir", "./dump"));
try {
this.dump_dir.mkdirs();
} catch (Exception e) {
}
// this.mgr_agent_lib_dir = new File(getValue("mgr_agent_lib_dir", "./_scouter_"));
// try {
// this.mgr_agent_lib_dir.mkdirs();
// } catch (Exception e) {
// }
this.plugin_dir = new File(getValue("plugin_dir", "./plugin"));
this.autodump_enabled = getBoolean("autodump_enabled", false);
this.autodump_trigger_active_service_cnt = getInt("autodump_trigger_active_service_cnt", 10000);
if (this.autodump_trigger_active_service_cnt < 1) {
this.autodump_trigger_active_service_cnt = 1;
}
this.autodump_level = getInt("autodump_level", 1);
this.autodump_interval_ms = getInt("autodump_interval_ms", 30000);
if (this.autodump_interval_ms < 5000) {
this.autodump_interval_ms = 5000;
}
this.autodump_stuck_thread_ms = getInt("autodump_stuck_thread_ms", 0);
this.mgr_static_content_extensions = getValue("mgr_static_content_extensions", "js, htm, html, gif, png, jpg, css");
this.profile_thread_cputime_enabled = getBoolean("profile_thread_cputime_enabled", false);
this.profile_socket_open_fullstack_enabled = getBoolean("profile_socket_open_fullstack_enabled", false);
this.trace_background_socket_enabled = getBoolean("trace_background_socket_enabled", true);
this.profile_socket_open_fullstack_port = getInt("profile_socket_open_fullstack_port", 0);
this.profile_sql_escape_enabled = getBoolean("profile_sql_escape_enabled", true);
this.profile_sqlmap_name_enabled = getBoolean("profile_sqlmap_name_enabled", true);
this.net_udp_packet_max_bytes = getInt("net_udp_packet_max_bytes", 60000);
this.trace_activeserivce_yellow_time = getLong("trace_activeserivce_yellow_time", 3000);
this.trace_activeservice_red_time = getLong("trace_activeservice_red_time", 8000);
this.mgr_log_ignore_ids = getValue("mgr_log_ignore_ids", "");
this.log_ignore_set = getStringSet("mgr_log_ignore_ids", ",");
this._log_udp_xlog_enabled = getBoolean("_log_udp_xlog_enabled", false);
this._log_udp_counter_enabled = getBoolean("_log_udp_counter_enabled", false);
this._log_udp_object_enabled = getBoolean("_log_udp_object_enabled", false);
this.net_local_udp_ip = getValue("net_local_udp_ip");
this.net_local_udp_port = getInt("net_local_udp_port", 0);
this.net_collector_ip = getValue("net_collector_ip", "127.0.0.1");
this.net_collector_udp_port = getInt("net_collector_udp_port", NetConstants.SERVER_UDP_PORT);
this.net_collector_tcp_port = getInt("net_collector_tcp_port", NetConstants.SERVER_TCP_PORT);
this.net_collector_tcp_session_count = getInt("net_collector_tcp_session_count", 1, 1);
this.net_collector_tcp_connection_timeout_ms = getInt("net_collector_tcp_connection_timeout_ms", 3000);
this.net_collector_tcp_so_timeout_ms = getInt("net_collector_tcp_so_timeout_ms", 60000);
this.hook_signature = 0;
this.hook_args_patterns = getValue("hook_args_patterns", "");
this.hook_return_patterns = getValue("hook_return_patterns", "");
this.hook_constructor_patterns = getValue("hook_constructor_patterns", "");
this.hook_connection_open_patterns = getValue("hook_connection_open_patterns", "");
this._log_datasource_lookup_enabled = getBoolean("_log_datasource_lookup_enabled", true);
this.profile_connection_open_enabled = getBoolean("profile_connection_open_enabled", true);
this._summary_connection_leak_fullstack_enabled = getBoolean("_summary_connection_leak_fullstack_enabled", false);
this.hook_method_patterns = getValue("hook_method_patterns", "");
this.hook_method_exclude_patterns = getValue("hook_method_exclude_patterns", "");
this.hook_method_access_public_enabled = getBoolean("hook_method_access_public_enabled", true);
this.hook_method_access_protected_enabled = getBoolean("hook_method_access_protected_enabled", false);
this.hook_method_access_private_enabled = getBoolean("hook_method_access_private_enabled", false);
this.hook_method_access_none_enabled = getBoolean("hook_method_access_none_enabled", false);
this.hook_method_ignore_prefixes = StringUtil.removeWhitespace(getValue("hook_method_ignore_prefixes", "get,set"));
this._hook_method_ignore_prefix = StringUtil.split(this.hook_method_ignore_prefixes, ",");
this._hook_method_ignore_prefix_len = this._hook_method_ignore_prefix == null ? 0
: this._hook_method_ignore_prefix.length;
this.hook_method_ignore_classes = StringUtil.trimEmpty(StringUtil.removeWhitespace(getValue(
"hook_method_ignore_classes", "")));
this._hook_method_ignore_classes = new StringSet(StringUtil.tokenizer(
this.hook_method_ignore_classes.replace('.', '/'), ","));
this.profile_method_enabled = getBoolean("profile_method_enabled", true);
this.hook_service_patterns = getValue("hook_service_patterns", "");
this.hook_apicall_patterns = getValue("hook_apicall_patterns", "");
this.hook_apicall_info_patterns = getValue("hook_apicall_info_patterns", "");
this.hook_jsp_patterns = getValue("hook_jsp_patterns", "");
this.hook_jdbc_pstmt_classes = getValue("hook_jdbc_pstmt_classes", "");
this.hook_jdbc_stmt_classes = getValue("hook_jdbc_stmt_classes", "");
this.hook_jdbc_rs_classes = getValue("hook_jdbc_rs_classes", "");
this.hook_jdbc_wrapping_driver_patterns = getValue("hook_jdbc_wrapping_driver_patterns", "");
this.hook_add_fields = getValue("hook_add_fields", "");
this.hook_context_classes = getValue("hook_context_classes", "javax/naming/InitialContext");
this.hook_signature ^= this.hook_args_patterns.hashCode();
this.hook_signature ^= this.hook_return_patterns.hashCode();
this.hook_signature ^= this.hook_constructor_patterns.hashCode();
this.hook_signature ^= this.hook_connection_open_patterns.hashCode();
this.hook_signature ^= this.hook_method_patterns.hashCode();
this.hook_signature ^= this.hook_service_patterns.hashCode();
this.hook_signature ^= this.hook_apicall_patterns.hashCode();
this.hook_signature ^= this.hook_jsp_patterns.hashCode();
this.hook_signature ^= this.hook_jdbc_wrapping_driver_patterns.hashCode();
this.control_reject_service_enabled = getBoolean("control_reject_service_enabled", false);
this.control_reject_service_max_count = getInt("control_reject_service_max_count", 10000);
this.control_reject_redirect_url_enabled = getBoolean("control_reject_redirect_url_enabled", false);
this.control_reject_text = getValue("control_reject_text", "too many request!!");
this.control_reject_redirect_url = getValue("control_reject_redirect_url", "/error.html");
this.profile_step_max_count = getInt("profile_step_max_count", 1024);
if (this.profile_step_max_count < 100)
this.profile_step_max_count = 100;
this._log_background_sql = getBoolean("_log_background_sql", false);
this.profile_fullstack_service_error_enabled = getBoolean("profile_fullstack_service_error_enabled", false);
this.profile_fullstack_apicall_error_enabled = getBoolean("profile_fullstack_apicall_error_enabled", false);
this.profile_fullstack_sql_error_enabled = getBoolean("profile_fullstack_sql_error_enabled", false);
this.profile_fullstack_sql_commit_enabled = getBoolean("profile_fullstack_sql_commit_enabled", false);
this.profile_fullstack_max_lines = getInt("profile_fullstack_max_lines", 0);
this.profile_fullstack_rs_leak_enabled = getBoolean("profile_fullstack_rs_leak_enabled", false);
this.profile_fullstack_stmt_leak_enabled = getBoolean("profile_fullstack_stmt_leak_enabled", false);
this.net_udp_collection_interval_ms = getInt("net_udp_collection_interval_ms", 100);
this.profile_http_parameter_url_prefix = getValue("profile_http_parameter_url_prefix", "/");
this.profile_http_header_url_prefix = getValue("profile_http_header_url_prefix", "/");
this.trace_http_client_ip_header_key = getValue("trace_http_client_ip_header_key", "");
this.trace_interservice_enabled = getBoolean("trace_interservice_enabled", false);
this.trace_response_gxid_enabled = getBoolean("trace_response_gxid_enabled", false);
this._trace_interservice_gxid_header_key = getValue("_trace_interservice_gxid_header_key", "X-Scouter-Gxid");
this._trace_interservice_callee_header_key = getValue("_trace_interservice_callee_header_key", "X-Scouter-Callee");
this._trace_interservice_caller_header_key = getValue("_trace_interservice_caller_header_key", "X-Scouter-Caller");
this.profile_connection_open_fullstack_enabled = getBoolean("profile_connection_open_fullstack_enabled", false);
this.profile_connection_autocommit_status_enabled = getBoolean("profile_connection_autocommit_status_enabled", false);
this.trace_user_mode = getInt("trace_user_mode", 2);
this.trace_user_session_key = getValue("trace_user_session_key", "JSESSIONID");
this._trace_auto_service_enabled = getBoolean("_trace_auto_service_enabled", false);
this._trace_auto_service_backstack_enabled = getBoolean("_trace_auto_service_backstack_enabled", true);
this.counter_enabled = getBoolean("counter_enabled", true);
this._hook_serivce_enabled = getBoolean("_hook_serivce_enabled", true);
this._hook_dbsql_enabled = getBoolean("_hook_dbsql_enabled", true);
this._hook_dbconn_enabled = getBoolean("_hook_dbconn_enabled", true);
this._hook_cap_enabled = getBoolean("_hook_cap_enabled", true);
this._hook_methods_enabled = getBoolean("_hook_methods_enabled", true);
this._hook_socket_enabled = getBoolean("_hook_socket_enabled", true);
this._hook_jsp_enabled = getBoolean("_hook_jsp_enabled", true);
this._hook_async_enabled = getBoolean("_hook_async_enabled", true);
this.trace_db2_enabled = getBoolean("trace_db2_enabled", true);
this._hook_usertx_enabled = getBoolean("_hook_usertx_enabled", true);
this._hook_direct_patch_classes = getValue("_hook_direct_patch_classes", "");
this._hook_boot_prefix = getValue("_hook_boot_prefix");
this.counter_recentuser_valid_ms = getLong("counter_recentuser_valid_ms", DateUtil.MILLIS_PER_FIVE_MINUTE);
this.counter_object_registry_path = getValue("counter_object_registry_path", "/tmp/scouter");
this.sfa_dump_enabled = getBoolean("sfa_dump_enabled", false);
this.sfa_dump_interval_ms = getInt("sfa_dump_interval_ms", 10000);
// 웹시스템으로 부터 WAS 사이의 성능과 어떤 웹서버가 요청을 보내 왔는지를 추적하는 기능을 ON/OFF하고
// 관련 키정보를 지정한다.
this.trace_webserver_enabled = getBoolean("trace_webserver_enabled", false);
this.trace_webserver_name_header_key = getValue("trace_webserver_name_header_key", "X-Forwarded-Host");
this.trace_webserver_time_header_key = getValue("trace_webserver_time_header_key", "X-Forwarded-Time");
this.trace_rs_leak_enabled = getBoolean("trace_rs_leak_enabled", false);
this.trace_stmt_leak_enabled = getBoolean("trace_stmt_leak_enabled", false);
// SUMMARY최대 갯수를 관리한다.
this.summary_enabled = getBoolean("summary_enabled", true);
this._summary_sql_max_count = getInt("_summary_sql_max_count", 5000);
this._summary_api_max_count = getInt("_summary_api_max_count", 5000);
this._summary_service_max_count = getInt("_summary_service_max_count", 5000);
this._summary_ip_max_count = getInt("_summary_ip_max_count", 5000);
this._summary_useragent_max_count = getInt("_summary_useragent_max_count", 5000);
this._summary_error_max_count = getInt("_summary_error_max_count", 500);
this._summary_enduser_nav_max_count = getInt("_summary_enduser_nav_max_count", 5000);
this._summary_enduser_ajax_max_count = getInt("_summary_enduser_ajax_max_count", 5000);
this._summary_enduser_error_max_count = getInt("_summary_enduser_error_max_count", 5000);
//Experimental(ignoreset)
this.__experimental = getBoolean("__experimental", false);
this.__control_connection_leak_autoclose_enabled = getBoolean("__control_connection_leak_autoclose_enabled", false);
//For testing
this.__ip_dummy_test = getBoolean("__ip_dummy_test", false);
this.alert_perm_warning_pct = getInt("alert_perm_warning_pct", 90);
this._hook_spring_rest_enabled = getBoolean("_hook_spring_rest_enabled", false);
this.alert_message_length = getInt("alert_message_length", 3000);
this.alert_send_interval_ms = getInt("alert_send_interval_ms", 3000);
this.xlog_error_jdbc_fetch_max = getInt("xlog_error_jdbc_fetch_max", 10000);
this.xlog_error_sql_time_max_ms = getInt("xlog_error_sql_time_max_ms", 30000);
this._log_asm_enabled = getBoolean("_log_asm_enabled", false);
this.obj_type_inherit_to_child_enabled = getBoolean("obj_type_inherit_to_child_enabled", false);
this._profile_fullstack_sql_connection_enabled = getBoolean("_profile_fullstack_sql_connection_enabled", false);
this._trace_fullstack_socket_open_port = getInt("_trace_fullstack_socket_open_port", 0);
this.log_dir = getValue("log_dir", "");
this.log_rotation_enabled = getBoolean("log_rotation_enabled", true);
this.log_keep_days = getInt("log_keep_days", 7);
this._trace = getBoolean("_trace", false);
this._trace_use_logger = getBoolean("_trace_use_logger", false);
this.enduser_trace_endpoint_url = getValue("enduser_trace_endpoint_url", "_scouter_browser.jsp");
this.enduser_perf_endpoint_hash = HashUtil.hash(this.enduser_trace_endpoint_url);
this.xlog_error_check_user_transaction_enabled = getBoolean("xlog_error_check_user_transaction_enabled", true);
resetObjInfo();
setStaticContents();
}
public int getObjHash() {
return this.objHash;
}
public String getObjName() {
return this.objName;
}
public int getObjHostHash(){
return this.objHostHash;
}
public String getObjHostName() {
return this.objHostName;
}
public int getEndUserPerfEndpointHash() {
return this.enduser_perf_endpoint_hash;
}
public boolean isIgnoreLog(String id) {
return log_ignore_set.hasKey(id);
}
private StringSet getStringSet(String key, String deli) {
StringSet set = new StringSet();
String v = getValue(key);
if (v != null) {
String[] vv = StringUtil.split(v, deli);
for (String x : vv) {
x = StringUtil.trimToEmpty(x);
if (x.length() > 0)
set.put(x);
}
}
return set;
}
private void setStaticContents() {
Set<String> tmp = new HashSet<String>();
String[] s = StringUtil.split(this.mgr_static_content_extensions, ',');
for (int i = 0; i < s.length; i++) {
String ss = s[i].trim();
if (ss.length() > 0) {
tmp.add(ss);
}
}
static_contents = tmp;
}
public boolean isStaticContents(String content) {
return static_contents.contains(content);
}
public boolean isIgnoreMethodPrefix(String name) {
for (int i = 0; i < this._hook_method_ignore_prefix_len; i++) {
if (name.startsWith(this._hook_method_ignore_prefix[i]))
return true;
}
return false;
}
public boolean isIgnoreMethodClass(String classname) {
return _hook_method_ignore_classes.hasKey(classname);
}
public synchronized void resetObjInfo() {
String detected = ObjTypeDetector.drivedType != null ? ObjTypeDetector.drivedType
: ObjTypeDetector.objType != null ? ObjTypeDetector.objType : CounterConstants.JAVA;
this.obj_type = getValue("obj_type", detected);
detected = CounterConstants.HOST;
if (SystemUtil.IS_LINUX) {
detected = CounterConstants.LINUX;
} else if (SystemUtil.IS_WINDOWS) {
detected = CounterConstants.WINDOWS;
} else if (SystemUtil.IS_MAC_OSX) {
detected = CounterConstants.OSX;
} else if (SystemUtil.IS_AIX) {
detected = CounterConstants.AIX;
} else if (SystemUtil.IS_HP_UX) {
detected = CounterConstants.HPUX;
}
this.obj_host_type = getValue("obj_host_type", detected);
this.obj_host_name = getValue("obj_host_name", SysJMX.getHostName());
this.objHostName = "/" + this.obj_host_name;
this.objHostHash = HashUtil.hash(objHostName);
this.obj_name_auto_pid_enabled = getBoolean("obj_name_auto_pid_enabled", false);
String defaultName;
if (this.obj_name_auto_pid_enabled == true) {
defaultName = "" + SysJMX.getProcessPID();
} else {
defaultName = this.obj_type + "1";
}
this.obj_name = getValue("obj_name", System.getProperty("jvmRoute", defaultName));
this.objName = objHostName + "/" + this.obj_name;
this.objHash = HashUtil.hash(objName);
System.setProperty("scouter.objname", this.objName);
System.setProperty("scouter.objtype", this.obj_type);
System.setProperty("scouter.dir", new File(".").getAbsolutePath());
}
public String getValue(String key) {
return StringUtil.trim(property.getProperty(key));
}
public String getValue(String key, String def) {
return StringUtil.trim(property.getProperty(key, def));
}
public int getInt(String key, int def) {
try {
String v = getValue(key);
if (v != null)
return Integer.parseInt(v);
} catch (Exception e) {
}
return def;
}
public int getInt(String key, int def, int min) {
try {
String v = getValue(key);
if (v != null) {
return Math.max(Integer.parseInt(v), min);
}
} catch (Exception e) {
}
return Math.max(def, min);
}
public long getLong(String key, long def) {
try {
String v = getValue(key);
if (v != null)
return Long.parseLong(v);
} catch (Exception e) {
}
return def;
}
public boolean getBoolean(String key, boolean def) {
try {
String v = getValue(key);
if (v != null)
return Boolean.parseBoolean(v);
} catch (Exception e) {
}
return def;
}
public String loadText() {
File file = getPropertyFile();
InputStream fin = null;
try {
fin = new FileInputStream(file);
byte[] buff = FileUtil.readAll(fin);
return new String(buff);
} catch (Exception e) {
} finally {
FileUtil.close(fin);
}
return null;
}
public boolean saveText(String text) {
File file = getPropertyFile();
OutputStream out = null;
try {
if (file.getParentFile().exists() == false) {
file.getParentFile().mkdirs();
}
out = new FileOutputStream(file);
out.write(text.getBytes());
return true;
} catch (Exception e) {
} finally {
FileUtil.close(out);
}
return false;
}
public void printConfig() {
Logger.info("Configure -Dscouter.config=" + propertyFile);
}
private static HashSet<String> ignoreSet = new HashSet<String>();
static {
ignoreSet.add("property");
ignoreSet.add("__experimental");
}
public MapValue getKeyValueInfo() {
StringKeyLinkedMap<Object> defMap = ConfigValueUtil.getConfigDefault(new Configure(true));
StringKeyLinkedMap<Object> curMap = ConfigValueUtil.getConfigDefault(this);
MapValue m = new MapValue();
ListValue nameList = m.newList("key");
ListValue valueList = m.newList("value");
ListValue defList = m.newList("default");
StringEnumer enu = defMap.keys();
while (enu.hasMoreElements()) {
String key = enu.nextString();
if (ignoreSet.contains(key))
continue;
nameList.add(key);
valueList.add(ConfigValueUtil.toValue(curMap.get(key)));
defList.add(ConfigValueUtil.toValue(defMap.get(key)));
}
return m;
}
public int getHookSignature() {
return this.hook_signature;
}
public static void main(String[] args) {
StringKeyLinkedMap<Object> defMap = ConfigValueUtil.getConfigDefault(new Configure(true));
StringEnumer enu = defMap.keys();
while (enu.hasMoreElements()) {
String key = enu.nextString();
if (ignoreSet.contains(key))
continue;
System.out.println(key + " : " + ConfigValueUtil.toValue(defMap.get(key)));
}
}
}