Skip to content

Commit 8d0b67a

Browse files
committed
Merge pull request #29 from scouter-project/dev
Dev
2 parents b85f910 + 436e93f commit 8d0b67a

File tree

128 files changed

+3565
-1545
lines changed

Some content is hidden

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

128 files changed

+3565
-1545
lines changed

scouter.agent.host/src/scouter/agent/netio/data/net/TcpRequestMgr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static synchronized TcpRequestMgr getInstance() {
2121
return instance;
2222
}
2323

24-
protected Executor pool = ThreadUtil.createExecutor("SCOUTER", 10, 10, true);
24+
protected Executor pool = ThreadUtil.createExecutor("SCOUTER", 10, 10000, true);
2525

2626
@Override
2727
public void run() {

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ public final static synchronized Configure getInstance() {
104104
public boolean enable_profile_summary = false;
105105
public boolean profile_thread_cputime = false;
106106
public boolean profile_socket_openstack = false;
107-
public boolean debug_socket_openstack = false;
108107
public int profile_socket_openstack_port = 0;
109-
public int debug_socket_openstack_port = 0;
110-
108+
109+
public boolean listup_background_socket = true;
110+
111111
public int xlog_time_limit = 0;
112112

113113
public String http_error_status = "";
@@ -196,7 +196,7 @@ public final static synchronized Configure getInstance() {
196196

197197
public String http_remote_ip_header_key = "";
198198
public boolean enable_trace_e2e = false;
199-
public String gxid = "gxid";
199+
public String gxid = "scouter_gxid";
200200
public boolean enable_response_gxid = false;
201201
public String this_txid = "scouter_this_txid";
202202
public String caller_txid = "scouter_caller_txid";
@@ -363,9 +363,8 @@ private void apply() {
363363
this.profile_thread_cputime = getBoolean("profile_thread_cputime", getBoolean("profile.thread.cputime", false));
364364
this.profile_socket_openstack = getBoolean("profile_socket_openstack",
365365
getBoolean("profile.socket.openstack", false));
366-
this.debug_socket_openstack = getBoolean("debug_socket_openstack", getBoolean("debug.socket.openstack", false));
366+
this.listup_background_socket = getBoolean("listup_background_socket", true);
367367
this.profile_socket_openstack_port = getInt("profile_socket_openstack_port", 0);
368-
this.debug_socket_openstack_port = getInt("debug_socket_openstack_port", 0);
369368
this.profile_sql_escape = getBoolean("profile_sql_escape", true);
370369

371370
this.enable_asm_jdbc = getBoolean("enable_asm_jdbc", getBoolean("enable.asm.jdbc", true));
@@ -500,6 +499,9 @@ private void apply() {
500499
this.max_think_time = getLong("max_think_time", DateUtil.MILLIS_PER_FIVE_MINUTE);
501500

502501
this.object_registry = getValue("object_registry", "/tmp/scouter");
502+
503+
this.pstack_enabled = getBoolean("pstack_enabled", false);;
504+
this.pstack_interval = getInt("pstack_interval", 10000);
503505

504506
resetObjInfo();
505507
setErrorStatus();

scouter.agent.java/src/scouter/agent/ObjTypeDetector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public class ObjTypeDetector {
2929
public static Set<String> extClass = new HashSet<String>();
3030
static {
3131
bootClass.put("org/eclipse/jetty/server/Server", CounterConstants.JETTY);
32-
bootClass.put("org/jboss/Main", CounterConstants.JBOSS);
32+
bootClass.put("org/jboss/Main", CounterConstants.JBOSS); // jboss as 6.1.0
33+
bootClass.put("org/jboss/as/server/Main", CounterConstants.JBOSS); // jboss as 7.2.0 final
3334
bootClass.put("org/apache/catalina/startup/Bootstrap", CounterConstants.TOMCAT);
3435
bootClass.put("org/apache/catalina/startup/Tomcat", CounterConstants.TOMCAT);
3536
}

scouter.agent.java/src/scouter/agent/asm/ApicallASM.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import scouter.org.objectweb.asm.commons.LocalVariablesSorter;
3535

3636
public class ApicallASM implements IASM, Opcodes {
37-
// private Map<String, MethodSet> target =
38-
// MethodSet.getHookingSet("hook.subcall");
3937
private List<MethodSet> target = MethodSet.getHookingMethodSet(Configure.getInstance().hook_apicall);
4038
private Map<String, MethodSet> reserved = new HashMap<String, MethodSet>();
4139

scouter.agent.java/src/scouter/agent/counter/CounterBasket.java

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,61 @@
1414
* limitations under the License.
1515
*/
1616

17-
package scouter.agent.counter;
18-
17+
package scouter.agent.counter;
18+
1919
import java.util.ArrayList;
2020
import java.util.HashMap;
2121
import java.util.Map;
2222

2323
import scouter.agent.Configure;
2424
import scouter.lang.TimeTypeEnum;
2525
import scouter.lang.pack.PerfCounterPack;
26-
27-
public class CounterBasket {
28-
private class Key {
29-
private String objName;
30-
private byte timeType;
31-
32-
public Key(String objName, byte timeType) {
33-
this.objName = objName;
34-
this.timeType = timeType;
35-
}
36-
37-
@Override
38-
public boolean equals(Object obj) {
39-
if (obj instanceof Key) {
40-
Key k = (Key) obj;
41-
return this.objName.equals(k.objName) && this.timeType==k.timeType;
42-
}
43-
return false;
44-
}
45-
46-
@Override
47-
public int hashCode() {
48-
49-
return objName.hashCode() ^ timeType;
50-
}
51-
}
52-
53-
private Map<Key, PerfCounterPack> table = new HashMap<CounterBasket.Key, PerfCounterPack>();
54-
55-
public PerfCounterPack getPack(String objName, byte timeType) {
56-
Key key = new Key(objName, timeType);
57-
PerfCounterPack p = table.get(key);
58-
if (p == null) {
59-
p = new PerfCounterPack();
60-
p.objName = objName;
61-
p.timetype = timeType;
62-
table.put(key, p);
63-
}
64-
return p;
65-
}
66-
67-
public PerfCounterPack getPack(byte timeType) {
68-
return getPack(Configure.getInstance().objName, timeType);
69-
}
70-
71-
public PerfCounterPack[] getList() {
72-
ArrayList list = new ArrayList(table.values());
73-
return (PerfCounterPack[])list.toArray(new PerfCounterPack[list.size()]);
74-
}
26+
27+
public class CounterBasket {
28+
private class Key {
29+
private String objName;
30+
private byte timeType;
31+
32+
public Key(String objName, byte timeType) {
33+
this.objName = objName;
34+
this.timeType = timeType;
35+
}
36+
37+
@Override
38+
public boolean equals(Object obj) {
39+
if (obj instanceof Key) {
40+
Key k = (Key) obj;
41+
return this.objName.equals(k.objName) && this.timeType == k.timeType;
42+
}
43+
return false;
44+
}
45+
46+
@Override
47+
public int hashCode() {
48+
49+
return objName.hashCode() ^ timeType;
50+
}
51+
}
52+
53+
private Map<Key, PerfCounterPack> table = new HashMap<CounterBasket.Key, PerfCounterPack>();
54+
55+
public PerfCounterPack getPack(String objName, byte timeType) {
56+
Key key = new Key(objName, timeType);
57+
PerfCounterPack p = table.get(key);
58+
if (p == null) {
59+
p = new PerfCounterPack();
60+
p.objName = objName;
61+
p.timetype = timeType;
62+
table.put(key, p);
63+
}
64+
return p;
65+
}
66+
67+
public PerfCounterPack getPack(byte timeType) {
68+
return getPack(Configure.getInstance().objName, timeType);
69+
}
70+
71+
public PerfCounterPack[] getList() {
72+
return (PerfCounterPack[]) table.values().toArray(new PerfCounterPack[table.size()]);
73+
}
7574
}

scouter.agent.java/src/scouter/agent/counter/task/AgentHeartBeat.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
import scouter.agent.counter.anotation.Counter;
2828
import scouter.agent.netio.data.DataProxy;
2929
import scouter.agent.netio.data.net.TcpWorker;
30+
import scouter.agent.proxy.ToolsMainFactory;
3031
import scouter.lang.pack.ObjectPack;
32+
import scouter.lang.value.BooleanValue;
3133
import scouter.util.FileUtil;
3234
import scouter.util.StringKeyLinkedMap;
3335
import scouter.util.SysJMX;
@@ -76,6 +78,9 @@ private ObjectPack getMainObject() {
7678

7779
p.version = Version.getAgentFullVersion();
7880
p.address = TcpWorker.localAddr;
81+
if(ToolsMainFactory.activeStack){
82+
p.tags.put("ActiveStack", new BooleanValue(true));
83+
}
7984
return p;
8085
}
8186

scouter.agent.java/src/scouter/agent/counter/task/MakeStack.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
public class MakeStack {
1414

1515
public long lastStackTime;
16-
1716
@Counter
1817
public void make(CounterBasket pw) {
19-
Configure conf = Configure.getInstance();
20-
if (conf.pstack_enabled == false)
18+
if (isPStackEnabled()== false){
19+
ToolsMainFactory.activeStack=false;
2120
return;
21+
}
2222
long now = System.currentTimeMillis();
23-
if (now < lastStackTime + conf.pstack_interval)
23+
if (now < lastStackTime + getInterval())
2424
return;
2525
lastStackTime = now;
2626
StringWriter sw = new StringWriter();
@@ -36,9 +36,17 @@ public void make(CounterBasket pw) {
3636

3737
StackPack p = new StackPack();
3838
p.time = System.currentTimeMillis();
39-
p.objHash = conf.objHash;
39+
p.objHash = Configure.getInstance().objHash;
4040
p.setStack(stack);
4141

4242
DataProxy.sendDirect(p);
4343
}
44+
45+
public static long pstack_requested;
46+
private boolean isPStackEnabled() {
47+
return Configure.getInstance().pstack_enabled || System.currentTimeMillis() < pstack_requested;
48+
}
49+
private long getInterval() {
50+
return Configure.getInstance().pstack_interval;
51+
}
4452
}

scouter.agent.java/src/scouter/agent/netio/data/DataProxy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public static void sendDirect(Pack p) {
215215

216216
private static void sendDirect(List<byte[]> buff) {
217217
switch (buff.size()) {
218+
case 0: return;
218219
case 1:
219220
udpNet.write(buff.get(0));
220221
break;

scouter.agent.java/src/scouter/agent/netio/data/net/TcpRequestMgr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static synchronized TcpRequestMgr getInstance() {
2121
return instance;
2222
}
2323

24-
protected Executor pool = ThreadUtil.createExecutor("SCOUTER", 10, 10, true);
24+
protected Executor pool = ThreadUtil.createExecutor("SCOUTER", 10, 10000, true);
2525

2626
@Override
2727
public void run() {

scouter.agent.java/src/scouter/agent/netio/request/handle/AgentFileSocket.java

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,85 @@
1414
* limitations under the License.
1515
*/
1616

17-
package scouter.agent.netio.request.handle;
18-
17+
package scouter.agent.netio.request.handle;
18+
1919
import scouter.agent.netio.request.anotation.RequestHandler;
20+
import scouter.agent.trace.SocketTable;
21+
import scouter.io.DataOutputX;
2022
import scouter.lang.pack.MapPack;
2123
import scouter.lang.pack.Pack;
24+
import scouter.lang.value.BlobValue;
25+
import scouter.lang.value.ListValue;
2226
import scouter.net.RequestCmd;
27+
import scouter.util.BitUtil;
28+
import scouter.util.LongEnumer;
2329
import scouter.util.RunExec;
30+
import scouter.util.StringUtil;
2431
import scouter.util.SysJMX;
2532
import scouter.util.SystemUtil;
2633

27-
public class AgentFileSocket {
28-
String linux_file = "lsof -Pp " + SysJMX.getProcessPID();
29-
30-
@RequestHandler(RequestCmd.OBJECT_FILE_SOCKET)
31-
public Pack getFileList(Pack param) {
32-
MapPack p = new MapPack();
33-
if (SystemUtil.IS_LINUX == false && SystemUtil.IS_MAC == false) {
34-
p.put("status", -2);
35-
p.put("error", "not supported os "+SystemUtil.OS_NAME);
36-
return p;
37-
}
38-
RunExec re = new RunExec(linux_file);
39-
int status = re.exec();
40-
p.put("status", status);
41-
if (re.getOutput() != null) {
42-
p.put("data", re.getOutput());
43-
}
44-
if (re.getError() != null) {
45-
p.put("error", re.getError());
46-
}
47-
if (re.getException() != null) {
48-
p.put("exception", re.getException().getMessage());
49-
}
50-
51-
return p;
52-
}
53-
54-
55-
34+
public class AgentFileSocket {
35+
String linux_file = "lsof -Pp " + SysJMX.getProcessPID();
36+
37+
@RequestHandler(RequestCmd.OBJECT_FILE_SOCKET)
38+
public Pack getFileList(Pack param) {
39+
MapPack p = new MapPack();
40+
if (SystemUtil.IS_LINUX == false && SystemUtil.IS_MAC == false) {
41+
p.put("status", -2);
42+
p.put("error", "not supported os " + SystemUtil.OS_NAME);
43+
return p;
44+
}
45+
RunExec re = new RunExec(linux_file);
46+
int status = re.exec();
47+
p.put("status", status);
48+
if (re.getOutput() != null) {
49+
p.put("data", re.getOutput());
50+
}
51+
if (re.getError() != null) {
52+
p.put("error", re.getError());
53+
}
54+
if (re.getException() != null) {
55+
p.put("exception", re.getException().getMessage());
56+
}
57+
58+
return p;
59+
}
60+
61+
@RequestHandler(RequestCmd.OBJECT_SOCKET)
62+
public Pack getSocketList(Pack param) {
63+
long order = ((MapPack) param).getLong("key");
64+
65+
MapPack p = new MapPack();
66+
ListValue keyLv = p.newList("key");
67+
ListValue hostLv = p.newList("host");
68+
ListValue portLv = p.newList("port");
69+
ListValue countLv = p.newList("count");
70+
ListValue serviceLv = p.newList("service");
71+
ListValue txidLv = p.newList("txid");
72+
ListValue orderLv = p.newList("order");
73+
ListValue stackLv = p.newList("stack");
74+
75+
LongEnumer en = SocketTable.socketMap.keys();
76+
while (en.hasMoreElements()) {
77+
long key = en.nextLong();
78+
SocketTable.Info fo = SocketTable.socketMap.get(key);
79+
if (fo == null)
80+
continue;
81+
82+
if (key == order || order == Long.MAX_VALUE) {
83+
fo.stackOrder = true;
84+
}
85+
86+
keyLv.add(key);
87+
hostLv.add(new BlobValue(DataOutputX.toBytes(BitUtil.getHigh(key))));
88+
portLv.add(BitUtil.getLow(key));
89+
countLv.add(fo.count);
90+
serviceLv.add(fo.service);
91+
txidLv.add(fo.txid);
92+
orderLv.add(fo.stackOrder);
93+
stackLv.add(StringUtil.trimEmpty(fo.stack));
94+
}
95+
return p;
96+
}
97+
5698
}

0 commit comments

Comments
 (0)