Skip to content

Commit 2241f26

Browse files
committed
Merge pull request #119 from scouter-project/master
merge for release
2 parents eaaa5be + 9da22dd commit 2241f26

File tree

67 files changed

+2883
-1418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2883
-1418
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ SCOUTER can help you.
3535
## Documents
3636
- [Document Home](./scouter.document/index.md)
3737
- [Quick Start Guide (Quick Installation and Demo)](./scouter.document/main/Quick-Start.md)
38+
- [Live Demo(Try to use scouter by connecting on live demo system)](./scouter.document/main/Live-Demo.md)
3839
- [Client Screen Help](./scouter.document/client/How-To-Use-Client.md)
3940

4041
## Download
@@ -67,12 +68,16 @@ Scouter has three modules:
6768
- **SWT & GEF4** : Charts and Diagrams
6869
<br>
6970

71+
## Facebook
72+
- [Scouter APM : Facebook Scouter user group](https://www.facebook.com/groups/scouterapm/)
73+
74+
## How to contribute
75+
- TBD
76+
77+
7078
## Q&A
7179
- [Google Groups](https://groups.google.com/forum/#!forum/scouter-project)
7280

73-
## Facebook
74-
- [Facebook Scouter user group](https://www.facebook.com/groups/1525329794448529/)
75-
7681
## License
7782
Licensed under the Apache License, Version 2.0
7883
<br>

README_kr.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ APM은 Application performance montoring 또는 application performance manageme
3030
## Documents
3131
- [Document Home](./scouter.document/index_kr.md)
3232
- [Quick Start(Scouter Demo 설치)](./scouter.document/main/Quick-Start_kr.md)
33+
- [Live Demo(제공되는 Demo 시스템 바로 접속해 보기)](./scouter.document/main/Live-Demo_kr.md)
3334
- [Client 화면 설명](./scouter.document/client/How-To-Use-Client_kr.md)
3435

3536
## Download
@@ -62,12 +63,15 @@ APM은 Application performance montoring 또는 application performance manageme
6263
- **SWT & GEF4** : Charts and Diagrams
6364
<br>
6465

66+
## Facebook
67+
- [Scouter APM 사용자 모임 - Facebook 그룹](https://www.facebook.com/groups/scouterapm/)
68+
69+
## Scouter에 기여하기
70+
- TBD
71+
6572
## Q&A
6673
- [Google Groups](https://groups.google.com/forum/#!forum/scouter-project)
6774

68-
## Facebook
69-
- [Facebook Scouter user group](https://www.facebook.com/groups/1525329794448529/)
70-
7175
## License
7276
Licensed under the Apache License, Version 2.0
7377
<br>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright 2015 the original author or authors.
3+
* @https://github.com/scouter-project/scouter
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package scouter.agent.counter.meter;
19+
20+
import scouter.lang.ref.DOUBLE;
21+
import scouter.lang.ref.INT;
22+
import scouter.util.MeteringUtil;
23+
import scouter.util.MeteringUtil.Handler;
24+
25+
public class MeterResource {
26+
27+
static class Bucket {
28+
double value;
29+
int count;
30+
}
31+
private MeteringUtil<Bucket> meter = new MeteringUtil<Bucket>() {
32+
protected Bucket create() {
33+
return new Bucket();
34+
};
35+
36+
protected void clear(Bucket o) {
37+
o.value=0;
38+
o.count = 0;
39+
}
40+
};
41+
42+
public synchronized void add(double value) {
43+
Bucket b = meter.getCurrentBucket();
44+
b.value += value;
45+
b.count++;
46+
}
47+
48+
public double getAvg(int period) {
49+
final INT count = new INT();
50+
final DOUBLE sum = new DOUBLE();
51+
meter.search(period, new Handler<MeterResource.Bucket>() {
52+
public void process(Bucket u) {
53+
sum.value += u.value;
54+
count.value += u.count;
55+
}
56+
});
57+
return count.value == 0 ? 0 : sum.value / count.value;
58+
}
59+
60+
public double getSum(int period) {
61+
final DOUBLE sum = new DOUBLE();
62+
meter.search(period, new Handler<MeterResource.Bucket>() {
63+
public void process(Bucket u) {
64+
sum.value += u.value;
65+
}
66+
});
67+
return sum.value;
68+
}
69+
70+
}

scouter.agent.host/src/scouter/agent/counter/task/HostPerf.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import scouter.agent.Logger;
1717
import scouter.agent.counter.CounterBasket;
1818
import scouter.agent.counter.anotation.Counter;
19+
import scouter.agent.counter.meter.MeterResource;
1920
import scouter.agent.netio.data.DataProxy;
2021
import scouter.lang.AlertLevel;
2122
import scouter.lang.TimeTypeEnum;
@@ -31,7 +32,11 @@ public class HostPerf {
3132
static int SLEEP_TIME = 2000;
3233
static Sigar sigarImpl = new Sigar();
3334
static SigarProxy sigar = SigarProxyCache.newInstance(sigarImpl, SLEEP_TIME);
34-
35+
36+
MeterResource cpuMeter = new MeterResource();
37+
MeterResource sysCpuMeter = new MeterResource();
38+
MeterResource userCpuMeter = new MeterResource();
39+
3540
@Counter
3641
public void process(CounterBasket pw) {
3742
try {
@@ -48,10 +53,18 @@ void domain(CounterBasket pw) throws SigarException {
4853

4954
CpuPerc cpuPerc = sigar.getCpuPerc();
5055
float cpu = (float) ((1.0D - cpuPerc.getIdle()) * 100);
51-
alertCpu(cpu);
56+
cpuMeter.add(cpu);
5257
float sysCpu = (float) cpuPerc.getSys() * 100;
58+
sysCpuMeter.add(sysCpu);
5359
float userCpu = (float) cpuPerc.getUser() * 100;
60+
userCpuMeter.add(userCpu);
61+
62+
cpu = (float) cpuMeter.getAvg(10);
63+
sysCpu = (float) sysCpuMeter.getAvg(10);
64+
userCpu = (float) userCpuMeter.getAvg(10);
5465

66+
alertCpu(cpu);
67+
5568
Mem m = sigar.getMem();
5669
alertMem(m);
5770

scouter.agent.java/src/scouter/AnyTrace.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
package scouter;
1919

2020
import scouter.agent.netio.data.DataProxy;
21-
import scouter.agent.trace.AlertProxy;
2221
import scouter.agent.trace.TraceApiCall;
2322
import scouter.agent.trace.TraceContext;
2423
import scouter.agent.trace.TraceContextManager;
2524
import scouter.agent.trace.TraceMain;
2625
import scouter.lang.pack.XLogTypes;
27-
import scouter.util.HashUtil;
2826
import scouter.util.KeyGen;
2927

3028
public class AnyTrace {
@@ -42,7 +40,7 @@ public static void setServiceName(String name) {
4240
}
4341

4442
public static void serviceError(String emsg) {
45-
TraceContext ctx = TraceContextManager.getLocalContext();
43+
TraceContext ctx = TraceContextManager.getContext();
4644
if (ctx != null && ctx.error != 0) { // already started
4745
ctx.error = DataProxy.sendError(emsg);
4846
}
@@ -70,7 +68,7 @@ public static Object startApicall(String name, long apiTxid) {
7068

7169
public static void setApicallName(String name) {
7270
try {
73-
TraceContext ctx = TraceContextManager.getLocalContext();
71+
TraceContext ctx = TraceContextManager.getContext();
7472
if (ctx != null) {
7573
if (ctx.apicall_name != null) { // already started subcall only
7674
ctx.apicall_name = name;
@@ -86,7 +84,7 @@ public static void endApicall(Object stat, Throwable thr) {
8684

8785
public static void desc(String desc) {
8886
try {
89-
TraceContext ctx = TraceContextManager.getLocalContext();
87+
TraceContext ctx = TraceContextManager.getContext();
9088
if (ctx != null) {
9189
ctx.desc = desc;
9290
}
@@ -96,7 +94,7 @@ public static void desc(String desc) {
9694

9795
public static void login(String login) {
9896
try {
99-
TraceContext ctx = TraceContextManager.getLocalContext();
97+
TraceContext ctx = TraceContextManager.getContext();
10098
if (ctx != null) {
10199
ctx.login = login;
102100
}

scouter.agent.java/src/scouter/agent/AgentTransformer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ public byte[] transform(ClassLoader loader, String className, Class classBeingRe
109109
AsyncRunner.getInstance().add(loader, className, classfileBuffer);
110110
return null;
111111
}
112-
if (loader == null) {
113-
return null;
112+
if (loader == null ) {
113+
if(conf._hook_boot_prefix==null || conf._hook_boot_prefix.length()==0 || false == className.startsWith(conf._hook_boot_prefix)){
114+
return null;
115+
}
114116
}
115117
}
116118
if (className.startsWith("scouter/")) {

scouter.agent.java/src/scouter/agent/Configure.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
public class Configure extends Thread {
3232
public static boolean JDBC_REDEFINED = false;
3333
private static Configure instance = null;
34+
3435
public final static synchronized Configure getInstance() {
3536
if (instance == null) {
3637
instance = new Configure();
@@ -182,6 +183,7 @@ public final static synchronized Configure getInstance() {
182183
public boolean _hook_usertx_enabled = true;
183184
public String _hook_direct_patch_classes = "";
184185
public boolean _hook_spring_rest_enabled = false;
186+
public String _hook_boot_prefix=null;
185187

186188
//Control
187189
public boolean control_reject_service_enabled = false;
@@ -443,6 +445,7 @@ private void apply() {
443445
this.trace_db2_enabled = getBoolean("trace_db2_enabled", true);
444446
this._hook_usertx_enabled = getBoolean("_hook_usertx_enabled", true);
445447
this._hook_direct_patch_classes = getValue("_hook_direct_patch_classes", "");
448+
this._hook_boot_prefix = getValue("_hook_boot_prefix");
446449
this.counter_recentuser_valid_ms = getLong("counter_recentuser_valid_ms", DateUtil.MILLIS_PER_FIVE_MINUTE);
447450
this.counter_object_registry_path = getValue("counter_object_registry_path", "/tmp/scouter");
448451
this.sfa_dump_enabled = getBoolean("sfa_dump_enabled", false);

scouter.agent.java/src/scouter/agent/asm/JDBCPreparedStatementASM.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class JDBCPreparedStatementASM implements IASM, Opcodes {
3838
public final HashSet<String> target = HookingSet.getHookingClassSet(Configure.getInstance().hook_jdbc_pstmt_classes);
3939
public final HashSet<String> noField = new HashSet<String>();
4040
public JDBCPreparedStatementASM() {
41+
target.add("org.mariadb.jdbc.MariaDbClientPreparedStatement");
4142
target.add("org/mariadb/jdbc/MySQLPreparedStatement");
4243
target.add("oracle/jdbc/driver/OraclePreparedStatement");
4344
target.add("org/postgresql/jdbc2/AbstractJdbc2Statement");
@@ -53,6 +54,7 @@ public JDBCPreparedStatementASM() {
5354
target.add("cubrid/jdbc/driver/CUBRIDPreparedStatement");
5455

5556
// @skyworker - MySQL ServerPreparedStatement는 특별히 필드를 추가하지 않음
57+
noField.add("org.mariadb.jdbc.MariaDbClientPreparedStatement");
5658
noField.add("com/mysql/jdbc/ServerPreparedStatement");
5759
noField.add("jdbc/FakePreparedStatement2");
5860
}

scouter.agent.java/src/scouter/agent/asm/JDBCStatementASM.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public class JDBCStatementASM implements IASM, Opcodes {
3737
public final HashSet<String> target = HookingSet.getHookingClassSet(Configure.getInstance().hook_jdbc_stmt_classes);
3838
public JDBCStatementASM() {
39-
39+
target.add("org.mariadb.jdbc.MariaDbStatement");
4040
target.add("org/mariadb/jdbc/MySQLStatement");
4141
target.add("oracle/jdbc/driver/OracleStatement");
4242
target.add("com/mysql/jdbc/StatementImpl");

scouter.agent.java/src/scouter/agent/asm/util/HookingSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static HashSet<String> getHookingClassSet(String arg) {
165165
if(c ==null)
166166
return classSet;
167167
for (int i = 0; i < c.length; i++) {
168-
classSet.add(c[i]);
168+
classSet.add(c[i].replace('.', '/').trim());
169169
}
170170
return classSet;
171171
}

0 commit comments

Comments
 (0)