diff --git a/.gitignore b/.gitignore index 911e397e1..ac01a79fa 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,10 @@ scouter.agent.java/.settings/* scouter.enduser.script/.idea/* scouter.enduser.script/.settings/* node_modules/ +scouter.enduser.script/.externalToolBuilders/ +scouter.server/*.scouter +scouter.server/conf/account.xml +scouter.server/conf/account_group.xml +scouter.server/database/ +scouter.client.product/plugin_customization.ini +scouter.client/plugin_customization.ini diff --git a/README.md b/README.md index 2fc9df426..310379d71 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ APM means application performance monitoring or application performance manageme - Opensource WAS - Tomcat, JBoss, Resin ... - Opensource DB - MariaDB(on closed beta testing now) - - Monitoring target (hopeful with every contributors) + - Monitoring target (hopeful with every contributor) - Nodejs, Redis, MongoDB, PostgreSQL, Apach HTTPD, nginX, php ... ![Screen](https://github.com/scouter-project/scouter-help/blob/master/misc/screen/dash1.png) @@ -20,7 +20,7 @@ SCOUTER can help you. - Services : ActiveService, TPS, ResponseTime, Transaction Profile(class,sql,apicall), TagCount - Resources : Cpu,Memory,Network and Heap usage, Connection pools etc. -### At a glance(Click to watch the film) +### At a glance(Click to watch the video) [![Demo gif](https://j.gifs.com/yDqbAa.gif)](https://youtu.be/iuArTzsD7Ws) diff --git a/scouter.agent.host/src/scouter/boot/Boot.java b/scouter.agent.host/src/scouter/boot/Boot.java index 2434d3192..2891b1e00 100644 --- a/scouter.agent.host/src/scouter/boot/Boot.java +++ b/scouter.agent.host/src/scouter/boot/Boot.java @@ -36,7 +36,7 @@ public static void main(String[] args) throws Throwable { try { JarUtil.unJar(JarUtil.getThisJarFile(), new File(lib)); } catch (Exception e) { - System.out.println("Fail to extract jar files"); + System.out.println("Fail to extract jar files : " + e.toString()); System.out.println("Please check the permission : " + lib + "/*.*"); } URL[] jarfiles = getURLs(lib); diff --git a/scouter.agent.java/src/scouter/agent/Configure.java b/scouter.agent.java/src/scouter/agent/Configure.java index f8651a59a..8af0565e3 100644 --- a/scouter.agent.java/src/scouter/agent/Configure.java +++ b/scouter.agent.java/src/scouter/agent/Configure.java @@ -178,6 +178,8 @@ public final static synchronized Configure getInstance() { public String hook_jdbc_pstmt = ""; public String hook_jdbc_stmt = ""; public String hook_jdbc_rs = ""; + + public String hook_dbc_wrapper=""; // /LOAD CONTROL///// public boolean enable_reject_service = false; @@ -231,6 +233,8 @@ public final static synchronized Configure getInstance() { public boolean enable_hook_future = true; //////////////////////////////////////////// + public boolean enable_dbc_wrapper = true; + public String direct_patch_class = ""; public long max_think_time = DateUtil.MILLIS_PER_FIVE_MINUTE; @@ -242,7 +246,13 @@ public final static synchronized Configure getInstance() { public boolean enable_trace_web = false; public String key_web_name = "X-Forwarded-Host"; public String key_web_time = "X-Forwarded-Time"; + + public boolean enable_summary=true; + public int summary_service_max=10000; + public int summary_sql_max=10000; + public int summary_api_max=5000; + /** * sometimes call by sample application, at that time normally set some * properties directly @@ -292,6 +302,8 @@ public File getPropertyFile() { } long last_check = 0; + + public synchronized boolean reload(boolean force) { long now = System.currentTimeMillis(); @@ -427,6 +439,7 @@ private void apply() { this.hook_jdbc_pstmt = getValue("hook_jdbc_pstmt", ""); this.hook_jdbc_stmt = getValue("hook_jdbc_stmt", ""); this.hook_jdbc_rs = getValue("hook_jdbc_rs", ""); + this.hook_dbc_wrapper= getValue("hook_dbc_wrapper", ""); this.hook_signature ^= this.hook_args.hashCode(); this.hook_signature ^= this.hook_return.hashCode(); @@ -496,6 +509,8 @@ private void apply() { this.enable_hook_jsp = getBoolean("enable_hook_jsp", true); this.enable_hook_future = getBoolean("enable_hook_future", true); + this.enable_dbc_wrapper= getBoolean("enable_dbc_wrapper", true); + this.direct_patch_class = getValue("direct_patch_class", ""); this.max_think_time = getLong("max_think_time", DateUtil.MILLIS_PER_FIVE_MINUTE); @@ -510,6 +525,13 @@ private void apply() { this.key_web_name = getValue("key_web_name", "X-Forwarded-Host"); this.key_web_time = getValue("key_web_time", "X-Forwarded-Time"); + //SUMMARY최대 갯수를 관리한다. + this.enable_summary = getBoolean("enable_summary", true); + this.summary_sql_max = getInt("summary_sql_max", 10000); + this.summary_api_max= getInt("summary_api_max", 5000); + this.summary_service_max = getInt("summary_service_max", 10000); + + resetObjInfo(); setErrorStatus(); setStaticContents(); diff --git a/scouter.agent.java/src/scouter/agent/asm/JDBCDriverASM.java b/scouter.agent.java/src/scouter/agent/asm/JDBCDriverASM.java index 67b0f1f34..6f4acf5cb 100644 --- a/scouter.agent.java/src/scouter/agent/asm/JDBCDriverASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/JDBCDriverASM.java @@ -14,8 +14,8 @@ * limitations under the License. */ package scouter.agent.asm; -import java.util.HashMap; import java.util.Map; + import scouter.agent.ClassDesc; import scouter.agent.Configure; import scouter.agent.Logger; @@ -28,15 +28,17 @@ import scouter.org.objectweb.asm.Opcodes; import scouter.org.objectweb.asm.Type; import scouter.org.objectweb.asm.commons.LocalVariablesSorter; + public class JDBCDriverASM implements IASM, Opcodes { - private Map reserved = new HashMap(); + //user can define driver.connect() + private Map reserved =MethodSet.getHookingSet(Configure.getInstance().hook_dbc_wrapper); public JDBCDriverASM() { AsmUtil.add(reserved, "com/ibm/db2/jcc/DB2Driver", "connect(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;"); } public boolean isTarget(String className) { MethodSet mset = reserved.get(className); if (mset != null){ - return false; + return true; } return false; } @@ -77,11 +79,9 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si // /////////////////////////////////////////////////////////////////////////// class JDBCDriverMV extends LocalVariablesSorter implements Opcodes { private static final String TRACE_SQL = TraceSQL.class.getName().replace('.', '/'); - private final static String START_METHOD = "startCreateDBC"; - private static final String START_SIGNATURE = "(Ljava/lang/String;)Ljava/lang/Object;"; - private final static String END_METHOD = "endCreateDBC"; - private static final String END_SIGNATURE = "(Ljava/sql/Connection;Ljava/lang/Object;)Ljava/sql/Connection;"; - private static final String ERR_SIGNATURE = "(Ljava/lang/Object;Ljava/lang/Throwable;)V"; + private final static String CONNECT_METHOD = "driverConnect"; + private static final String CONNECT_SIGNATURE = "(Ljava/sql/Connection;Ljava/lang/String;)Ljava/sql/Connection;"; + private static final String ERR_SIGNATURE = "(Ljava/lang/String;Ljava/lang/Throwable;)V"; private Label startFinally = new Label(); private Type returnType; @@ -93,23 +93,18 @@ public JDBCDriverMV(int access, String desc, MethodVisitor mv, String fullname) this.returnType = Type.getReturnType(desc); } private String fullname; - private int statIdx; private int strArgIdx; private boolean isStatic; @Override public void visitCode() { - mv.visitVarInsn(Opcodes.ALOAD, strArgIdx); - mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACE_SQL, START_METHOD, START_SIGNATURE,false); - statIdx = newLocal(Type.getType(Object.class)); - mv.visitVarInsn(Opcodes.ASTORE, statIdx); mv.visitLabel(startFinally); mv.visitCode(); } @Override public void visitInsn(int opcode) { if ((opcode >= IRETURN && opcode <= RETURN)) { - mv.visitVarInsn(Opcodes.ALOAD, statIdx); - mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACE_SQL, END_METHOD, END_SIGNATURE,false); + mv.visitVarInsn(Opcodes.ALOAD, strArgIdx); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACE_SQL, CONNECT_METHOD, CONNECT_SIGNATURE,false); } mv.visitInsn(opcode); } @@ -122,9 +117,9 @@ public void visitMaxs(int maxStack, int maxLocals) { int errIdx = newLocal(Type.getType(Throwable.class)); mv.visitVarInsn(Opcodes.ASTORE, errIdx); - mv.visitVarInsn(Opcodes.ALOAD, statIdx); + mv.visitVarInsn(Opcodes.ALOAD, strArgIdx); mv.visitVarInsn(Opcodes.ALOAD, errIdx); - mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACE_SQL, END_METHOD, ERR_SIGNATURE,false); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACE_SQL, CONNECT_METHOD, ERR_SIGNATURE,false); mv.visitInsn(ATHROW); mv.visitMaxs(maxStack + 8, maxLocals + 2); } diff --git a/scouter.agent.java/src/scouter/agent/counter/task/ServicePerf.java b/scouter.agent.java/src/scouter/agent/counter/task/ServicePerf.java index bf4f59f79..692824234 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/ServicePerf.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/ServicePerf.java @@ -14,77 +14,109 @@ * limitations under the License. */ -package scouter.agent.counter.task; - +package scouter.agent.counter.task; + import scouter.agent.Configure; import scouter.agent.counter.CounterBasket; import scouter.agent.counter.anotation.Counter; import scouter.agent.counter.meter.MeterResource; import scouter.agent.counter.meter.MeterService; +import scouter.agent.netio.data.DataProxy; +import scouter.agent.summary.ServiceSummary; import scouter.agent.trace.TraceContextManager; import scouter.agent.util.DumpUtil; +import scouter.lang.SummaryEnum; import scouter.lang.TimeTypeEnum; import scouter.lang.counters.CounterConstants; import scouter.lang.pack.PerfCounterPack; +import scouter.lang.pack.SummaryPack; import scouter.lang.value.DecimalValue; import scouter.lang.value.FloatValue; import scouter.lang.value.ListValue; - -public class ServicePerf { - - private MeterResource activeCounter = new MeterResource(); - - @Counter - public void getServicePerf(CounterBasket pw) { - Configure conf = Configure.getInstance(); - MeterService service = MeterService.getInstance(); - int elapsed = service.getElapsedTime(30); - float tps = service.getTPS(30); - float err = service.getError(30); - int count = service.getServiceCount(60); +import scouter.util.DateUtil; + +public class ServicePerf { + + private MeterResource activeCounter = new MeterResource(); + + @Counter + public void getServicePerf(CounterBasket pw) { + Configure conf = Configure.getInstance(); + MeterService service = MeterService.getInstance(); + int elapsed = service.getElapsedTime(30); + float tps = service.getTPS(30); + float err = service.getError(30); + int count = service.getServiceCount(60); int resp90pct = service.getElapsed90Pct(30); - - int[] act = TraceContextManager.getActiveCount(); - int active = act[0] + act[1] + act[2]; - if (conf.auto_dump_trigger <= active) { - DumpUtil.autoDump(); + + int[] act = TraceContextManager.getActiveCount(); + int active = act[0] + act[1] + act[2]; + if (conf.auto_dump_trigger <= active) { + DumpUtil.autoDump(); } - activeCounter.add(active); - - // active service 30초 평균으로 변경 - active = (int) Math.round(activeCounter.getAvg(30)); - - PerfCounterPack p = pw.getPack(TimeTypeEnum.REALTIME); - p.put(CounterConstants.WAS_ELAPSED_TIME, new DecimalValue(elapsed)); - p.put(CounterConstants.WAS_SERVICE_COUNT, new DecimalValue(count)); - p.put(CounterConstants.WAS_TPS, new FloatValue(tps)); - p.put(CounterConstants.WAS_ERROR_RATE, new FloatValue(err)); + activeCounter.add(active); + + // active service 30초 평균으로 변경 + active = (int) Math.round(activeCounter.getAvg(30)); + + PerfCounterPack p = pw.getPack(TimeTypeEnum.REALTIME); + p.put(CounterConstants.WAS_ELAPSED_TIME, new DecimalValue(elapsed)); + p.put(CounterConstants.WAS_SERVICE_COUNT, new DecimalValue(count)); + p.put(CounterConstants.WAS_TPS, new FloatValue(tps)); + p.put(CounterConstants.WAS_ERROR_RATE, new FloatValue(err)); p.put(CounterConstants.WAS_ACTIVE_SERVICE, new DecimalValue(active)); p.put(CounterConstants.WAS_ELAPSED_90PCT, new DecimalValue(resp90pct)); - - ListValue activeSpeed = new ListValue(); - activeSpeed.add(act[0]); - activeSpeed.add(act[1]); - activeSpeed.add(act[2]); - - p.put(CounterConstants.WAS_ACTIVE_SPEED, activeSpeed); - - // UdpProxy.sendAlert(, message) - - count = service.getServiceCount(300); - tps = service.getTPS(300); - elapsed = service.getElapsedTime(300); - err = service.getError(300); - int activeSErvice = (int) activeCounter.getAvg(300); + + ListValue activeSpeed = new ListValue(); + activeSpeed.add(act[0]); + activeSpeed.add(act[1]); + activeSpeed.add(act[2]); + + p.put(CounterConstants.WAS_ACTIVE_SPEED, activeSpeed); + + // UdpProxy.sendAlert(, message) + + count = service.getServiceCount(300); + tps = service.getTPS(300); + elapsed = service.getElapsedTime(300); + err = service.getError(300); + int activeSErvice = (int) activeCounter.getAvg(300); resp90pct = service.getElapsed90Pct(300); - - p = pw.getPack(TimeTypeEnum.FIVE_MIN); - p.put(CounterConstants.WAS_ELAPSED_TIME, new DecimalValue(elapsed)); - p.put(CounterConstants.WAS_SERVICE_COUNT, new DecimalValue(count)); - p.put(CounterConstants.WAS_TPS, new FloatValue(tps)); - p.put(CounterConstants.WAS_ERROR_RATE, new FloatValue(err)); + + p = pw.getPack(TimeTypeEnum.FIVE_MIN); + p.put(CounterConstants.WAS_ELAPSED_TIME, new DecimalValue(elapsed)); + p.put(CounterConstants.WAS_SERVICE_COUNT, new DecimalValue(count)); + p.put(CounterConstants.WAS_TPS, new FloatValue(tps)); + p.put(CounterConstants.WAS_ERROR_RATE, new FloatValue(err)); p.put(CounterConstants.WAS_ACTIVE_SERVICE, new DecimalValue(activeSErvice)); - p.put(CounterConstants.WAS_ELAPSED_90PCT, new DecimalValue(resp90pct)); - } - + p.put(CounterConstants.WAS_ELAPSED_90PCT, new DecimalValue(resp90pct)); + } + + private long last_sent = DateUtil.getMinUnit(System.currentTimeMillis()) / 5; + + @Counter(interval = 500) + public void summay(CounterBasket pw) { + long time = System.currentTimeMillis(); + long now = DateUtil.getMinUnit(time) / 5; + if (now == last_sent) + return; + last_sent = now; + time = (time - 10000) / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE; + + SummaryPack p = ServiceSummary.getInstance().getAndClear(SummaryEnum.APP); + if (p != null) { + p.time = time; + DataProxy.send(p); + } + p = ServiceSummary.getInstance().getAndClear(SummaryEnum.SQL); + if (p != null) { + p.time = time; + DataProxy.send(p); + } + p = ServiceSummary.getInstance().getAndClear(SummaryEnum.APICALL); + if (p != null) { + p.time = time; + DataProxy.send(p); + } + } } \ No newline at end of file diff --git a/scouter.agent.java/src/scouter/agent/netio/data/DataProxy.java b/scouter.agent.java/src/scouter/agent/netio/data/DataProxy.java index f7cfc3b8d..fbc888d75 100644 --- a/scouter.agent.java/src/scouter/agent/netio/data/DataProxy.java +++ b/scouter.agent.java/src/scouter/agent/netio/data/DataProxy.java @@ -30,6 +30,7 @@ import scouter.lang.pack.ObjectPack; import scouter.lang.pack.Pack; import scouter.lang.pack.PerfCounterPack; +import scouter.lang.pack.SummaryPack; import scouter.lang.pack.TextPack; import scouter.lang.pack.XLogPack; import scouter.lang.pack.XLogProfilePack; @@ -203,7 +204,10 @@ public static void sendXLog(XLogPack p) { Logger.info(p.toString()); } } - + public static void send(SummaryPack p) { + p.objHash = conf.objHash; + sendDirect(p); + } static DataUdpAgent udpNet = DataUdpAgent.getInstance(); public static void sendDirect(Pack p) { diff --git a/scouter.agent.java/src/scouter/agent/netio/data/net/TcpWorker.java b/scouter.agent.java/src/scouter/agent/netio/data/net/TcpWorker.java index e8ee7d611..0eb574ba4 100644 --- a/scouter.agent.java/src/scouter/agent/netio/data/net/TcpWorker.java +++ b/scouter.agent.java/src/scouter/agent/netio/data/net/TcpWorker.java @@ -94,19 +94,28 @@ private void process(Socket socket) throws IOException { } private void processV2(Socket socket) throws IOException { + DataInputX in = null; DataOutputX out = null; + Configure conf = Configure.getInstance(); + try { in = new DataInputX(new BufferedInputStream(socket.getInputStream())); out = new DataOutputX(new BufferedOutputStream(socket.getOutputStream())); + String server_addr = conf.server_addr; + int port = conf.server_tcp_port; + out.writeInt(NetCafe.TCP_AGENT_V2); out.writeInt(objHash); out.flush(); - while (objHash == Configure.getInstance().objHash) { - byte[] buff = in.readIntBytes(); + //에이전트 이름, 서버 주소포트가 같은 동안만 세션을 유지하라. + while (objHash == Configure.getInstance().objHash && server_addr.equals(conf.server_addr) + && port == conf.server_tcp_port) { + byte[] buff = in.readIntBytes(); + DataInputX in2 = new DataInputX(buff); String cmd = in2.readText(); Pack parameter = (Pack) in2.readPack(); @@ -114,7 +123,7 @@ private void processV2(Socket socket) throws IOException { Pack res = ReqestHandlingProxy.process(cmd, parameter, in, out); if (res != null) { out.writeByte(TcpFlag.HasNEXT); - + byte[] obuff = new DataOutputX().writePack(res).toByteArray(); out.writeIntBytes(obuff); } diff --git a/scouter.agent.java/src/scouter/agent/summary/ServiceSummary.java b/scouter.agent.java/src/scouter/agent/summary/ServiceSummary.java new file mode 100644 index 000000000..e8474400e --- /dev/null +++ b/scouter.agent.java/src/scouter/agent/summary/ServiceSummary.java @@ -0,0 +1,150 @@ +/* + * Copyright 2015 the original author or authors. + * + * 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.summary; + +import java.util.Enumeration; + +import scouter.agent.Configure; +import scouter.lang.SummaryEnum; +import scouter.lang.pack.SummaryPack; +import scouter.lang.pack.XLogPack; +import scouter.lang.step.ApiCallStep; +import scouter.lang.step.SqlStep; +import scouter.lang.value.ListValue; +import scouter.lang.value.MapValue; +import scouter.util.IntKeyLinkedMap; + +public class ServiceSummary { + + private static ServiceSummary instance = null; + + public final static synchronized ServiceSummary getInstance() { + if (instance == null) { + instance = new ServiceSummary(); + } + return instance; + } + + private Configure conf = Configure.getInstance(); + + public void process(XLogPack p) { + if (conf.enable_summary == false) + return; + SummaryData d = getSummaryMap(serviceMaster, p.service); + d.count++; + d.elapsed += p.elapsed; + if (p.error != 0) { + d.error_cnt++; + } + d.cpu += p.cpu; + d.mem += p.bytes; + } + + public void process(SqlStep sqlStep) { + if (conf.enable_summary == false) + return; + SummaryData d = getSummaryMap(sqlMaster, sqlStep.hash); + d.count++; + d.elapsed += sqlStep.elapsed; + if (sqlStep.error != 0) { + d.error_cnt++; + } + } + + public void process(ApiCallStep apiStep) { + if (conf.enable_summary == false) + return; + SummaryData d = getSummaryMap(apiMaster, apiStep.hash); + d.count++; + d.elapsed += apiStep.elapsed; + if (apiStep.error != 0) { + d.error_cnt++; + } + } + + private SummaryData getSummaryMap(IntKeyLinkedMap table, int hash) { + IntKeyLinkedMap tempTable = table; + SummaryData d = tempTable.get(hash); + if (d == null) { + d = new SummaryData(); + tempTable.put(hash, d); + } + return d; + } + + private IntKeyLinkedMap sqlMaster = new IntKeyLinkedMap().setMax(conf.summary_sql_max); + private IntKeyLinkedMap apiMaster = new IntKeyLinkedMap().setMax(conf.summary_api_max); + private IntKeyLinkedMap serviceMaster = new IntKeyLinkedMap() + .setMax(conf.summary_service_max); + + public SummaryPack getAndClear(byte type) { + IntKeyLinkedMap temp; + switch (type) { + case SummaryEnum.APP: + if (serviceMaster.size() == 0) + return null; + temp = serviceMaster; + serviceMaster = new IntKeyLinkedMap().setMax(conf.summary_service_max); + break; + case SummaryEnum.SQL: + if (sqlMaster.size() == 0) + return null; + temp = sqlMaster; + sqlMaster = new IntKeyLinkedMap().setMax(conf.summary_sql_max); + break; + case SummaryEnum.APICALL: + if (apiMaster.size() == 0) + return null; + temp = apiMaster; + apiMaster = new IntKeyLinkedMap().setMax(conf.summary_api_max); + break; + default: + return null; + } + + SummaryPack p = new SummaryPack(); + p.stype = type; + + int cnt = temp.size(); + ListValue id = p.table.newList("id"); + ListValue count = p.table.newList("count"); + ListValue errorCnt = p.table.newList("error"); + ListValue elapsedSum = p.table.newList("elapsed"); + + ListValue cpu = null; + ListValue mem = null; + if (SummaryEnum.APP == type) { + cpu = p.table.newList("cpu"); + mem = p.table.newList("mem"); + } + Enumeration en = temp.entries(); + for (int i = 0; i < cnt; i++) { + IntKeyLinkedMap.ENTRY ent = en.nextElement(); + int key = ent.getKey(); + SummaryData data = ent.getValue(); + id.add(key); + count.add(data.count); + errorCnt.add(data.error_cnt); + elapsedSum.add(data.elapsed); + if (SummaryEnum.APP == type) { + cpu.add(data.cpu); + mem.add(data.mem); + } + } + return p; + } + +} \ No newline at end of file diff --git a/scouter.agent.java/src/scouter/jdbc/JdbcTrace.java b/scouter.agent.java/src/scouter/agent/summary/SummaryData.java similarity index 78% rename from scouter.agent.java/src/scouter/jdbc/JdbcTrace.java rename to scouter.agent.java/src/scouter/agent/summary/SummaryData.java index 9da4d655c..5ab0124f5 100644 --- a/scouter.agent.java/src/scouter/jdbc/JdbcTrace.java +++ b/scouter.agent.java/src/scouter/agent/summary/SummaryData.java @@ -13,15 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package scouter.agent.summary; -package scouter.jdbc; - -import java.sql.Connection; - -public class JdbcTrace { - - public static Connection connect(Connection inner) { - return new ScouterConnection(inner); - } - -} \ No newline at end of file +public class SummaryData { + public int count; + public int error_cnt; + public long elapsed; + public long cpu; + public long mem; +} diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java b/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java index 7e21186a8..7449c178a 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java @@ -28,6 +28,7 @@ import scouter.agent.netio.data.DataProxy; import scouter.agent.plugin.ApiCallTracePlugin; import scouter.agent.plugin.HttpServiceTracePlugIn; +import scouter.agent.summary.ServiceSummary; import scouter.io.DataOutputX; import scouter.lang.AlertLevel; import scouter.lang.step.ApiCallStep; @@ -160,6 +161,7 @@ public static void endApicall(Object stat, Object returnValue, Throwable thr) { } } + ServiceSummary.getInstance().process(step); tctx.profile.pop(step); } catch (Throwable t) { t.printStackTrace(); diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java index 47b32a5b3..02f2cc2a5 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java @@ -24,6 +24,7 @@ import scouter.agent.plugin.ServiceTracePlugIn; import scouter.agent.proxy.HttpTraceFactory; import scouter.agent.proxy.IHttpTrace; +import scouter.agent.summary.ServiceSummary; import scouter.lang.AlertLevel; import scouter.lang.pack.XLogPack; import scouter.lang.pack.XLogTypes; @@ -313,6 +314,7 @@ public static void metering(XLogPack pack) { case XLogTypes.WEB_SERVICE: case XLogTypes.APP_SERVICE: MeterService.getInstance().add(pack.elapsed, pack.error != 0); + ServiceSummary.getInstance().process(pack); break; case XLogTypes.BACK_THREAD: } diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java b/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java index 0ec64c40a..4b686127c 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java @@ -22,8 +22,9 @@ import scouter.agent.Configure; import scouter.agent.Logger; import scouter.agent.netio.data.DataProxy; +import scouter.agent.summary.ServiceSummary; import scouter.jdbc.DetectConnection; -import scouter.jdbc.JdbcTrace; +import scouter.jdbc.WrConnection; import scouter.lang.AlertLevel; import scouter.lang.step.MessageStep; import scouter.lang.step.MethodStep; @@ -263,6 +264,7 @@ public static void end(Object stat, Throwable thr) { tctx.sqlCount++; tctx.sqlTime += ps.elapsed; + ServiceSummary.getInstance().process(ps); tctx.profile.pop(ps); } @@ -447,30 +449,17 @@ public static void prepare(Object o, SqlParameter args, String sql) { } - /** - * JDBC Wrapper is only available for the DB2 Driver - * - * @param url - * : JDBC Connection URL - * @return - trace object - */ - public static Object startCreateDBC(String url) { - String name = "CREATE-DBC " + url; - int hash = DataProxy.sendMethodName(name); - return TraceSQL.dbcOpenStart(hash, name, null); - } - - public static Connection endCreateDBC(Connection conn, Object stat) { - if (conn == null) { - conn = TraceSQL.dbcOpenEnd(conn, stat); + public static Connection driverConnect(Connection conn, String url) { + if(conn==null) return conn; - } - conn = TraceSQL.dbcOpenEnd(conn, stat); - return JdbcTrace.connect(conn); + if(conf.enable_dbc_wrapper==false) + return conn; + if(conn instanceof WrConnection) + return conn; + return new WrConnection(conn); } - - public static void endCreateDBC(Object stat, Throwable thr) { - TraceSQL.dbcOpenEnd(stat, thr); + public static void driverConnect(String url, Throwable thr) { + AlertProxy.sendAlert(AlertLevel.ERROR, "CONNECT", url + " " + thr); } public static Object dbcOpenStart(int hash, String msg, Object pool) { diff --git a/scouter.agent.java/src/scouter/jdbc/ScouterCallableStatement.java b/scouter.agent.java/src/scouter/jdbc/WrCallableStatement.java similarity index 98% rename from scouter.agent.java/src/scouter/jdbc/ScouterCallableStatement.java rename to scouter.agent.java/src/scouter/jdbc/WrCallableStatement.java index 24d3a8539..72b3dd0c1 100644 --- a/scouter.agent.java/src/scouter/jdbc/ScouterCallableStatement.java +++ b/scouter.agent.java/src/scouter/jdbc/WrCallableStatement.java @@ -19,10 +19,10 @@ import java.sql.SQLException; import java.util.Map; -public class ScouterCallableStatement extends ScouterPreparedStatement implements java.sql.CallableStatement { +public class WrCallableStatement extends WrPreparedStatement implements java.sql.CallableStatement { java.sql.CallableStatement inner; - public ScouterCallableStatement(java.sql.CallableStatement inner, String sql) { + public WrCallableStatement(java.sql.CallableStatement inner, String sql) { super(inner, sql); this.inner = inner; } diff --git a/scouter.agent.java/src/scouter/jdbc/ScouterConnection.java b/scouter.agent.java/src/scouter/jdbc/WrConnection.java similarity index 87% rename from scouter.agent.java/src/scouter/jdbc/ScouterConnection.java rename to scouter.agent.java/src/scouter/jdbc/WrConnection.java index 02e9efb84..83f2dc8d5 100644 --- a/scouter.agent.java/src/scouter/jdbc/ScouterConnection.java +++ b/scouter.agent.java/src/scouter/jdbc/WrConnection.java @@ -20,10 +20,10 @@ import java.util.Map; import java.util.concurrent.Executor; -public class ScouterConnection implements java.sql.Connection { +public class WrConnection implements java.sql.Connection { java.sql.Connection inner; - public ScouterConnection(java.sql.Connection inner) { + public WrConnection(java.sql.Connection inner) { this.inner = inner; } @@ -40,57 +40,57 @@ final public boolean isReadOnly() throws java.sql.SQLException { } final public java.sql.Statement createStatement() throws java.sql.SQLException { - return new ScouterStatement(this.inner.createStatement()); + return new WrStatement(this.inner.createStatement()); } final public java.sql.Statement createStatement(int a0, int a1) throws java.sql.SQLException { - return new ScouterStatement(this.inner.createStatement(a0, a1)); + return new WrStatement(this.inner.createStatement(a0, a1)); } final public java.sql.Statement createStatement(int a0, int a1, int a2) throws java.sql.SQLException { - return new ScouterStatement(this.inner.createStatement(a0, a1, a2)); + return new WrStatement(this.inner.createStatement(a0, a1, a2)); } final public java.sql.PreparedStatement prepareStatement(java.lang.String a0, int a1) throws java.sql.SQLException { - return new ScouterPreparedStatement(this.inner.prepareStatement(a0, a1), a0); + return new WrPreparedStatement(this.inner.prepareStatement(a0, a1), a0); } final public java.sql.PreparedStatement prepareStatement(java.lang.String a0, int a1, int a2) throws java.sql.SQLException { - return new ScouterPreparedStatement(this.inner.prepareStatement(a0, a1, a2), a0); + return new WrPreparedStatement(this.inner.prepareStatement(a0, a1, a2), a0); } final public java.sql.PreparedStatement prepareStatement(java.lang.String a0, int a1, int a2, int a3) throws java.sql.SQLException { - return new ScouterPreparedStatement(this.inner.prepareStatement(a0, a1, a2, a3), a0); + return new WrPreparedStatement(this.inner.prepareStatement(a0, a1, a2, a3), a0); } final public java.sql.PreparedStatement prepareStatement(java.lang.String a0, int[] a1) throws java.sql.SQLException { - return new ScouterPreparedStatement(this.inner.prepareStatement(a0, a1), a0); + return new WrPreparedStatement(this.inner.prepareStatement(a0, a1), a0); } final public java.sql.PreparedStatement prepareStatement(java.lang.String a0, java.lang.String[] a1) throws java.sql.SQLException { - return new ScouterPreparedStatement(this.inner.prepareStatement(a0, a1), a0); + return new WrPreparedStatement(this.inner.prepareStatement(a0, a1), a0); } final public java.sql.PreparedStatement prepareStatement(java.lang.String a0) throws java.sql.SQLException { - return new ScouterPreparedStatement(inner.prepareStatement(a0), a0); + return new WrPreparedStatement(inner.prepareStatement(a0), a0); } final public java.sql.CallableStatement prepareCall(java.lang.String a0) throws java.sql.SQLException { - return new ScouterCallableStatement(this.inner.prepareCall(a0), a0); + return new WrCallableStatement(this.inner.prepareCall(a0), a0); } final public java.sql.CallableStatement prepareCall(java.lang.String a0, int a1, int a2) throws java.sql.SQLException { - return new ScouterCallableStatement(this.inner.prepareCall(a0, a1, a2), a0); + return new WrCallableStatement(this.inner.prepareCall(a0, a1, a2), a0); } final public java.sql.CallableStatement prepareCall(java.lang.String a0, int a1, int a2, int a3) throws java.sql.SQLException { - return new ScouterCallableStatement(this.inner.prepareCall(a0, a1, a2, a3), a0); + return new WrCallableStatement(this.inner.prepareCall(a0, a1, a2, a3), a0); } final public java.lang.String nativeSQL(java.lang.String a0) throws java.sql.SQLException { diff --git a/scouter.agent.java/src/scouter/jdbc/ScouterPreparedStatement.java b/scouter.agent.java/src/scouter/jdbc/WrPreparedStatement.java similarity index 97% rename from scouter.agent.java/src/scouter/jdbc/ScouterPreparedStatement.java rename to scouter.agent.java/src/scouter/jdbc/WrPreparedStatement.java index 7f01609c7..81cfd0da2 100644 --- a/scouter.agent.java/src/scouter/jdbc/ScouterPreparedStatement.java +++ b/scouter.agent.java/src/scouter/jdbc/WrPreparedStatement.java @@ -22,11 +22,11 @@ import scouter.agent.trace.SqlParameter; import scouter.agent.trace.TraceSQL; -public class ScouterPreparedStatement extends ScouterStatement implements java.sql.PreparedStatement { +public class WrPreparedStatement extends WrStatement implements java.sql.PreparedStatement { java.sql.PreparedStatement inner; SqlParameter sql = new SqlParameter(); - public ScouterPreparedStatement(java.sql.PreparedStatement inner, String sql) { + public WrPreparedStatement(java.sql.PreparedStatement inner, String sql) { super(inner); this.inner = inner; this.sql.setSql(sql); @@ -112,7 +112,7 @@ final public java.sql.ResultSet executeQuery() throws java.sql.SQLException { try { ResultSet rs = this.inner.executeQuery(); TraceSQL.end(stat, null); - return new ScouterResultSet(rs); + return new WrResultSet(rs); } catch (SQLException ex) { TraceSQL.end(stat, ex); throw ex; diff --git a/scouter.agent.java/src/scouter/jdbc/ScouterResultSet.java b/scouter.agent.java/src/scouter/jdbc/WrResultSet.java similarity index 99% rename from scouter.agent.java/src/scouter/jdbc/ScouterResultSet.java rename to scouter.agent.java/src/scouter/jdbc/WrResultSet.java index 3dc2e09ad..28c3f49e4 100644 --- a/scouter.agent.java/src/scouter/jdbc/ScouterResultSet.java +++ b/scouter.agent.java/src/scouter/jdbc/WrResultSet.java @@ -21,10 +21,10 @@ import scouter.agent.trace.TraceSQL; -public class ScouterResultSet implements java.sql.ResultSet { +public class WrResultSet implements java.sql.ResultSet { java.sql.ResultSet inner; - public ScouterResultSet(java.sql.ResultSet inner) { + public WrResultSet(java.sql.ResultSet inner) { this.inner = inner; } diff --git a/scouter.agent.java/src/scouter/jdbc/ScouterStatement.java b/scouter.agent.java/src/scouter/jdbc/WrStatement.java similarity index 97% rename from scouter.agent.java/src/scouter/jdbc/ScouterStatement.java rename to scouter.agent.java/src/scouter/jdbc/WrStatement.java index 118e24a85..d642c7427 100644 --- a/scouter.agent.java/src/scouter/jdbc/ScouterStatement.java +++ b/scouter.agent.java/src/scouter/jdbc/WrStatement.java @@ -21,10 +21,10 @@ import scouter.agent.trace.TraceSQL; -public class ScouterStatement implements java.sql.Statement { +public class WrStatement implements java.sql.Statement { java.sql.Statement inner; - public ScouterStatement(java.sql.Statement inner) { + public WrStatement(java.sql.Statement inner) { this.inner = inner; } @@ -102,7 +102,7 @@ final public java.sql.ResultSet executeQuery(java.lang.String a0) throws java.sq try { ResultSet rs = this.inner.executeQuery(a0); TraceSQL.end(stat, null); - return new ScouterResultSet(rs); + return new WrResultSet(rs); } catch (SQLException ex) { TraceSQL.end(stat, ex); throw ex; @@ -218,7 +218,7 @@ final public void setCursorName(java.lang.String a0) throws java.sql.SQLExceptio final public java.sql.ResultSet getResultSet() throws java.sql.SQLException { ResultSet rs = this.inner.getResultSet(); - return new ScouterResultSet(rs); + return new WrResultSet(rs); } final public int getUpdateCount() throws java.sql.SQLException { diff --git a/scouter.client.product/icons/launcher.icns b/scouter.client.product/icons/launcher.icns index e69de29bb..222794819 100644 Binary files a/scouter.client.product/icons/launcher.icns and b/scouter.client.product/icons/launcher.icns differ diff --git a/scouter.client.product/icons/launcher.ico b/scouter.client.product/icons/launcher.ico index d69c37502..81e47564e 100644 Binary files a/scouter.client.product/icons/launcher.ico and b/scouter.client.product/icons/launcher.ico differ diff --git a/scouter.client.product/icons/launcher.xpm b/scouter.client.product/icons/launcher.xpm index 3311f5760..17df9c3e8 100644 Binary files a/scouter.client.product/icons/launcher.xpm and b/scouter.client.product/icons/launcher.xpm differ diff --git a/scouter.client/.classpath b/scouter.client/.classpath index f070c1182..0530b715c 100644 --- a/scouter.client/.classpath +++ b/scouter.client/.classpath @@ -2,6 +2,7 @@ + diff --git a/scouter.client/META-INF/MANIFEST.MF b/scouter.client/META-INF/MANIFEST.MF index e6d7eb14e..9e92e0776 100644 --- a/scouter.client/META-INF/MANIFEST.MF +++ b/scouter.client/META-INF/MANIFEST.MF @@ -17,4 +17,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-ClassPath: ., lib/scouter.common.jar, - lib/hibernate-core-3.3.2.GA.jar + lib/hibernate-core-3.3.2.GA.jar, + lib/opencsv-2.4.jar diff --git a/scouter.client/gallery/launcher.icns b/scouter.client/gallery/launcher.icns new file mode 100644 index 000000000..222794819 Binary files /dev/null and b/scouter.client/gallery/launcher.icns differ diff --git a/scouter.client/gallery/original/scouter-logo-cubic4-blue.xcf b/scouter.client/gallery/original/scouter-logo-cubic4-blue.xcf new file mode 100644 index 000000000..6db59bfee Binary files /dev/null and b/scouter.client/gallery/original/scouter-logo-cubic4-blue.xcf differ diff --git a/scouter.client/gallery/original/scouter-logo-cubic4-text-blue.xcf b/scouter.client/gallery/original/scouter-logo-cubic4-text-blue.xcf new file mode 100644 index 000000000..268df33a3 Binary files /dev/null and b/scouter.client/gallery/original/scouter-logo-cubic4-text-blue.xcf differ diff --git a/scouter.client/gallery/original/scouter-logo-cubic4.xcf b/scouter.client/gallery/original/scouter-logo-cubic4.xcf new file mode 100644 index 000000000..41eab1f3e Binary files /dev/null and b/scouter.client/gallery/original/scouter-logo-cubic4.xcf differ diff --git a/scouter.client/gallery/original/scouter-logo-full4.png b/scouter.client/gallery/original/scouter-logo-full4.png new file mode 100644 index 000000000..60c6beb76 Binary files /dev/null and b/scouter.client/gallery/original/scouter-logo-full4.png differ diff --git a/scouter.client/gallery/original/scouter-logo-full4.xcf b/scouter.client/gallery/original/scouter-logo-full4.xcf new file mode 100644 index 000000000..1dc6881cd Binary files /dev/null and b/scouter.client/gallery/original/scouter-logo-full4.xcf differ diff --git a/scouter.client/gallery/original/scouter-logo-full4_blue.xcf b/scouter.client/gallery/original/scouter-logo-full4_blue.xcf new file mode 100644 index 000000000..b2d710047 Binary files /dev/null and b/scouter.client/gallery/original/scouter-logo-full4_blue.xcf differ diff --git a/scouter.client/gallery/original/scouter-logo-splash-blue.xcf b/scouter.client/gallery/original/scouter-logo-splash-blue.xcf new file mode 100644 index 000000000..ba74a24e8 Binary files /dev/null and b/scouter.client/gallery/original/scouter-logo-splash-blue.xcf differ diff --git a/scouter.client/gallery/original/scouter-logo-splash.xcf b/scouter.client/gallery/original/scouter-logo-splash.xcf new file mode 100644 index 000000000..3b9074ce5 Binary files /dev/null and b/scouter.client/gallery/original/scouter-logo-splash.xcf differ diff --git a/scouter.client/gallery/scouter-logo-cubic4-blue.png b/scouter.client/gallery/scouter-logo-cubic4-blue.png new file mode 100644 index 000000000..ef3c14c77 Binary files /dev/null and b/scouter.client/gallery/scouter-logo-cubic4-blue.png differ diff --git a/scouter.client/gallery/scouter-logo-cubic4-text-blue.png b/scouter.client/gallery/scouter-logo-cubic4-text-blue.png new file mode 100644 index 000000000..1aa2591ef Binary files /dev/null and b/scouter.client/gallery/scouter-logo-cubic4-text-blue.png differ diff --git a/scouter.client/gallery/scouter-logo-cubic4.png b/scouter.client/gallery/scouter-logo-cubic4.png new file mode 100644 index 000000000..30b5ee107 Binary files /dev/null and b/scouter.client/gallery/scouter-logo-cubic4.png differ diff --git a/scouter.client/gallery/scouter-logo-full4.png b/scouter.client/gallery/scouter-logo-full4.png new file mode 100644 index 000000000..60c6beb76 Binary files /dev/null and b/scouter.client/gallery/scouter-logo-full4.png differ diff --git a/scouter.client/gallery/scouter-logo-full4_blue_transp.png b/scouter.client/gallery/scouter-logo-full4_blue_transp.png new file mode 100644 index 000000000..f0df9bad5 Binary files /dev/null and b/scouter.client/gallery/scouter-logo-full4_blue_transp.png differ diff --git a/scouter.client/gallery/scouter-logo-full4_blue_transp_all.png b/scouter.client/gallery/scouter-logo-full4_blue_transp_all.png new file mode 100644 index 000000000..94bd5d228 Binary files /dev/null and b/scouter.client/gallery/scouter-logo-full4_blue_transp_all.png differ diff --git a/scouter.client/gallery/scouter-logo-full4_green.png b/scouter.client/gallery/scouter-logo-full4_green.png new file mode 100644 index 000000000..8bd9239a9 Binary files /dev/null and b/scouter.client/gallery/scouter-logo-full4_green.png differ diff --git a/scouter.client/gallery/scouter-logo-full4_green_transp_all.png b/scouter.client/gallery/scouter-logo-full4_green_transp_all.png new file mode 100644 index 000000000..497511a27 Binary files /dev/null and b/scouter.client/gallery/scouter-logo-full4_green_transp_all.png differ diff --git a/scouter.client/gallery/scouter_text.icns b/scouter.client/gallery/scouter_text.icns new file mode 100644 index 000000000..c6edb616d Binary files /dev/null and b/scouter.client/gallery/scouter_text.icns differ diff --git a/scouter.client/icons/about_dialog.png b/scouter.client/icons/about_dialog.png index 1827292ee..79f1a521a 100644 Binary files a/scouter.client/icons/about_dialog.png and b/scouter.client/icons/about_dialog.png differ diff --git a/scouter.client/icons/h128.png b/scouter.client/icons/h128.png index 56ea4c2a7..9904cf3d0 100644 Binary files a/scouter.client/icons/h128.png and b/scouter.client/icons/h128.png differ diff --git a/scouter.client/icons/h16.png b/scouter.client/icons/h16.png index 67050c936..9fec0e47d 100644 Binary files a/scouter.client/icons/h16.png and b/scouter.client/icons/h16.png differ diff --git a/scouter.client/icons/h24.png b/scouter.client/icons/h24.png new file mode 100644 index 000000000..bcf7e762b Binary files /dev/null and b/scouter.client/icons/h24.png differ diff --git a/scouter.client/icons/h256.png b/scouter.client/icons/h256.png index fbada33c0..468bec721 100644 Binary files a/scouter.client/icons/h256.png and b/scouter.client/icons/h256.png differ diff --git a/scouter.client/icons/h32.png b/scouter.client/icons/h32.png index c7855870c..c22219d7b 100644 Binary files a/scouter.client/icons/h32.png and b/scouter.client/icons/h32.png differ diff --git a/scouter.client/icons/h48.png b/scouter.client/icons/h48.png index 755b22747..117304fc7 100644 Binary files a/scouter.client/icons/h48.png and b/scouter.client/icons/h48.png differ diff --git a/scouter.client/icons/h512.png b/scouter.client/icons/h512.png new file mode 100644 index 000000000..ba2e69556 Binary files /dev/null and b/scouter.client/icons/h512.png differ diff --git a/scouter.client/icons/h64.png b/scouter.client/icons/h64.png index 9c3c7248e..8ade99793 100644 Binary files a/scouter.client/icons/h64.png and b/scouter.client/icons/h64.png differ diff --git a/scouter.client/icons/h96.png b/scouter.client/icons/h96.png new file mode 100644 index 000000000..720c1f515 Binary files /dev/null and b/scouter.client/icons/h96.png differ diff --git a/scouter.client/lib/opencsv-2.4.jar b/scouter.client/lib/opencsv-2.4.jar new file mode 100644 index 000000000..eb280eb7a Binary files /dev/null and b/scouter.client/lib/opencsv-2.4.jar differ diff --git a/scouter.client/splash.bmp b/scouter.client/splash.bmp index 8b5b46a00..35c51863a 100644 Binary files a/scouter.client/splash.bmp and b/scouter.client/splash.bmp differ diff --git a/scouter.client/src/scouter/client/actions/ShowCounterObjectSelectionDialogAction.java b/scouter.client/src/scouter/client/actions/ShowCounterObjectSelectionDialogAction.java deleted file mode 100644 index df1d1998c..000000000 --- a/scouter.client/src/scouter/client/actions/ShowCounterObjectSelectionDialogAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * 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.client.actions; - - -import java.util.ArrayList; - -import org.eclipse.jface.action.Action; -import org.eclipse.ui.IWorkbenchWindow; - -import scouter.client.Images; -import scouter.client.model.ICounterObjectSelector; -import scouter.client.popup.XYGraphObjectSelectionDialog; - - -public class ShowCounterObjectSelectionDialogAction extends Action { - public final static String ID = ShowCounterObjectSelectionDialogAction.class.getName(); - - private final IWorkbenchWindow window; - private ICounterObjectSelector objSelector; - private ArrayList objHashAll; - private ArrayList objHashSelected; - private int serverId; - - public ShowCounterObjectSelectionDialogAction(IWorkbenchWindow window, ICounterObjectSelector objSelector, ArrayList objHashAll, ArrayList objHashSelected, int serverId) { - this.window = window; - this.objSelector = objSelector; - this.objHashAll = objHashAll; - this.objHashSelected = objHashSelected; - this.serverId = serverId; - - setText("Select Objects"); - setImageDescriptor(Images.SELECTOR); - setId(ID); - } - - public void run() { - if (window != null) { - XYGraphObjectSelectionDialog dialog = new XYGraphObjectSelectionDialog(window.getShell().getDisplay(), objSelector, serverId); - dialog.show(objHashAll, objHashSelected); - } - } -} diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java b/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java index 6b24fb3d8..0e3a47a3b 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastLongDateAllView.java @@ -16,10 +16,12 @@ */ package scouter.client.counter.views; +import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import org.csstudio.swt.xygraph.dataprovider.CircularBufferDataProvider; @@ -27,8 +29,14 @@ import org.csstudio.swt.xygraph.figures.Trace; import org.csstudio.swt.xygraph.figures.Trace.PointStyle; import org.csstudio.swt.xygraph.figures.XYGraph; +import org.csstudio.swt.xygraph.linearscale.Range; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.draw2d.FigureCanvas; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; import org.eclipse.swt.SWT; @@ -45,6 +53,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.IMemento; @@ -53,10 +62,12 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import au.com.bytecode.opencsv.CSVWriter; + import scouter.client.Images; import scouter.client.counter.actions.OpenPastLongDateAllAction; +import scouter.client.counter.views.CounterPastTimeAllView.ExportDataTask; import scouter.client.model.AgentColorManager; -import scouter.client.model.ICounterObjectSelector; import scouter.client.model.TextProxy; import scouter.client.net.INetReader; import scouter.client.net.TcpProxy; @@ -73,17 +84,19 @@ import scouter.client.util.ImageUtil; import scouter.client.util.MenuUtil; import scouter.client.util.TimeUtil; +import scouter.client.util.TimedSeries; import scouter.client.util.UIUtil; import scouter.client.views.ScouterViewPart; +import scouter.io.DataInputX; import scouter.lang.pack.MapPack; import scouter.lang.value.ListValue; -import scouter.io.DataInputX; import scouter.net.RequestCmd; import scouter.util.CastUtil; import scouter.util.DateUtil; +import scouter.util.FormatUtil; import scouter.util.StringUtil; -public class CounterPastLongDateAllView extends ScouterViewPart implements DualCalendarDialog.ILoadDualCounterDialog, ICounterObjectSelector { +public class CounterPastLongDateAllView extends ScouterViewPart implements DualCalendarDialog.ILoadDualCounterDialog { public static final String ID = CounterPastLongDateAllView.class.getName(); private IMemento memento; @@ -189,10 +202,6 @@ public void run() { for (MapPack mpack : values) { int objHash = mpack.getInt("objHash"); - checkAllList(objHash); - if(!existInSelectedList(objHash)) - continue; - //String insName = mpack.getText("objName"); ListValue time = mpack.getList("time"); ListValue value = mpack.getList("value"); @@ -219,24 +228,6 @@ public void run() { }); } - private void checkAllList(int objHash){ - if(objHashAll.indexOf(objHash) < 0){ - objHashAll.add(objHash); - objHashSelected.add(objHash); - } - } - - private boolean existInSelectedList(int objHash){ - if(objHashSelected.indexOf(objHash) < 0){ - return false; - }else{ - return true; - } - } - - private ArrayList objHashAll = new ArrayList(); - private ArrayList objHashSelected = new ArrayList(); - private void duplicateView() { Server server = ServerManager.getInstance().getServer(serverId); String counterDisplay = ""; @@ -361,6 +352,23 @@ public void run() { } }); + IMenuManager menuManager = getViewSite().getActionBars().getMenuManager(); + menuManager.add(new Action("Export CSV", ImageUtil.getImageDescriptor(Images.csv)) { + public void run() { + FileDialog dialog = new FileDialog(getViewSite().getShell(), SWT.SAVE); + dialog.setOverwrite(true); + String filename = "[" + DateUtil.format(stime, "yyyyMMdd") + "-" + + DateUtil.format(etime - 1, "yyyyMMdd") + "]" + objType + "_" + counter + ".csv"; + dialog.setFileName(filename); + dialog.setFilterExtensions(new String[] { "*.csv", "*.*" }); + dialog.setFilterNames(new String[] { "CSV File(*.csv)", "All Files" }); + String fileSelected = dialog.open(); + if (fileSelected != null) { + new ExportDataTask(fileSelected).schedule(); + } + } + }); + restoreState(); } @@ -578,17 +586,65 @@ public static DatePeriodUnit fromString(String text) { } } - public void setSelections(ArrayList selections) { - Iterator itr = traces.keySet().iterator(); - while(itr.hasNext()){ - xyGraph.removeTrace(traces.get(itr.next())); + class ExportDataTask extends Job { + + String filePath; + + public ExportDataTask(String filePath) { + super("Export..."); + this.filePath = filePath; } - objHashSelected = new ArrayList(selections); - try { - setInput(sDate, eDate, objType, counter, serverId); - } catch (Exception e) { - e.printStackTrace(); + + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + TimedSeries sereis = new TimedSeries(); + Range xRange = xyGraph.primaryXAxis.getRange(); + long lower = (long) xRange.getLower(); + long upper = (long) xRange.getUpper(); + List traceList = xyGraph.getPlotArea().getTraceList(); + List titleValues = new ArrayList(); + titleValues.add("Time"); + for (Trace t : traceList) { + titleValues.add(t.getName()); + CircularBufferDataProvider provider = (CircularBufferDataProvider) t.getDataProvider(); + for (int inx = 0; inx < provider.getSize(); inx++) { + Sample sample = (Sample) provider.getSample(inx); + double x = sample.getXValue(); + if(x < lower || x > upper) { + continue; + } + double y = sample.getYValue(); + sereis.add(t.getName(), (long)x, y); + } + } + List values = new ArrayList(); + values.add(titleValues.toArray(new String[titleValues.size()])); + while (lower < upper) { + List value = new ArrayList(); + value.add(DateUtil.format(lower, "yyyy-MM-dd HH:mm")); + for (int i = 1; i < titleValues.size(); i++) { + String objName = titleValues.get(i); + Double d = sereis.getInTime(objName, lower, DateUtil.MILLIS_PER_FIVE_MINUTE - 1); + if (d != null) { + value.add(FormatUtil.print(d.doubleValue(), "#,###.##")); + } else { + value.add(""); + } + } + values.add(value.toArray(new String[value.size()])); + lower += DateUtil.MILLIS_PER_FIVE_MINUTE; + } + CSVWriter cw = new CSVWriter(new FileWriter(filePath)); + cw.writeAll(values); + cw.flush(); + cw.close(); + } catch (Exception e) { + e.printStackTrace(); + return Status.CANCEL_STATUS; + } + return Status.OK_STATUS; } + } - } \ No newline at end of file diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java index b17028474..a450f3d54 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java @@ -16,10 +16,12 @@ */ package scouter.client.counter.views; +import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Locale; import java.util.Map; @@ -28,8 +30,14 @@ import org.csstudio.swt.xygraph.figures.Trace; import org.csstudio.swt.xygraph.figures.Trace.PointStyle; import org.csstudio.swt.xygraph.figures.XYGraph; +import org.csstudio.swt.xygraph.linearscale.Range; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.draw2d.FigureCanvas; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; import org.eclipse.swt.SWT; @@ -43,6 +51,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.IMemento; @@ -54,7 +63,6 @@ import scouter.client.Images; import scouter.client.counter.actions.OpenPastTimeAllAction; import scouter.client.model.AgentColorManager; -import scouter.client.model.ICounterObjectSelector; import scouter.client.model.TextProxy; import scouter.client.net.INetReader; import scouter.client.net.TcpProxy; @@ -72,17 +80,20 @@ import scouter.client.util.ImageUtil; import scouter.client.util.MenuUtil; import scouter.client.util.TimeUtil; +import scouter.client.util.TimedSeries; import scouter.client.util.UIUtil; import scouter.client.views.ScouterViewPart; +import scouter.io.DataInputX; import scouter.lang.pack.MapPack; import scouter.lang.value.ListValue; -import scouter.io.DataInputX; import scouter.net.RequestCmd; import scouter.util.CastUtil; import scouter.util.DateUtil; +import scouter.util.FormatUtil; import scouter.util.StringUtil; +import au.com.bytecode.opencsv.CSVWriter; -public class CounterPastTimeAllView extends ScouterViewPart implements CalendarDialog.ILoadCounterDialog, ICounterObjectSelector { +public class CounterPastTimeAllView extends ScouterViewPart implements CalendarDialog.ILoadCounterDialog { public static final String ID = CounterPastTimeAllView.class.getName(); private IMemento memento; @@ -176,10 +187,6 @@ public void run() { for (MapPack mpack : values) { int objHash = mpack.getInt("objHash"); - checkAllList(objHash); - if(!existInSelectedList(objHash)) - continue; - //String insName = mpack.getText("objName"); ListValue time = mpack.getList("time"); ListValue value = mpack.getList("value"); @@ -204,24 +211,6 @@ public void run() { }); } - private void checkAllList(int objHash){ - if(objHashAll.indexOf(objHash) < 0){ - objHashAll.add(objHash); - objHashSelected.add(objHash); - } - } - - private boolean existInSelectedList(int objHash){ - if(objHashSelected.indexOf(objHash) < 0){ - return false; - }else{ - return true; - } - } - - private ArrayList objHashAll = new ArrayList(); - private ArrayList objHashSelected = new ArrayList(); - private void duplicateView() { Server server = ServerManager.getInstance().getServer(serverId); String counterDisplay = ""; @@ -263,6 +252,23 @@ public void run() { } }); + IMenuManager menuManager = getViewSite().getActionBars().getMenuManager(); + menuManager.add(new Action("Export CSV", ImageUtil.getImageDescriptor(Images.csv)) { + public void run() { + FileDialog dialog = new FileDialog(getViewSite().getShell(), SWT.SAVE); + dialog.setOverwrite(true); + String filename = "[" + DateUtil.format(startTime, "yyyyMMdd_HHmmss") + "-" + + DateUtil.format(endTime, "HHmmss") + "]" + objType + "_" + counter + ".csv"; + dialog.setFileName(filename); + dialog.setFilterExtensions(new String[] { "*.csv", "*.*" }); + dialog.setFilterNames(new String[] { "CSV File(*.csv)", "All Files" }); + String fileSelected = dialog.open(); + if (fileSelected != null) { + new ExportDataTask(fileSelected).schedule(); + } + } + }); + Composite composite = new Composite(parent, SWT.NONE); GridLayout gLayout = new GridLayout(1, true); gLayout.horizontalSpacing = 0; @@ -505,16 +511,66 @@ public static DatePeriodUnit fromString(String text) { } } - public void setSelections(ArrayList selections) { - Iterator itr = traces.keySet().iterator(); - while(itr.hasNext()){ - xyGraph.removeTrace(traces.get(itr.next())); + class ExportDataTask extends Job { + + String filePath; + + public ExportDataTask(String filePath) { + super("Export..."); + this.filePath = filePath; } - objHashSelected = new ArrayList(selections); - try { - setInput(startTime, endTime, objType, counter, serverId); - } catch (Exception e) { - e.printStackTrace(); + + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + TimedSeries sereis = new TimedSeries(); + Range xRange = xyGraph.primaryXAxis.getRange(); + long lower = (long) xRange.getLower(); + long upper = (long) xRange.getUpper(); + List traceList = xyGraph.getPlotArea().getTraceList(); + List titleValues = new ArrayList(); + titleValues.add("Time"); + for (Trace t : traceList) { + titleValues.add(t.getName()); + CircularBufferDataProvider provider = (CircularBufferDataProvider) t.getDataProvider(); + for (int inx = 0; inx < provider.getSize(); inx++) { + Sample sample = (Sample) provider.getSample(inx); + double x = sample.getXValue(); + if(x < lower || x > upper) { + continue; + } + double y = sample.getYValue(); + sereis.add(t.getName(), (long)x, y); + } + } + List values = new ArrayList(); + values.add(titleValues.toArray(new String[titleValues.size()])); + while (lower < upper) { + List value = new ArrayList(); + value.add(DateUtil.format(lower, "HH:mm:ss")); + for (int i = 1; i < titleValues.size(); i++) { + String objName = titleValues.get(i); + Double d = sereis.getInTime(objName, lower, 3000); + if (d != null) { + value.add(FormatUtil.print(d.doubleValue(), "#,###.##")); + } else { + value.add(""); + } + } + values.add(value.toArray(new String[value.size()])); + lower += 2000; + } + CSVWriter cw = new CSVWriter(new FileWriter(filePath)); + cw.writeAll(values); + cw.flush(); + cw.close(); + } catch (Exception e) { + e.printStackTrace(); + return Status.CANCEL_STATUS; + } + return Status.OK_STATUS; } + } + } \ No newline at end of file diff --git a/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java b/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java index aa1f37aba..e6881692a 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterRealTimeAllView.java @@ -80,11 +80,11 @@ import scouter.client.util.ScouterUtil; import scouter.client.util.TimeUtil; import scouter.client.views.ScouterViewPart; +import scouter.io.DataInputX; import scouter.lang.pack.MapPack; import scouter.lang.value.ListValue; import scouter.lang.value.Value; import scouter.lang.value.ValueEnum; -import scouter.io.DataInputX; import scouter.net.RequestCmd; import scouter.util.CastUtil; import scouter.util.DateUtil; @@ -278,7 +278,6 @@ public void run() { MenuUtil.createCounterContextMenu(ID, canvas, serverId, objType, counter); ObjectSelectManager.getInstance().addObjectCheckStateListener(this); - thread = new RefreshThread(this, 2000); thread.setName(this.toString() + " - " + "objType:" + objType + ", counter:" + counter + ", serverId:" + serverId); thread.start(); diff --git a/scouter.client/src/scouter/client/model/ICounterObjectSelector.java b/scouter.client/src/scouter/client/model/ICounterObjectSelector.java deleted file mode 100644 index f88c3119e..000000000 --- a/scouter.client/src/scouter/client/model/ICounterObjectSelector.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * 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.client.model; - -import java.util.ArrayList; - -public interface ICounterObjectSelector { - - public void setSelections(ArrayList selections); -} diff --git a/scouter.client/src/scouter/client/net/LoginMgr.java b/scouter.client/src/scouter/client/net/LoginMgr.java index c46aba8f2..91e4eb239 100644 --- a/scouter.client/src/scouter/client/net/LoginMgr.java +++ b/scouter.client/src/scouter/client/net/LoginMgr.java @@ -69,6 +69,11 @@ public static boolean login(int serverId, String user, String password){ MapValue mv = (MapValue) value; server.setGroupPolicy(mv); } + Value menuV = out.get("menu"); + if (menuV != null) { + MapValue mv = (MapValue) menuV; + server.setMenuEnableMap(mv); + } CounterEngine counterEngine = server.getCounterEngine(); MapPack m = getCounterXmlServer(serverId); if (m != null) { @@ -126,6 +131,11 @@ public static boolean silentLogin(Server server, String user, String encryptedPw MapValue mv = (MapValue) value; server.setGroupPolicy(mv); } + Value menuV = out.get("menu"); + if (menuV != null) { + MapValue mv = (MapValue) menuV; + server.setMenuEnableMap(mv); + } CounterEngine counterEngine = server.getCounterEngine(); MapPack m = getCounterXmlServer(server.getId()); if (m != null) { diff --git a/scouter.client/src/scouter/client/popup/XYGraphObjectSelectionDialog.java b/scouter.client/src/scouter/client/popup/XYGraphObjectSelectionDialog.java deleted file mode 100644 index af488a4a4..000000000 --- a/scouter.client/src/scouter/client/popup/XYGraphObjectSelectionDialog.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * 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.client.popup; - -import java.util.ArrayList; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import scouter.client.Images; -import scouter.client.model.ICounterObjectSelector; -import scouter.client.model.TextProxy; -import scouter.client.util.TimeUtil; -import scouter.util.DateUtil; - -public class XYGraphObjectSelectionDialog { - - private final Display display; - private Shell dialog; - private ICounterObjectSelector objSelector; - private int serverId; - - ArrayList objHashAll; - ArrayList newSelected; - - public XYGraphObjectSelectionDialog(Display display, ICounterObjectSelector objSelector, int serverId) { - this.display = display; - this.objSelector = objSelector; - this.serverId = serverId; - } - - public void show(ArrayList objHashAll, ArrayList objHashSelected) { - this.objHashAll = objHashAll; - newSelected = new ArrayList(objHashSelected); - - dialog = setDialogLayout(); - dialog.pack(); - - Rectangle rect = dialog.getBounds (); - Point cursorLocation = Display.getCurrent().getCursorLocation(); - dialog.setLocation (cursorLocation.x - (rect.width / 2), cursorLocation.y - (rect.height / 2)); - - dialog.open(); - } - - public void close(){ - if(!dialog.isDisposed()){ - dialog.dispose(); - dialog = null; - } - } - - ArrayList