Skip to content

Commit

Permalink
Merge pull request #43 from scouter-project/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bill23-kim committed Nov 1, 2015
2 parents c09caef + d7bb0ce commit a549200
Show file tree
Hide file tree
Showing 12 changed files with 928 additions and 336 deletions.
7 changes: 6 additions & 1 deletion scouter.agent.java/src/scouter/agent/Configure.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ public final static synchronized Configure getInstance() {
public boolean hook_method_access_protected = false;
public boolean hook_method_access_none = false;

public boolean trace_method_enabled=true;


public String hook_service = "";
public String hook_apicall = "";
public String hook_apicall_info = "";
Expand Down Expand Up @@ -313,7 +316,7 @@ public File getPropertyFile() {
}

long last_check = 0;


public synchronized boolean reload(boolean force) {
long now = System.currentTimeMillis();
Expand Down Expand Up @@ -441,6 +444,8 @@ private void apply() {
this._hook_method_ignore_classes = new StringSet(StringUtil.tokenizer(
this.hook_method_ignore_classes.replace('.', '/'), ","));

this.trace_method_enabled=getBoolean("trace_method_enabled", true);

this.hook_service = getValue("hook_service", "");
this.hook_apicall = getValue("hook_apicall", "");
this.hook_apicall_info = getValue("hook_apicall_info", "");
Expand Down
47 changes: 27 additions & 20 deletions scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import scouter.agent.counter.CounterBasket;
import scouter.agent.counter.anotation.Counter;
import scouter.agent.counter.meter.MeterResource;
import scouter.agent.counter.task.TomcatJMXPerf.CtxObj;
import scouter.agent.counter.task.TomcatJMXPerf.MeterKey;
import scouter.lang.TimeTypeEnum;
import scouter.lang.conf.ConfObserver;
import scouter.lang.counters.CounterConstants;
Expand Down Expand Up @@ -78,22 +80,22 @@ private MeterResource getMeter(MeterKey key) {

static class MeterKey {

String objName;
int mbeanHash;
String counter;

public MeterKey(String objName, String counter) {
this.objName = objName;
public MeterKey(int mbeanHash, String counter) {
this.mbeanHash = mbeanHash;
this.counter = counter;
}

public int hashCode() {
return objName.hashCode() ^ counter.hashCode();
return mbeanHash ^ counter.hashCode();
}

public boolean equals(Object obj) {
if (obj instanceof MeterKey) {
MeterKey key = (MeterKey) obj;
return (this.objName.equals(key.objName)) && (this.counter.equals(key.counter));
return (this.mbeanHash == key.mbeanHash) && (this.counter.equals(key.counter));
}
return false;
}
Expand All @@ -110,8 +112,6 @@ public void process(CounterBasket pw) {
if (CounterConstants.JBOSS.equals(ObjTypeDetector.objType) == false) {
return;
}
// if(CounterConstants.JBOSS.equals(conf.objType) ==false)
// return;

getMBeanServer();

Expand All @@ -124,12 +124,12 @@ public void process(CounterBasket pw) {
}
collectCnt++;

collectCnt++;
MBeanServer server = servers.get(0);

for (CtxObj ctx : ctxList) {
if (ctx.valueType == ValueEnum.DECIMAL) {
try {
MeterKey key = new MeterKey(ctx.objName, ctx.counter);
MeterKey key = new MeterKey(ctx.mbeanHash, ctx.counter);
long v = CastUtil.clong(server.getAttribute(ctx.mbean, ctx.attrName));
if (deltas.contains(ctx.counter)) {
v = getDelta(key, v);
Expand All @@ -138,17 +138,17 @@ public void process(CounterBasket pw) {
v = (long) meter.getSum(60);
long sum = (long) meter.getSum(300) / 5;

pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).put(ctx.counter, new DecimalValue(v));
pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).put(ctx.counter, new DecimalValue(sum));
pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).add(ctx.counter, new DecimalValue(v));
pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).add(ctx.counter, new DecimalValue(sum));
} else {
MeterResource meter = getMeter(key);
meter.add(v);
double d = meter.getAvg(30);
double avg = meter.getAvg(300);
FloatValue value = new FloatValue((float) d);
FloatValue avgValue = new FloatValue((float) avg);
pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).put(ctx.counter, value);
pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).put(ctx.counter, avgValue);
pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).add(ctx.counter, value);
pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).add(ctx.counter, avgValue);
}
} catch (Exception e) {
errors.add(ctx.attrName);
Expand Down Expand Up @@ -268,23 +268,30 @@ private static String checkObjName(String name) {
}

class CtxObj {
private String objName;
private ObjectName mbean;
private String objType;
private byte valueType;
private String attrName;
private String counter;
public int mbeanHash;
public String objName;
public ObjectName mbean;
public String objType;
public byte valueType;
public String attrName;
public String counter;

public CtxObj(String objName, ObjectName mbean, String objType, byte valueType, String attrName, String counter) {

this.objName = objName;
this.mbean = mbean;
this.mbeanHash = HashUtil.hash(mbean.toString());
this.objType = objType;
this.valueType = valueType;
this.attrName = attrName;
this.counter = counter;
}

}
@Override
public String toString() {
return "CtxObj [objName=" + objName + ", mbean=" + mbean + ", objType=" + objType + ", valueType="
+ valueType + ", attrName=" + attrName + ", counter=" + counter + "]";
}

}
}
Loading

0 comments on commit a549200

Please sign in to comment.