From ce873e8fbac8fc27b19a2b14467e8c10291e9c98 Mon Sep 17 00:00:00 2001 From: kukgini Date: Thu, 26 Nov 2015 16:09:54 +0900 Subject: [PATCH 01/42] There's no reason to use List for MBeanServer (conflict resolved) --- .../agent/counter/task/TomcatJMXPerf.java | 96 +++++++++---------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/scouter.agent.java/src/scouter/agent/counter/task/TomcatJMXPerf.java b/scouter.agent.java/src/scouter/agent/counter/task/TomcatJMXPerf.java index cd656a328..246e5d3a2 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/TomcatJMXPerf.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/TomcatJMXPerf.java @@ -85,7 +85,7 @@ public boolean equals(Object obj) { return false; } } - private List servers; + private MBeanServer server; private String version; List ctxList = new ArrayList(); public long collectCnt = 0; @@ -103,7 +103,6 @@ public void process(CounterBasket pw) { getContextList(); } collectCnt++; - MBeanServer server = servers.get(0); for (CtxObj ctx : ctxList) { if (ctx.valueType == ValueEnum.DECIMAL) { try { @@ -138,65 +137,62 @@ public void process(CounterBasket pw) { } private HashSet errors = new HashSet(); private void getMBeanServer() { - if (servers == null) { - servers = new LinkedList(); - servers.add(ManagementFactory.getPlatformMBeanServer()); + if (server == null) { + server = ManagementFactory.getPlatformMBeanServer(); } } Configure conf = Configure.getInstance(); private void getContextList() { ctxList.clear(); - for (final MBeanServer server : servers) { - Set mbeans = server.queryNames(null, null); - for (final ObjectName mbean : mbeans) { - String type = mbean.getKeyProperty("type"); - if (type == null) { - continue; - } - if (StringUtil.isEmpty(version) && "Server".equals(type)) { // Server - // Bean - try { - Object value = server.getAttribute(mbean, "serverInfo"); - if (value != null) { - version = value.toString().split("/")[1]; - Logger.println("Tomcat version = " + version); - } - } catch (Exception e) { - e.printStackTrace(); + Set mbeans = server.queryNames(null, null); + for (final ObjectName mbean : mbeans) { + String type = mbean.getKeyProperty("type"); + if (type == null) { + continue; + } + if (StringUtil.isEmpty(version) && "Server".equals(type)) { // Server + // Bean + try { + Object value = server.getAttribute(mbean, "serverInfo"); + if (value != null) { + version = value.toString().split("/")[1]; + Logger.println("Tomcat version = " + version); } + } catch (Exception e) { + e.printStackTrace(); } - if ("GlobalRequestProcessor".equals(type)) { - String port = mbean.getKeyProperty("name"); + } + if ("GlobalRequestProcessor".equals(type)) { + String port = mbean.getKeyProperty("name"); + try { + String objName = conf.objName + "/" + checkObjName(port); + String objType = getReqProcType(); + AgentHeartBeat.addObject(objType, HashUtil.hash(objName), objName); + add(objName, mbean, objType, ValueEnum.DECIMAL, "bytesReceived", + CounterConstants.REQUESTPROCESS_BYTES_RECEIVED); + add(objName, mbean, objType, ValueEnum.DECIMAL, "bytesSent", + CounterConstants.REQUESTPROCESS_BYTES_SENT); + add(objName, mbean, objType, ValueEnum.DECIMAL, "errorCount", + CounterConstants.REQUESTPROCESS_ERROR_COUNT); + add(objName, mbean, objType, ValueEnum.DECIMAL, "processingTime", + CounterConstants.REQUESTPROCESS_PROCESSING_TIME); + add(objName, mbean, objType, ValueEnum.DECIMAL, "requestCount", + CounterConstants.REQUESTPROCESS_REQUEST_COUNT); + } catch (Exception e) { + } + } else if ("DataSource".equals(type)) { // datasource + String name = mbean.getKeyProperty("name"); + if (StringUtil.isNotEmpty(name)) { try { - String objName = conf.objName + "/" + checkObjName(port); - String objType = getReqProcType(); + String objName = conf.objName + "/" + checkObjName(name); + String objType = getDataSourceType(); AgentHeartBeat.addObject(objType, HashUtil.hash(objName), objName); - add(objName, mbean, objType, ValueEnum.DECIMAL, "bytesReceived", - CounterConstants.REQUESTPROCESS_BYTES_RECEIVED); - add(objName, mbean, objType, ValueEnum.DECIMAL, "bytesSent", - CounterConstants.REQUESTPROCESS_BYTES_SENT); - add(objName, mbean, objType, ValueEnum.DECIMAL, "errorCount", - CounterConstants.REQUESTPROCESS_ERROR_COUNT); - add(objName, mbean, objType, ValueEnum.DECIMAL, "processingTime", - CounterConstants.REQUESTPROCESS_PROCESSING_TIME); - add(objName, mbean, objType, ValueEnum.DECIMAL, "requestCount", - CounterConstants.REQUESTPROCESS_REQUEST_COUNT); + add(objName, mbean, objType, ValueEnum.DECIMAL, "numActive", + CounterConstants.DATASOURCE_CONN_ACTIVE); + add(objName, mbean, objType, ValueEnum.DECIMAL, "numIdle", + CounterConstants.DATASOURCE_CONN_IDLE); } catch (Exception e) { } - } else if ("DataSource".equals(type)) { // datasource - String name = mbean.getKeyProperty("name"); - if (StringUtil.isNotEmpty(name)) { - try { - String objName = conf.objName + "/" + checkObjName(name); - String objType = getDataSourceType(); - AgentHeartBeat.addObject(objType, HashUtil.hash(objName), objName); - add(objName, mbean, objType, ValueEnum.DECIMAL, "numActive", - CounterConstants.DATASOURCE_CONN_ACTIVE); - add(objName, mbean, objType, ValueEnum.DECIMAL, "numIdle", - CounterConstants.DATASOURCE_CONN_IDLE); - } catch (Exception e) { - } - } } } } From 768c4f2d773e557432a34de2630d3d8c2788fd0e Mon Sep 17 00:00:00 2001 From: KwonMunsoo Date: Sat, 28 Nov 2015 00:46:01 +0900 Subject: [PATCH 02/42] add SQL Summary in XLogProfileView (not completed) --- .../client/stack/base/PerformanceWindow.java | 4 +- .../client/stack/views/StackAnalyzerView.java | 2 +- .../xlog/dialog/XlogSQLSummaryDialog.java | 293 ++++++++++++++++++ .../client/xlog/views/XLogProfileView.java | 16 +- 4 files changed, 307 insertions(+), 8 deletions(-) create mode 100644 scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java diff --git a/scouter.client/src/scouter/client/stack/base/PerformanceWindow.java b/scouter.client/src/scouter/client/stack/base/PerformanceWindow.java index fac98013a..2195cbb9b 100644 --- a/scouter.client/src/scouter/client/stack/base/PerformanceWindow.java +++ b/scouter.client/src/scouter/client/stack/base/PerformanceWindow.java @@ -37,6 +37,7 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; +import scouter.client.Activator; import scouter.client.Images; import scouter.client.stack.data.StackFileInfo; import scouter.client.stack.data.StackParser; @@ -100,10 +101,11 @@ private void init(Shell shell, String title) { m_shell.setLayout(new FillLayout()); m_performanceTree = new Tree(m_shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); + m_performanceTree.setBackgroundImage(Activator.getImage("icons/grid.jpg")); constructTree(); createTreePopupMenu(); - m_shell.open(); + m_shell.open(); } private void constructTree() { diff --git a/scouter.client/src/scouter/client/stack/views/StackAnalyzerView.java b/scouter.client/src/scouter/client/stack/views/StackAnalyzerView.java index fb4d8221f..7891e3c1e 100644 --- a/scouter.client/src/scouter/client/stack/views/StackAnalyzerView.java +++ b/scouter.client/src/scouter/client/stack/views/StackAnalyzerView.java @@ -89,7 +89,7 @@ private void initializeTree(Composite parent){ TreeColumn treeColumn = new TreeColumn(m_mainTree, SWT.LEFT); treeColumn.setAlignment(SWT.LEFT); treeColumn.setText("Division"); - treeColumn.setWidth(450); + treeColumn.setWidth(300); treeColumn = new TreeColumn(m_mainTree, SWT.RIGHT); treeColumn.setAlignment(SWT.RIGHT); treeColumn.setText("Count"); diff --git a/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java b/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java new file mode 100644 index 000000000..313baf4f5 --- /dev/null +++ b/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java @@ -0,0 +1,293 @@ +package scouter.client.xlog.dialog; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +import scouter.client.model.TextProxy; +import scouter.client.model.XLogData; +import scouter.lang.step.HashedMessageStep; +import scouter.lang.step.SqlStep; +import scouter.lang.step.Step; +import scouter.lang.step.StepEnum; +import scouter.lang.step.StepSingle; +import scouter.util.FormatUtil; +import scouter.util.Hexa32; + +public class XlogSQLSummaryDialog extends Dialog { + private Shell shell; + private Table sqlTable; + private Table bindTable; + private Step[] steps; + private XLogData xperf; + private HashMap sqlMap = new HashMap(); + + public XlogSQLSummaryDialog(Shell shell, Step[] steps, XLogData xperf) { + super(shell); + this.shell = shell; + this.xperf = xperf; + this.steps = steps; + this.shell.setSize(600, 400); + } + + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + FillLayout layout = new FillLayout(); + container.setLayout(layout); + SashForm sashVertForm = new SashForm(container, SWT.VERTICAL); + sashVertForm.SASH_WIDTH = 3; + initSQLTable(sashVertForm); + initBindTable(sashVertForm); + + sashVertForm.setWeights(new int [] {55, 45}); + + processSqlData(); + displaySQLSumData(); + + return container; + } + + private void initSQLTable(Composite parent){ + sqlTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION); + TableColumn tableColumn = new TableColumn(sqlTable, SWT.RIGHT); + tableColumn.setText("Execs"); + tableColumn.setWidth(80); + tableColumn = new TableColumn(sqlTable, SWT.RIGHT); + tableColumn.setText("Binds"); + tableColumn.setWidth(80); + tableColumn = new TableColumn(sqlTable, SWT.RIGHT); + tableColumn.setText("Exec Time"); + tableColumn.setWidth(80); + tableColumn = new TableColumn(sqlTable, SWT.RIGHT); + tableColumn.setText("Fetch Time"); + tableColumn.setWidth(80); + tableColumn = new TableColumn(sqlTable, SWT.RIGHT); + tableColumn.setText("Total Rows"); + tableColumn.setWidth(80); + tableColumn = new TableColumn(sqlTable, SWT.LEFT); + tableColumn.setText("SQL Text"); + tableColumn.setWidth(600); + sqlTable.setHeaderVisible(true); + sqlTable.setVisible(true); + + sqlTable.addSelectionListener(new SelectionListener(){ + public void widgetDefaultSelected(SelectionEvent event) { + } + @SuppressWarnings("unchecked") + public void widgetSelected(SelectionEvent event) { + bindTable.clearAll(); + bindTable.setItemCount(0); + + TableItem item = (TableItem)event.item; + if(item == null) + return; + + Integer hash = (Integer)item.getData(); + ArrayList list = getLBindSumDataList(hash.intValue()); + + TableItem bindItem; + for(BindSumData value : list){ + bindItem = new TableItem(bindTable, SWT.BORDER); + bindItem.setText(value.toTableInfo()); + } + } + }); + } + + private void initBindTable(Composite parent){ + bindTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION); + TableColumn tableColumn = new TableColumn(bindTable, SWT.RIGHT); + tableColumn.setText("Execs"); + tableColumn.setWidth(80); + tableColumn = new TableColumn(bindTable, SWT.RIGHT); + tableColumn.setText("Exec Time"); + tableColumn.setWidth(80); + tableColumn = new TableColumn(bindTable, SWT.RIGHT); + tableColumn.setText("Fetch Time"); + tableColumn.setWidth(80); + tableColumn = new TableColumn(bindTable, SWT.RIGHT); + tableColumn.setText("Total Rows"); + tableColumn.setWidth(80); + tableColumn = new TableColumn(bindTable, SWT.LEFT); + tableColumn.setText("Bind Variabls"); + tableColumn.setWidth(600); + bindTable.setHeaderVisible(true); + bindTable.setVisible(true); + } + + protected void displaySQLSumData(){ + sqlTable.clearAll(); + sqlTable.setItemCount(0); + ArrayList list = getLSQLSumDataList(); + + TableItem item; + for(SQLSumData value : list){ + item = new TableItem(sqlTable, SWT.BORDER); + item.setText(value.toTableInfo()); + item.setData(new Integer(value.hash)); + } + } + + protected void processSqlData(){ + StepSingle stepSingle; + SqlStep sql; + HashedMessageStep message; + SQLSumData sqlSumData = null; + BindSumData bindSumData = null; + String bindParam; + + for (int i = 0; i < steps.length; i++) { + stepSingle = (StepSingle)steps[i]; + + switch(stepSingle.getStepType()){ + case StepEnum.SQL: + case StepEnum.SQL2: + sql = (SqlStep)stepSingle; + + sqlSumData = sqlMap.get(sql.hash); + if(sqlSumData == null){ + sqlSumData = new SQLSumData(); + sqlSumData.hash = sql.hash; + sqlSumData.sqlText = TextProxy.sql.getText(sql.hash); + sqlMap.put(sql.hash, sqlSumData); + } + sqlSumData.execs++; + sqlSumData.execTime += sql.elapsed; + + bindSumData = sqlSumData.bindMap.get(sql.param); + if(bindSumData == null){ + sqlSumData.binds++; + bindSumData = new BindSumData(); + if(sql.param == null){ + bindParam = "[No Value]"; + }else{ + bindParam = sql.param; + } + bindSumData.bindText = bindParam; + sqlSumData.bindMap.put(bindParam, bindSumData); + } + bindSumData.execs++; + bindSumData.execTime += sql.elapsed; + break; + case StepEnum.HASHED_MESSAGE: + message = (HashedMessageStep)stepSingle; + if(!"RESULT-SET-FETCH".equals(TextProxy.hashMessage.getText(message.hash))){ + continue; + } + if(sqlSumData != null){ + sqlSumData.fetchTime += message.time; + sqlSumData.totalRows += message.value; + } + if(bindSumData != null){ + bindSumData.fetchTime += message.time; + bindSumData.totalRows += message.value; + } + break; + } + } + } + + private ArrayList getLSQLSumDataList(){ + ArrayList list = new ArrayList(); + Iterator itor = sqlMap.values().iterator(); + while(itor.hasNext()){ + list.add(itor.next()); + } + return list; + } + + private ArrayList getLBindSumDataList(int hash){ + ArrayList list = new ArrayList(); + SQLSumData sqlSumData = sqlMap.get(hash); + if(sqlSumData == null){ + return null; + } + HashMap bindMap = sqlSumData.bindMap; + Iterator itor = bindMap.values().iterator(); + while(itor.hasNext()){ + list.add(itor.next()); + } + return list; + } + + @Override + protected void okPressed() { + super.okPressed(); + } + + @Override + protected Point getInitialSize() { + return getShell().computeSize(600,400); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(new StringBuilder(100).append("SQL Statistics Summary-").append(TextProxy.service.getText(xperf.p.service)).append('(').append(Hexa32.toString32(xperf.p.txid)).append(")-").append(FormatUtil.print(xperf.p.elapsed, "#,##0")).append("ms").toString()); + } + + @Override + protected boolean isResizable() { + return true; + } + + @Override + protected Control createButtonBar(Composite parent){ + return null; + } + + private class SQLSumData { + public int execs = 0; + public int binds = 0; + public int execTime = 0; + public int fetchTime = 0; + public int totalRows = 0; + public String sqlText = null; + public int hash = 0; + public HashMap bindMap = new HashMap(); + + public String[] toTableInfo(){ + String [] values = new String[6]; + values[0] = FormatUtil.print(execs, "#,##0"); + values[1] = FormatUtil.print(binds, "#,##0"); + values[2] = FormatUtil.print(execTime, "#,##0"); + values[3] = FormatUtil.print(fetchTime, "#,##0"); + values[4] = FormatUtil.print(totalRows, "#,##0"); + values[5] = sqlText; + return values; + } + } + + private class BindSumData { + public int execs = 0; + public int execTime = 0; + public int fetchTime = 0; + public int totalRows = 0; + public String bindText = null; + + public String[] toTableInfo(){ + String [] values = new String[6]; + values[0] = FormatUtil.print(execs, "#,##0"); + values[1] = FormatUtil.print(execTime, "#,##0"); + values[2] = FormatUtil.print(fetchTime, "#,##0"); + values[3] = FormatUtil.print(totalRows, "#,##0"); + values[4] = bindText; + return values; + } + + } +} \ No newline at end of file diff --git a/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java b/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java index ef1726ec5..6c6d276d5 100644 --- a/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java +++ b/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java @@ -26,15 +26,12 @@ import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Font; 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.Composite; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Monitor; -import org.eclipse.ui.IViewReference; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; @@ -43,16 +40,15 @@ import scouter.client.Activator; import scouter.client.Images; -import scouter.client.model.DetachedManager; import scouter.client.model.XLogData; import scouter.client.util.ConsoleProxy; import scouter.client.util.ImageUtil; import scouter.client.util.MyKeyAdapter; -import scouter.client.util.ScouterUtil; import scouter.client.xlog.ProfileText; import scouter.client.xlog.SaveProfileJob; import scouter.client.xlog.actions.OpenXLogProfileJob; import scouter.client.xlog.actions.OpenXLogThreadProfileJob; +import scouter.client.xlog.dialog.XlogSQLSummaryDialog; import scouter.lang.step.Step; import scouter.util.CacheTable; import scouter.util.DateUtil; @@ -94,6 +90,14 @@ public void createPartControl(Composite parent) { text.addKeyListener(adapter); IToolBarManager man = getViewSite().getActionBars().getToolBarManager(); + + man.add( new Action("SQL Statistics", ImageUtil.getImageDescriptor(Images.sum)) { + public void run() { + XlogSQLSummaryDialog sqlSummberDialog = new XlogSQLSummaryDialog(new Shell(getViewSite().getShell().getDisplay(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN ), steps, xLogData); + sqlSummberDialog.open(); + } + }); + Action gridBackAct = new Action("Grid Background", IAction.AS_CHECK_BOX) { public void run() { if (isChecked()) { From da052f876b505a4fc0aa4a023b3e62225b50633c Mon Sep 17 00:00:00 2001 From: KwonMunsoo Date: Sat, 28 Nov 2015 10:21:22 +0900 Subject: [PATCH 03/42] modify sql summary statistics --- .../client/stack/base/FilterInputDialog.java | 3 +- .../client/stack/base/ProgressBarWindow.java | 3 +- .../client/stack/utils/ResourceUtils.java | 8 ---- .../src/scouter/client/util/UIUtil.java | 9 +++++ .../xlog/dialog/XlogSQLSummaryDialog.java | 40 ++++++++++++++++--- 5 files changed, 48 insertions(+), 15 deletions(-) diff --git a/scouter.client/src/scouter/client/stack/base/FilterInputDialog.java b/scouter.client/src/scouter/client/stack/base/FilterInputDialog.java index 29d65608a..e9024eaca 100644 --- a/scouter.client/src/scouter/client/stack/base/FilterInputDialog.java +++ b/scouter.client/src/scouter/client/stack/base/FilterInputDialog.java @@ -27,6 +27,7 @@ import scouter.client.Images; import scouter.client.stack.utils.ResourceUtils; +import scouter.client.util.UIUtil; public class FilterInputDialog { public enum TASK { NONE, PERFORMANCE_TREE, SERVICE_CALL, THREAD_STACK, FILTER_ANALYZER }; @@ -47,7 +48,7 @@ public FilterInputDialog(Shell shell, boolean isAscending, scouter.client.stack. layout.marginWidth = 5; m_shell.setLayoutData(layout); - int [] screen = ResourceUtils.getScreenSize(); + int [] screen = UIUtil.getScreenSize(); m_shell.setLocation((screen[0]/2)-350, (screen[1]/2)-75); m_field = new Text(m_shell, SWT.BORDER | SWT.LEFT); diff --git a/scouter.client/src/scouter/client/stack/base/ProgressBarWindow.java b/scouter.client/src/scouter/client/stack/base/ProgressBarWindow.java index b158ad2d1..f0535ec07 100644 --- a/scouter.client/src/scouter/client/stack/base/ProgressBarWindow.java +++ b/scouter.client/src/scouter/client/stack/base/ProgressBarWindow.java @@ -23,6 +23,7 @@ import org.eclipse.swt.widgets.Shell; import scouter.client.stack.utils.ResourceUtils; +import scouter.client.util.UIUtil; public class ProgressBarWindow{ private Shell m_shell = null; @@ -32,7 +33,7 @@ public ProgressBarWindow(Shell shell, String title){ m_shell = new Shell(shell, SWT.TITLE); m_shell.setText(title); m_shell.setLayout(new FillLayout()); - int [] pos = ResourceUtils.getScreenSize(); + int [] pos = UIUtil.getScreenSize(); m_shell.setBounds((pos[0]/2)-75, (pos[1]/2)-15, 150, 40); m_progressBar = new ProgressBar(m_shell, SWT.HORIZONTAL); diff --git a/scouter.client/src/scouter/client/stack/utils/ResourceUtils.java b/scouter.client/src/scouter/client/stack/utils/ResourceUtils.java index bd6dac04c..f13770cbb 100644 --- a/scouter.client/src/scouter/client/stack/utils/ResourceUtils.java +++ b/scouter.client/src/scouter/client/stack/utils/ResourceUtils.java @@ -43,14 +43,6 @@ public static InputStream getDefaultXMLConfig(){ return ResourceUtils.class.getClassLoader().getResourceAsStream("/scouter/client/stack/doc/config_default.xml"); } - public static int [] getScreenSize(){ - int [] size = new int[2]; - GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - size[0] = gd.getDisplayMode().getWidth(); - size[1] = gd.getDisplayMode().getHeight(); - return size; - } - static public String openFileSaveDialog(String [] names, String [] extensions, String path, String defaultName){ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); FileDialog dialog = new FileDialog(shell, SWT.SAVE); diff --git a/scouter.client/src/scouter/client/util/UIUtil.java b/scouter.client/src/scouter/client/util/UIUtil.java index 9aeb61d3b..aac650c7b 100644 --- a/scouter.client/src/scouter/client/util/UIUtil.java +++ b/scouter.client/src/scouter/client/util/UIUtil.java @@ -17,6 +17,8 @@ */ package scouter.client.util; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.awt.MouseInfo; import java.awt.Point; import java.awt.PointerInfo; @@ -231,4 +233,11 @@ public static GridData gridData(int horAlign){ return gridData; } + public static int [] getScreenSize(){ + int [] size = new int[2]; + GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + size[0] = gd.getDisplayMode().getWidth(); + size[1] = gd.getDisplayMode().getHeight(); + return size; + } } diff --git a/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java b/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java index 313baf4f5..c62129a92 100644 --- a/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java +++ b/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java @@ -1,6 +1,8 @@ package scouter.client.xlog.dialog; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; @@ -20,6 +22,7 @@ import scouter.client.model.TextProxy; import scouter.client.model.XLogData; +import scouter.client.util.UIUtil; import scouter.lang.step.HashedMessageStep; import scouter.lang.step.SqlStep; import scouter.lang.step.Step; @@ -29,7 +32,6 @@ import scouter.util.Hexa32; public class XlogSQLSummaryDialog extends Dialog { - private Shell shell; private Table sqlTable; private Table bindTable; private Step[] steps; @@ -38,10 +40,8 @@ public class XlogSQLSummaryDialog extends Dialog { public XlogSQLSummaryDialog(Shell shell, Step[] steps, XLogData xperf) { super(shell); - this.shell = shell; this.xperf = xperf; - this.steps = steps; - this.shell.setSize(600, 400); + this.steps = steps; } protected Control createDialogArea(Composite parent) { @@ -98,7 +98,9 @@ public void widgetSelected(SelectionEvent event) { Integer hash = (Integer)item.getData(); ArrayList list = getLBindSumDataList(hash.intValue()); - + + Collections.sort(list, new BindSumDataComp()); + TableItem bindItem; for(BindSumData value : list){ bindItem = new TableItem(bindTable, SWT.BORDER); @@ -134,6 +136,8 @@ protected void displaySQLSumData(){ sqlTable.setItemCount(0); ArrayList list = getLSQLSumDataList(); + Collections.sort(list, new SQLSumDataComp()); + TableItem item; for(SQLSumData value : list){ item = new TableItem(sqlTable, SWT.BORDER); @@ -250,6 +254,12 @@ protected Control createButtonBar(Composite parent){ return null; } + @Override + protected void initializeBounds(){ + int[] size = UIUtil.getScreenSize(); + this.getShell().setBounds((size[0]/2)-400, (size[1]/2)-200, 800, 400); + } + private class SQLSumData { public int execs = 0; public int binds = 0; @@ -290,4 +300,24 @@ public String[] toTableInfo(){ } } + + private class SQLSumDataComp implements Comparator{ + public int compare(SQLSumData o1, SQLSumData o2) { + if(o1.execTime > o2.execTime) + return -1; + else if(o1.execTime < o2.execTime) + return 1; + return 0; + } + } + + private class BindSumDataComp implements Comparator{ + public int compare(BindSumData o1, BindSumData o2) { + if(o1.execTime > o2.execTime) + return -1; + else if(o1.execTime < o2.execTime) + return 1; + return 0; + } + } } \ No newline at end of file From 147091b9de28b0e4da7a5e263c8481d3396e02f7 Mon Sep 17 00:00:00 2001 From: KwonMunsoo Date: Sat, 28 Nov 2015 10:23:25 +0900 Subject: [PATCH 04/42] bugfix --- .../src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java b/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java index c62129a92..590c35fee 100644 --- a/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java +++ b/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java @@ -125,7 +125,7 @@ private void initBindTable(Composite parent){ tableColumn.setText("Total Rows"); tableColumn.setWidth(80); tableColumn = new TableColumn(bindTable, SWT.LEFT); - tableColumn.setText("Bind Variabls"); + tableColumn.setText("Bind Variables"); tableColumn.setWidth(600); bindTable.setHeaderVisible(true); bindTable.setVisible(true); From b51180bf9968c70fe79c2899f512780b44fa7d90 Mon Sep 17 00:00:00 2001 From: KwonMunsoo Date: Sat, 28 Nov 2015 14:17:01 +0900 Subject: [PATCH 05/42] rename class --- ...{XlogSQLSummaryDialog.java => XlogSummarySQLDialog.java} | 4 ++-- .../src/scouter/client/xlog/views/XLogProfileView.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename scouter.client/src/scouter/client/xlog/dialog/{XlogSQLSummaryDialog.java => XlogSummarySQLDialog.java} (98%) diff --git a/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java b/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java similarity index 98% rename from scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java rename to scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java index 590c35fee..0bf9b3522 100644 --- a/scouter.client/src/scouter/client/xlog/dialog/XlogSQLSummaryDialog.java +++ b/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java @@ -31,14 +31,14 @@ import scouter.util.FormatUtil; import scouter.util.Hexa32; -public class XlogSQLSummaryDialog extends Dialog { +public class XlogSummarySQLDialog extends Dialog { private Table sqlTable; private Table bindTable; private Step[] steps; private XLogData xperf; private HashMap sqlMap = new HashMap(); - public XlogSQLSummaryDialog(Shell shell, Step[] steps, XLogData xperf) { + public XlogSummarySQLDialog(Shell shell, Step[] steps, XLogData xperf) { super(shell); this.xperf = xperf; this.steps = steps; diff --git a/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java b/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java index 6c6d276d5..cee094c58 100644 --- a/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java +++ b/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java @@ -48,7 +48,7 @@ import scouter.client.xlog.SaveProfileJob; import scouter.client.xlog.actions.OpenXLogProfileJob; import scouter.client.xlog.actions.OpenXLogThreadProfileJob; -import scouter.client.xlog.dialog.XlogSQLSummaryDialog; +import scouter.client.xlog.dialog.XlogSummarySQLDialog; import scouter.lang.step.Step; import scouter.util.CacheTable; import scouter.util.DateUtil; @@ -93,8 +93,8 @@ public void createPartControl(Composite parent) { man.add( new Action("SQL Statistics", ImageUtil.getImageDescriptor(Images.sum)) { public void run() { - XlogSQLSummaryDialog sqlSummberDialog = new XlogSQLSummaryDialog(new Shell(getViewSite().getShell().getDisplay(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN ), steps, xLogData); - sqlSummberDialog.open(); + XlogSummarySQLDialog summberSQLDialog = new XlogSummarySQLDialog(new Shell(getViewSite().getShell().getDisplay(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN ), steps, xLogData); + summberSQLDialog.open(); } }); From b4d98b538b9ac74f433f0ad27a21a77b1871b6cd Mon Sep 17 00:00:00 2001 From: Gunhee Lee Date: Sat, 28 Nov 2015 16:03:52 +0900 Subject: [PATCH 06/42] end user perf gathering scripts --- .gitignore | 2 ++ .../script/src/error/scouter-script-error.js | 19 +++++----- .../script/src/timing/scouter-ajax-timing.js | 7 ++-- .../src/timing/scouter-navigation-timing.js | 35 +++++++++++-------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 18d4cccbf..17b901b3e 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,8 @@ scouter.server/database/ scouter.client.product/plugin_customization.ini scouter.client/plugin_customization.ini +*/*.scouter + ### Vim template [._]*.s[a-w][a-z] [._]s[a-w][a-z] diff --git a/scouter.enduser.script/script/src/error/scouter-script-error.js b/scouter.enduser.script/script/src/error/scouter-script-error.js index 1f86511b8..5c286692b 100644 --- a/scouter.enduser.script/script/src/error/scouter-script-error.js +++ b/scouter.enduser.script/script/src/error/scouter-script-error.js @@ -46,8 +46,10 @@ THE SOFTWARE.*/ */ // The `Scouter` object is the only globally exported variable (function (window, old) { - var self = {}, - lastEvent, + //var self = {}; + var self = old; + + var lastEvent, lastScript, previousNotification, shouldCatch = true, @@ -331,7 +333,7 @@ THE SOFTWARE.*/ // For maximum browser compatibility and cross-domain support, requests are // made by creating a temporary JavaScript `Image` object. function request(url, params) { - url += "?" + serialize(params) + "&ct=img&cb=" + new Date().getTime(); + url += "?" + serialize(params) + "&p=err&z=" + new Date().getTime(); if (typeof SCOUTER_TESTING !== "undefined" && self.testRequest) { self.testRequest(url, params); } else { @@ -378,6 +380,9 @@ THE SOFTWARE.*/ // Validate a Scouter API key exists and is of the correct format. function validateApiKey(apiKey) { + //Skip api key validation + if(1===1) { return true; } + if (!apiKey || !apiKey.match(API_KEY_REGEX)) { log("Invalid API key '" + apiKey + "'"); return false; @@ -433,10 +438,8 @@ THE SOFTWARE.*/ notifierVersion: NOTIFIER_VERSION, apiKey: apiKey, - projectRoot: getSetting("projectRoot") || window.location.protocol + "//" + window.location.host, - context: getSetting("context") || window.location.pathname, - userId: getSetting("userId"), // Deprecated, remove in v3 - user: getSetting("user"), + host: getSetting("host") || window.location.protocol + "//" + window.location.host, + uri: getSetting("uri") || window.location.pathname, metaData: merge(merge({}, getSetting("metaData")), metaData), releaseStage: releaseStage, appVersion: getSetting("appVersion"), @@ -470,7 +473,7 @@ THE SOFTWARE.*/ } // Make the HTTP request - request(getSetting("endpoint") || DEFAULT_NOTIFIER_ENDPOINT, payload); + request(getSetting("endPoint") || DEFAULT_NOTIFIER_ENDPOINT, payload); } // Generate a browser stacktrace (or approximation) from the current stack. diff --git a/scouter.enduser.script/script/src/timing/scouter-ajax-timing.js b/scouter.enduser.script/script/src/timing/scouter-ajax-timing.js index 2bd65b53e..f47989700 100644 --- a/scouter.enduser.script/script/src/timing/scouter-ajax-timing.js +++ b/scouter.enduser.script/script/src/timing/scouter-ajax-timing.js @@ -26,9 +26,9 @@ (function(XHR) { "use strict"; - var _p = window.scouter || {}; + var _p = window.Scouter || {}; var DEFAULT_END_POINT = '/_scouter_browser.jsp'; - var DEFAULT_GXID_HEADER = 'scouter_gxid'; + var DEFAULT_GXID_HEADER = 'SCOUTER'; var DEFAULT_GATHER_RATIO = 100.0; //unit:% - default:100.0% //options @@ -73,8 +73,7 @@ var queryString = JSON.stringify({stats:stats}, undefined, 0); var xhr = new XHR(); xhr.noIntercept = true; - var fullQuery = _p.endPoint + '?p=ax&q=' + encodeURIComponent(queryString); - + var fullQuery = _p.endPoint + '?p=ax&z=' + new Date().getTime() + '&q=' + encodeURIComponent(queryString); if(_p.debug) { console.log('fullQuery = ' + fullQuery); } diff --git a/scouter.enduser.script/script/src/timing/scouter-navigation-timing.js b/scouter.enduser.script/script/src/timing/scouter-navigation-timing.js index 73cdbf0bd..3f16b278c 100644 --- a/scouter.enduser.script/script/src/timing/scouter-navigation-timing.js +++ b/scouter.enduser.script/script/src/timing/scouter-navigation-timing.js @@ -24,9 +24,9 @@ * -- all modern browsers ( IE9+, IOS6+, Chrome any, Safari any, FF any) */ (function() { - var _p = window.scouter || {}; + var _p = window.Scouter || {}; var DEFAULT_END_POINT = "/_scouter_browser.jsp"; - var DEFAULT_GXID_HEADER = 'scouter_gxid'; + var DEFAULT_GXID_HEADER = 'SCOUTER'; var DEFAULT_GATHER_RATIO = 100.0; //unit:% - default:100.0% _p.endPoint = _p.endPoint || DEFAULT_END_POINT; @@ -59,7 +59,7 @@ } var t = performance.timing; var navtiming = { - gxid: resGxId, + gxid: resGxid, navigationStart: t.navigationStart, unloadEventStart: t.unloadEventStart, unloadEventEnd: t.unloadEventEnd, @@ -124,7 +124,7 @@ uri: location.pathname, url: window.location.href, userAgent: navigator.userAgent, - gxid: resGxId, + gxid: t.gxid, navigationStart: t.navigationStart, unloadEventStart: t.unloadEventStart, unloadEventEnd: t.unloadEventEnd, @@ -145,7 +145,10 @@ domContentLoadedEventEnd: t.domContentLoadedEventEnd, domComplete: t.domComplete, loadEventStart: t.loadEventStart, - loadEventEnd: t.loadEventEnd + loadEventEnd: t.loadEventEnd, + StartToResponse : t.responseEnd - t.navigationStart, + StartToDomLoad : t.domComplete - t.navigationStart, + StartTtoTotalLoad : t.loadEventEnd - t.navigationStart }; if(_p.debug) { console.log(sendObj); @@ -158,15 +161,19 @@ img.src = url + "?" + serialize(params) + "&p=nav&z=" + new Date().getTime(); } - /** - * http://www.sitepoint.com/how-to-deal-with-cookies-in-javascript/ - * @param name - * @returns {*} - */ - function getCookie(name) { - var regexp = new RegExp("(?:^" + name + "|;\s*"+ name + ")=(.*?)(?:;|$)", "g"); - var result = regexp.exec(document.cookie); - return (result === null) ? null : result[1]; + function getCookie(name) + { + var i,x,y,cookies=document.cookie.split(";"); + for (i=0;i Date: Sat, 28 Nov 2015 16:29:11 +0900 Subject: [PATCH 07/42] modify gxid default name --- scouter.enduser.script/script/src/timing/scouter-ajax-timing.js | 2 +- .../script/src/timing/scouter-navigation-timing.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scouter.enduser.script/script/src/timing/scouter-ajax-timing.js b/scouter.enduser.script/script/src/timing/scouter-ajax-timing.js index f47989700..b84f3cbf1 100644 --- a/scouter.enduser.script/script/src/timing/scouter-ajax-timing.js +++ b/scouter.enduser.script/script/src/timing/scouter-ajax-timing.js @@ -28,7 +28,7 @@ var _p = window.Scouter || {}; var DEFAULT_END_POINT = '/_scouter_browser.jsp'; - var DEFAULT_GXID_HEADER = 'SCOUTER'; + var DEFAULT_GXID_HEADER = 'X-Scouter-Gxid'; var DEFAULT_GATHER_RATIO = 100.0; //unit:% - default:100.0% //options diff --git a/scouter.enduser.script/script/src/timing/scouter-navigation-timing.js b/scouter.enduser.script/script/src/timing/scouter-navigation-timing.js index 3f16b278c..de2c01772 100644 --- a/scouter.enduser.script/script/src/timing/scouter-navigation-timing.js +++ b/scouter.enduser.script/script/src/timing/scouter-navigation-timing.js @@ -26,7 +26,7 @@ (function() { var _p = window.Scouter || {}; var DEFAULT_END_POINT = "/_scouter_browser.jsp"; - var DEFAULT_GXID_HEADER = 'SCOUTER'; + var DEFAULT_GXID_HEADER = 'X-Scouter-Gxid'; var DEFAULT_GATHER_RATIO = 100.0; //unit:% - default:100.0% _p.endPoint = _p.endPoint || DEFAULT_END_POINT; From e638b310c43dac1e001760e2f8e3df4796473dbc Mon Sep 17 00:00:00 2001 From: Gunhee Lee Date: Sat, 28 Nov 2015 18:04:08 +0900 Subject: [PATCH 08/42] set-cookie gxid on response(except static contents) --- .../src/scouter/agent/trace/TraceContext.java | 3 ++- .../src/scouter/agent/trace/TraceMain.java | 7 +++++-- .../src/scouter/xtra/http/HttpTrace.java | 21 +++++++++++++------ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceContext.java b/scouter.agent.java/src/scouter/agent/trace/TraceContext.java index 752d00bc4..8c53581c4 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceContext.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceContext.java @@ -21,6 +21,7 @@ public class TraceContext { private boolean isSummary; + public boolean isStaticContents; protected TraceContext() { } @@ -33,7 +34,7 @@ public TraceContext(boolean profile_summary) { this.profile = new ProfileCollector(this); } } - + public TraceContext parent; public long txid; public Thread thread; diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java index b82ed5db6..6d658ee48 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java @@ -16,6 +16,7 @@ */ package scouter.agent.trace; import javax.sql.DataSource; + import scouter.agent.Configure; import scouter.agent.Logger; import scouter.agent.counter.meter.MeterService; @@ -170,11 +171,13 @@ private static Object startHttp(Object req, Object res) { ctx.threadId = TraceContextManager.start(ctx.thread, ctx); ctx.bytes = SysJMX.getCurrentThreadAllocBytes(); ctx.profile_thread_cputime = conf.profile_thread_cputime; + http.start(ctx, req, res); if (ctx.serviceName == null) ctx.serviceName = "Non-URI"; Stat stat = new Stat(ctx, req, res); - stat.isStaticContents = isStaticContents(ctx.serviceName); + stat.isStaticContents = ctx.isStaticContents; + if (stat.isStaticContents == false) { PluginHttpServiceTrace.start(ctx, req, res); } @@ -314,7 +317,7 @@ public static void metering(XLogPack pack) { case XLogTypes.BACK_THREAD: } } - private static boolean isStaticContents(String serviceName) { + public static boolean isStaticContents(String serviceName) { int x = serviceName.lastIndexOf('.'); if (x <= 0) return false; diff --git a/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java b/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java index f6775bc55..8fdff9646 100644 --- a/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java +++ b/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java @@ -21,6 +21,7 @@ import java.io.PrintWriter; import java.util.Enumeration; +import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -30,13 +31,12 @@ import scouter.agent.proxy.IHttpTrace; import scouter.agent.trace.IProfileCollector; import scouter.agent.trace.TraceContext; -import scouter.io.DataInputX; +import scouter.agent.trace.TraceMain; import scouter.lang.conf.ConfObserver; import scouter.lang.step.MessageStep; import scouter.util.CompareUtil; import scouter.util.HashUtil; import scouter.util.Hexa32; -import scouter.util.IPUtil; import scouter.util.StringUtil; public class HttpTrace implements IHttpTrace { @@ -75,9 +75,10 @@ public void start(TraceContext ctx, Object req, Object res) { Configure conf = Configure.getInstance(); HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; - + ctx.serviceName = getRequestURI(request); - + ctx.isStaticContents = TraceMain.isStaticContents(ctx.serviceName); + if (conf.service_header_key != null) { String v = request.getHeader(conf.service_header_key); ctx.serviceName = new StringBuilder(ctx.serviceName.length() + v.length() + 5).append(ctx.serviceName) @@ -141,14 +142,22 @@ public void start(TraceContext ctx, Object req, Object res) { } } - if (conf.enable_response_gxid) { + if (conf.enable_response_gxid && !ctx.isStaticContents) { try { if (ctx.gxid == 0) ctx.gxid = ctx.txid; - response.setHeader(conf.gxid, Hexa32.toString32(ctx.gxid) + ":" + ctx.startTime); + + String resGxId = Hexa32.toString32(ctx.gxid) + ":" + ctx.startTime; + response.setHeader(conf.gxid, resGxId); + + Cookie c = new Cookie(conf.gxid, resGxId); + response.addCookie(c); + } catch (Throwable t) { } } + + if (conf.enable_trace_web) { try { ctx.web_name = request.getHeader(conf.key_web_name); From 3261dcd6b790b8f1187f79d47b080959c2a58358 Mon Sep 17 00:00:00 2001 From: KwonMunsoo Date: Sat, 28 Nov 2015 18:18:18 +0900 Subject: [PATCH 09/42] attach SQLFormatDialog at XlogSummarySQLDialog. SQLFormatDialog was converted to modal dialog add SQLMkakerUtil class --- .../scouter/client/popup/SQLFormatDialog.java | 29 ++++++++++++-- .../src/scouter/client/util/SqlMakerUtil.java | 8 ++++ .../src/scouter/client/xlog/ProfileText.java | 5 ++- .../xlog/dialog/XlogSummarySQLDialog.java | 39 +++++++++++++------ .../client/xlog/views/XLogProfileView.java | 5 ++- 5 files changed, 68 insertions(+), 18 deletions(-) create mode 100644 scouter.client/src/scouter/client/util/SqlMakerUtil.java diff --git a/scouter.client/src/scouter/client/popup/SQLFormatDialog.java b/scouter.client/src/scouter/client/popup/SQLFormatDialog.java index f09a88be4..f3a5d567f 100644 --- a/scouter.client/src/scouter/client/popup/SQLFormatDialog.java +++ b/scouter.client/src/scouter/client/popup/SQLFormatDialog.java @@ -20,6 +20,9 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.SelectionAdapter; @@ -33,12 +36,16 @@ import org.hibernate.jdbc.util.BasicFormatterImpl; import scouter.client.util.SqlFormatUtil; +import scouter.client.util.SqlMakerUtil; import scouter.client.util.UIUtil; public class SQLFormatDialog { + public void show(final String message, final String error){ + show(message, error, null); + } - public void show(final String message, final String error) { - final Shell dialog = new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.RESIZE); + public void show(final String message, final String error, final String params) { + final Shell dialog = new Shell(Display.getDefault(), SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM | SWT.RESIZE); UIUtil.setDialogDefaultFunctions(dialog); dialog.setText("SQL"); dialog.setLayout(new GridLayout(1, true)); @@ -62,7 +69,11 @@ public void show(final String message, final String error) { gd.widthHint = 700; gd.heightHint = 500; text.setLayoutData(gd); - SqlFormatUtil.applyStyledFormat(text, message); + if(params == null){ + SqlFormatUtil.applyStyledFormat(text, message); + }else{ + SqlFormatUtil.applyStyledFormat(text, SqlMakerUtil.bindSQL(message, params)); + } text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.stateMask == SWT.CTRL) { @@ -96,6 +107,18 @@ public void widgetSelected(SelectionEvent e) { formatBtn.setEnabled(true); } }); + + final Button copyBtn = new Button(bottomComp, SWT.PUSH); + copyBtn.setLayoutData(UIUtil.formData(null, -1, null, -1, formatBtn, -5, null, -1, 100)); + copyBtn.setText("&Copy"); + copyBtn.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + Clipboard clipboard = new Clipboard(Display.getDefault()); + TextTransfer textTransfer = TextTransfer.getInstance(); + clipboard.setContents(new String[]{text.getText()}, new Transfer[]{textTransfer}); + clipboard.dispose(); + } + }); dialog.pack(); dialog.open(); diff --git a/scouter.client/src/scouter/client/util/SqlMakerUtil.java b/scouter.client/src/scouter/client/util/SqlMakerUtil.java new file mode 100644 index 000000000..9f7ec381b --- /dev/null +++ b/scouter.client/src/scouter/client/util/SqlMakerUtil.java @@ -0,0 +1,8 @@ +package scouter.client.util; + +public class SqlMakerUtil { + static public String bindSQL(String sqlText, String binds){ + String completedSqlText = sqlText; + return completedSqlText; + } +} diff --git a/scouter.client/src/scouter/client/xlog/ProfileText.java b/scouter.client/src/scouter/client/xlog/ProfileText.java index e4415057b..cfaed2635 100644 --- a/scouter.client/src/scouter/client/xlog/ProfileText.java +++ b/scouter.client/src/scouter/client/xlog/ProfileText.java @@ -677,7 +677,10 @@ public static void toString(StringBuffer sb, SqlStep p, int serverId, int lineHe if (StringUtil.isEmpty(p.param) == false) { sb.append("\n").append(StringUtil.leftPad("", lineHead)); Server server = ServerManager.getInstance().getServer(serverId); - boolean showParam = server.isAllowAction(GroupPolicyConstants.ALLOW_SQLPARAMETER); + boolean showParam = true; + if(server != null){ + showParam = server.isAllowAction(GroupPolicyConstants.ALLOW_SQLPARAMETER); + } sb.append("[").append(showParam ? p.param : "******").append("]"); } sb.append(" ").append(FormatUtil.print(p.elapsed, "#,##0")).append(" ms"); diff --git a/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java b/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java index 0bf9b3522..ed348fac2 100644 --- a/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java +++ b/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java @@ -9,9 +9,10 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -22,6 +23,7 @@ import scouter.client.model.TextProxy; import scouter.client.model.XLogData; +import scouter.client.popup.SQLFormatDialog; import scouter.client.util.UIUtil; import scouter.lang.step.HashedMessageStep; import scouter.lang.step.SqlStep; @@ -41,7 +43,7 @@ public class XlogSummarySQLDialog extends Dialog { public XlogSummarySQLDialog(Shell shell, Step[] steps, XLogData xperf) { super(shell); this.xperf = xperf; - this.steps = steps; + this.steps = steps; } protected Control createDialogArea(Composite parent) { @@ -101,10 +103,12 @@ public void widgetSelected(SelectionEvent event) { Collections.sort(list, new BindSumDataComp()); + String sqlText = sqlMap.get(hash).sqlText; TableItem bindItem; for(BindSumData value : list){ bindItem = new TableItem(bindTable, SWT.BORDER); bindItem.setText(value.toTableInfo()); + bindItem.setData(sqlText); } } }); @@ -129,6 +133,27 @@ private void initBindTable(Composite parent){ tableColumn.setWidth(600); bindTable.setHeaderVisible(true); bindTable.setVisible(true); + bindTable.setToolTipText("Please double click on in order to view the complete SQL statement"); + bindTable.addMouseListener(new MouseListener(){ + public void mouseDoubleClick(MouseEvent event) { + TableItem [] items = bindTable.getSelection(); + if(items.length == 0){ + return; + } + TableItem item = items[0]; + String sqlText = (String)item.getData(); + String binds = item.getText(4); + new SQLFormatDialog().show(sqlText, null, binds); + } + + @Override + public void mouseDown(MouseEvent event) { + } + + @Override + public void mouseUp(MouseEvent event) { + } + }); } protected void displaySQLSumData(){ @@ -228,16 +253,6 @@ private ArrayList getLBindSumDataList(int hash){ return list; } - @Override - protected void okPressed() { - super.okPressed(); - } - - @Override - protected Point getInitialSize() { - return getShell().computeSize(600,400); - } - @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); diff --git a/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java b/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java index cee094c58..f2c438621 100644 --- a/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java +++ b/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java @@ -29,6 +29,7 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; @@ -92,8 +93,8 @@ public void createPartControl(Composite parent) { IToolBarManager man = getViewSite().getActionBars().getToolBarManager(); man.add( new Action("SQL Statistics", ImageUtil.getImageDescriptor(Images.sum)) { - public void run() { - XlogSummarySQLDialog summberSQLDialog = new XlogSummarySQLDialog(new Shell(getViewSite().getShell().getDisplay(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN ), steps, xLogData); + public void run() { + XlogSummarySQLDialog summberSQLDialog = new XlogSummarySQLDialog(new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN), steps, xLogData); summberSQLDialog.open(); } }); From fa368062d31cf626cbd5a525374237f3bc178391 Mon Sep 17 00:00:00 2001 From: KwonMunsoo Date: Sat, 28 Nov 2015 20:50:45 +0900 Subject: [PATCH 10/42] class to bind params with SQL Text --- .../src/scouter/client/util/SqlMakerUtil.java | 114 +++++++++++++++++- 1 file changed, 110 insertions(+), 4 deletions(-) diff --git a/scouter.client/src/scouter/client/util/SqlMakerUtil.java b/scouter.client/src/scouter/client/util/SqlMakerUtil.java index 9f7ec381b..7521f0f10 100644 --- a/scouter.client/src/scouter/client/util/SqlMakerUtil.java +++ b/scouter.client/src/scouter/client/util/SqlMakerUtil.java @@ -1,8 +1,114 @@ package scouter.client.util; +import java.util.ArrayList; + public class SqlMakerUtil { - static public String bindSQL(String sqlText, String binds){ - String completedSqlText = sqlText; - return completedSqlText; + static public String bindSQL(String sqlText, String params){ + if(params == null || "".equals(params)){ + return sqlText; + } + + ArrayList binds = divideParams(params); + if(binds == null || binds.size() == 0){ + return sqlText; + } + + int index = 0; + int pos = 0; + + int sqlLength = sqlText.length(); + int bindLength = binds.size(); + String bind; + int search; + boolean isChar; + + StringBuilder sb = new StringBuilder(100); + while(pos < sqlLength){ + search = sqlText.indexOf('@', pos); + + if(search < 0 || index >= bindLength){ + sb.append(sqlText.substring(pos)); + break; + } + + bind = binds.get(index); + if(bind.charAt(0) == '\''){ + isChar = true; + }else{ + isChar = false; + } + + if(isChar){ + if(search == 0 || (search + 1) == sqlLength){ + return errorMessage(sb, sqlText, bind, "SQL Character Position Check", pos, search, isChar); + } + + if(sqlText.charAt(search - 1) != '\'' || sqlText.charAt(search + 1) != '\''){ + return errorMessage(sb, sqlText, bind, "SQL Character Quata Check", pos, search, isChar); + } + + sb.append(sqlText.subSequence(pos, search - 1)); + sb.append(bind); + pos = search + 2; + }else{ + if(search > 0){ + if(" \t=<>,+-*/|^&(".indexOf(sqlText.charAt(search-1))<0){ + return errorMessage(sb, sqlText, bind, "Number Check", pos, search, isChar); + } + } + sb.append(sqlText.subSequence(pos, search)); + sb.append(bind); + pos = search + 1; + } + + index++; + } + + return sb.toString(); + } + + static private String errorMessage(StringBuilder sb, String sqlText, String param, String error, int pos, int search, boolean isChar){ + sb.append(sqlText.substring(pos,search)); + sb.append('[').append(error).append('-').append(param).append(']').append(sqlText.substring(search)); + return "Fail to convert =>\r\n" + sb.toString(); + } + + static private ArrayList divideParams(String params){ + if(params == null || "".equals(params.trim())){ + return null; + } + ArrayList binds = new ArrayList(); + + char ch; + int start = 0; + boolean isQ = false; + boolean isDQ = false; + int size = params.length(); + for(int i = 0; i< size; i++){ + ch = params.charAt(i); + if(ch == ',' && !isQ && !isDQ){ + binds.add(params.substring(start, i)); + start = i + 1; + continue; + } + if(ch != '\'' && ch != '\"' ){ + continue; + } + if(ch == '\''){ + if(isQ){ + isQ = false; + }else{ + isQ = true; + } + }else if(ch == '\"'){ + if(isDQ){ + isDQ = false; + }else{ + isDQ = true; + } + } + } + binds.add(params.substring(start)); + return binds; } -} +} \ No newline at end of file From 77223a8cc70bbe057aceba6f57a01ebc58469ce0 Mon Sep 17 00:00:00 2001 From: KwonMunsoo Date: Sun, 29 Nov 2015 21:11:19 +0900 Subject: [PATCH 11/42] convert to :1 from ? append bind params to SQL text --- .../scouter/client/popup/SQLFormatDialog.java | 18 ++++- .../src/scouter/client/util/SqlMakerUtil.java | 68 ++++++++++++++++--- 2 files changed, 75 insertions(+), 11 deletions(-) diff --git a/scouter.client/src/scouter/client/popup/SQLFormatDialog.java b/scouter.client/src/scouter/client/popup/SQLFormatDialog.java index f3a5d567f..d35571183 100644 --- a/scouter.client/src/scouter/client/popup/SQLFormatDialog.java +++ b/scouter.client/src/scouter/client/popup/SQLFormatDialog.java @@ -102,7 +102,23 @@ public void widgetSelected(SelectionEvent e) { formatBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { formatBtn.setEnabled(false); - String formateed = new BasicFormatterImpl().format(text.getText()); + + String inputSQL = text.getText(); + String bindVariables = null; + + int search = -1; + if(inputSQL != null){ + search = inputSQL.indexOf(SqlMakerUtil.SQLDIVIDE); + if(search >= 0){ + bindVariables = inputSQL.substring(search); + inputSQL = inputSQL.substring(0, search); + } + } + String formateed = new BasicFormatterImpl().format(inputSQL); + if(search >=0){ + formateed = formateed + bindVariables; + } + text.setText(formateed); formatBtn.setEnabled(true); } diff --git a/scouter.client/src/scouter/client/util/SqlMakerUtil.java b/scouter.client/src/scouter/client/util/SqlMakerUtil.java index 7521f0f10..0e2a8de92 100644 --- a/scouter.client/src/scouter/client/util/SqlMakerUtil.java +++ b/scouter.client/src/scouter/client/util/SqlMakerUtil.java @@ -3,6 +3,8 @@ import java.util.ArrayList; public class SqlMakerUtil { + public static String SQLDIVIDE = "\r\n\r\n[Bind Variables]\r\n"; + static public String bindSQL(String sqlText, String params){ if(params == null || "".equals(params)){ return sqlText; @@ -16,7 +18,13 @@ static public String bindSQL(String sqlText, String params){ int index = 0; int pos = 0; - int sqlLength = sqlText.length(); + if(sqlText == null || sqlText.length() == 0){ + return "No SQL Text"; + } + + String newSqlText = convertBindVariable(sqlText); + + int sqlLength = newSqlText.length(); int bindLength = binds.size(); String bind; int search; @@ -24,10 +32,10 @@ static public String bindSQL(String sqlText, String params){ StringBuilder sb = new StringBuilder(100); while(pos < sqlLength){ - search = sqlText.indexOf('@', pos); + search = newSqlText.indexOf('@', pos); if(search < 0 || index >= bindLength){ - sb.append(sqlText.substring(pos)); + sb.append(newSqlText.substring(pos)); break; } @@ -40,23 +48,23 @@ static public String bindSQL(String sqlText, String params){ if(isChar){ if(search == 0 || (search + 1) == sqlLength){ - return errorMessage(sb, sqlText, bind, "SQL Character Position Check", pos, search, isChar); + return errorMessage(sb, newSqlText, bind, "SQL Character Position Check", pos, search, isChar); } - if(sqlText.charAt(search - 1) != '\'' || sqlText.charAt(search + 1) != '\''){ - return errorMessage(sb, sqlText, bind, "SQL Character Quata Check", pos, search, isChar); + if(newSqlText.charAt(search - 1) != '\'' || newSqlText.charAt(search + 1) != '\''){ + return errorMessage(sb, newSqlText, bind, "SQL Character Quata Check", pos, search, isChar); } - sb.append(sqlText.subSequence(pos, search - 1)); + sb.append(newSqlText.subSequence(pos, search - 1)); sb.append(bind); pos = search + 2; }else{ if(search > 0){ - if(" \t=<>,+-*/|^&(".indexOf(sqlText.charAt(search-1))<0){ - return errorMessage(sb, sqlText, bind, "Number Check", pos, search, isChar); + if(" \t=<>,+-*/|^&(".indexOf(newSqlText.charAt(search-1))<0){ + return errorMessage(sb, newSqlText, bind, "Number Check", pos, search, isChar); } } - sb.append(sqlText.subSequence(pos, search)); + sb.append(newSqlText.subSequence(pos, search)); sb.append(bind); pos = search + 1; } @@ -64,6 +72,38 @@ static public String bindSQL(String sqlText, String params){ index++; } + if(index < bindLength){ + sb.append(SQLDIVIDE); + + int inx = 1; + for(int i = index; i < bindLength; i++){ + sb.append(':').append(inx).append(" - ").append(binds.get(i)).append("\r\n"); + inx++; + } + } + + return sb.toString(); + } + + static private String convertBindVariable(String sqlText){ // convert to ':1' from '?' + StringBuilder sb = new StringBuilder(sqlText.length() + 40); + + int sqlLength = sqlText.length(); + int search; + int index = 1; + int pos = 0; + + while(pos < sqlLength){ + search = sqlText.indexOf('?', pos); + + if(search < 0 ){ + sb.append(sqlText.substring(pos)); + break; + } + sb.append(sqlText.substring(pos, search)).append(':').append(index); + index++; + pos = search + 1; + } return sb.toString(); } @@ -111,4 +151,12 @@ static private ArrayList divideParams(String params){ binds.add(params.substring(start)); return binds; } + + static public void main(String [] args){ + try { + System.out.println(convertBindVariable("?sel?ect =? test???-?-?")); + }catch(Exception ex){ + ex.printStackTrace(); + } + } } \ No newline at end of file From bbaada0f52c405a7de35d79cdc16026f06d35282 Mon Sep 17 00:00:00 2001 From: Gunhee Lee Date: Sun, 29 Nov 2015 21:31:22 +0900 Subject: [PATCH 12/42] add configure String enduser_perf_endpoint --- scouter.agent.java/src/scouter/agent/Configure.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scouter.agent.java/src/scouter/agent/Configure.java b/scouter.agent.java/src/scouter/agent/Configure.java index 24272b8df..ce255f92f 100644 --- a/scouter.agent.java/src/scouter/agent/Configure.java +++ b/scouter.agent.java/src/scouter/agent/Configure.java @@ -214,6 +214,8 @@ public final static synchronized Configure getInstance() { public boolean log_rotation=true; public int log_keep_dates=7; + public String enduser_perf_endpoint = "_scouter_browser.jsp"; + /** * sometimes call by sample application, at that time normally set some * properties directly @@ -462,6 +464,8 @@ private void apply() { this.log_rotation = getBoolean("log_rotation", true); this.log_keep_dates = getInt("log_keep_dates", 7); + this.enduser_perf_endpoint = getValue("enduser_perf_endpoint", "_scouter_browser.jsp"); + resetObjInfo(); setErrorStatus(); setStaticContents(); From 33cbc50001fad9f2d5853f22e0e14804188cf4dc Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Mon, 30 Nov 2015 09:21:14 +0900 Subject: [PATCH 13/42] copy dialog --- scouter.client/src/scouter/client/popup/SQLFormatDialog.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scouter.client/src/scouter/client/popup/SQLFormatDialog.java b/scouter.client/src/scouter/client/popup/SQLFormatDialog.java index d35571183..a913a34a5 100644 --- a/scouter.client/src/scouter/client/popup/SQLFormatDialog.java +++ b/scouter.client/src/scouter/client/popup/SQLFormatDialog.java @@ -17,6 +17,7 @@ */ package scouter.client.popup; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; @@ -133,6 +134,7 @@ public void widgetSelected(SelectionEvent e) { TextTransfer textTransfer = TextTransfer.getInstance(); clipboard.setContents(new String[]{text.getText()}, new Transfer[]{textTransfer}); clipboard.dispose(); + MessageDialog.openInformation(dialog, "Copy", "Copied to clipboard"); } }); From 74fff8a6e10a5ce173738cba037f79fa8c02e90b Mon Sep 17 00:00:00 2001 From: SkyWorker Date: Mon, 30 Nov 2015 16:27:38 +0900 Subject: [PATCH 14/42] add summary db for bw --- .../src/scouter/agent/Configure.java | 16 +- .../agent/counter/task/ServicePerf.java | 29 +- .../scouter/agent/netio/data/net/Test.java | 19 ++ .../scouter/agent/proxy/HttpTraceFactory.java | 81 +++--- .../src/scouter/agent/proxy/IHttpTrace.java | 4 +- .../agent/summary/EndUserAjaxData.java | 26 ++ .../agent/summary/EndUserErrorData.java | 30 +++ .../agent/summary/EndUserNavigationData.java | 43 +++ .../scouter/agent/summary/EndUserSummary.java | 251 ++++++++++++++++++ .../src/scouter/agent/trace/TraceContext.java | 6 +- .../src/scouter/agent/trace/TraceMain.java | 17 +- .../src/scouter/xtra/http/HttpTrace.java | 41 ++- .../src/scouter/lang/SummaryEnum.java | 5 + .../src/scouter/net/RequestCmd.java | 6 +- .../src/scouter/server/db/SummaryRD.scala | 106 ++++---- .../src/scouter/server/db/SummaryWR.scala | 152 ++++++----- .../service/handle/SummaryEndUserAjax.scala | 114 ++++++++ .../service/handle/SummaryEndUserError.scala | 127 +++++++++ .../service/handle/SummaryEndUserNav.scala | 194 ++++++++++++++ 19 files changed, 1082 insertions(+), 185 deletions(-) create mode 100644 scouter.agent.java/src/scouter/agent/netio/data/net/Test.java create mode 100644 scouter.agent.java/src/scouter/agent/summary/EndUserAjaxData.java create mode 100644 scouter.agent.java/src/scouter/agent/summary/EndUserErrorData.java create mode 100644 scouter.agent.java/src/scouter/agent/summary/EndUserNavigationData.java create mode 100644 scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java create mode 100644 scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserAjax.scala create mode 100644 scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserError.scala create mode 100644 scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserNav.scala diff --git a/scouter.agent.java/src/scouter/agent/Configure.java b/scouter.agent.java/src/scouter/agent/Configure.java index ce255f92f..8df68d2ae 100644 --- a/scouter.agent.java/src/scouter/agent/Configure.java +++ b/scouter.agent.java/src/scouter/agent/Configure.java @@ -205,6 +205,11 @@ public final static synchronized Configure getInstance() { public int summary_service_ip_max = 5000; public int summary_service_ua_max = 5000; public int summary_service_error_max = 500; + + public int summary_enduser_nav_max = 5000; + public int summary_enduser_ajax_max = 5000; + public int summary_enduser_error_max = 5000; + public int heap_perm_warning_pct = 90; public long heap_perm_alert_interval = 30000; public boolean hook_spring_request_mapping = false; @@ -215,6 +220,7 @@ public final static synchronized Configure getInstance() { public int log_keep_dates=7; public String enduser_perf_endpoint = "_scouter_browser.jsp"; + public int enduser_perf_endpoint_hash = HashUtil.hash(enduser_perf_endpoint); /** * sometimes call by sample application, at that time normally set some @@ -449,6 +455,12 @@ private void apply() { this.summary_service_ip_max = getInt("summary_service_ip_max", 5000); this.summary_service_ua_max = getInt("summary_service_ua_max", 5000); this.summary_service_error_max = getInt("summary_service_error_max", 500); + + this.summary_enduser_nav_max = getInt("summary_enduser_nav_max", 5000); + this.summary_enduser_ajax_max = getInt("summary_enduser_ajax_max", 5000); + this.summary_enduser_error_max = getInt("summary_enduser_error_max", 5000); + + this.heap_perm_alert_interval = getLong("heap_perm_alert_interval", 30000); this.heap_perm_warning_pct = getInt("heap_perm_warning_pct", 90); this.hook_spring_request_mapping = getBoolean("hook_spring_request_mapping", false); @@ -465,7 +477,8 @@ private void apply() { this.log_keep_dates = getInt("log_keep_dates", 7); this.enduser_perf_endpoint = getValue("enduser_perf_endpoint", "_scouter_browser.jsp"); - + this.enduser_perf_endpoint_hash = HashUtil.hash(this.enduser_perf_endpoint); + resetObjInfo(); setErrorStatus(); setStaticContents(); @@ -638,6 +651,7 @@ public void printConfig() { ignoreSet.add("objName"); ignoreSet.add("objType"); ignoreSet.add("log_ignore_set"); + ignoreSet.add("enduser_perf_endpoint_hash"); } public MapValue getKeyValueInfo() { StringKeyLinkedMap defMap = ConfigValueUtil.getConfigDefault(new Configure(true)); 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 59cb51a4d..f41cc7b46 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/ServicePerf.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/ServicePerf.java @@ -23,6 +23,7 @@ import scouter.agent.counter.meter.MeterResource; import scouter.agent.counter.meter.MeterService; import scouter.agent.netio.data.DataProxy; +import scouter.agent.summary.EndUserSummary; import scouter.agent.summary.ServiceSummary; import scouter.agent.trace.TraceContextManager; import scouter.agent.util.DumpUtil; @@ -119,7 +120,7 @@ public void summay(CounterBasket pw) { p.time = time; DataProxy.send(p); } - + p = ServiceSummary.getInstance().getAndClearX(SummaryEnum.IP); if (p != null) { p.time = time; @@ -136,4 +137,30 @@ public void summay(CounterBasket pw) { DataProxy.send(p); } } + + @Counter(interval = 500) + public void enduser(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 = EndUserSummary.getInstance().getAndClearNavTable(); + if (p != null) { + p.time = time; + DataProxy.send(p); + } + p = EndUserSummary.getInstance().getAndClearAjaxTable(); + if (p != null) { + p.time = time; + DataProxy.send(p); + } + p = EndUserSummary.getInstance().getAndClearErrorTable(); + 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/net/Test.java b/scouter.agent.java/src/scouter/agent/netio/data/net/Test.java new file mode 100644 index 000000000..a1a5d378f --- /dev/null +++ b/scouter.agent.java/src/scouter/agent/netio/data/net/Test.java @@ -0,0 +1,19 @@ +package scouter.agent.netio.data.net; + +import java.net.DatagramSocket; +import java.net.SocketException; +import java.util.ArrayList; + +public class Test { + + public static void main(String[] args) throws SocketException { + ArrayList a = new ArrayList(); + for(int i = 0 ; i < 10;i++){ + DatagramSocket d = new DatagramSocket(0); + a.add(d); + System.out.println(d.getLocalPort()); + } + + } + +} diff --git a/scouter.agent.java/src/scouter/agent/proxy/HttpTraceFactory.java b/scouter.agent.java/src/scouter/agent/proxy/HttpTraceFactory.java index 2c465b8f0..9d3514026 100644 --- a/scouter.agent.java/src/scouter/agent/proxy/HttpTraceFactory.java +++ b/scouter.agent.java/src/scouter/agent/proxy/HttpTraceFactory.java @@ -14,44 +14,49 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package scouter.agent.proxy; - +package scouter.agent.proxy; + import scouter.agent.Logger; import scouter.agent.trace.TraceContext; - -public class HttpTraceFactory { - private static final String HTTP_TRACE = "scouter.xtra.http.HttpTrace"; - - public static final IHttpTrace dummy = new IHttpTrace() { - public String getParameter(Object req, String key) { - return null; - } - - public void start(TraceContext ctx, Object req, Object res) { - } - - public void end(TraceContext ctx, Object req, Object res) { - } - - public void rejectText(Object res, String text) { - } - - public void rejectUrl(Object res, String url) { - } - };; - - public static IHttpTrace create(ClassLoader parent) { - try { - ClassLoader loader = LoaderManager.getHttpLoader(parent); - if (loader == null) { - return dummy; - } - Class c = Class.forName(HTTP_TRACE, true, loader); - return (IHttpTrace) c.newInstance(); - } catch (Throwable e) { - Logger.println("A133", "fail to create", e); - return dummy; - } - } - + +public class HttpTraceFactory { + private static final String HTTP_TRACE = "scouter.xtra.http.HttpTrace"; + + public static final IHttpTrace dummy = new IHttpTrace() { + public String getParameter(Object req, String key) { + return null; + } + + public String getHeader(Object req, String key) { + return null; + } + + public void start(TraceContext ctx, Object req, Object res) { + } + + public void end(TraceContext ctx, Object req, Object res) { + } + + public void rejectText(Object res, String text) { + } + + public void rejectUrl(Object res, String url) { + } + + }; + + public static IHttpTrace create(ClassLoader parent) { + try { + ClassLoader loader = LoaderManager.getHttpLoader(parent); + if (loader == null) { + return dummy; + } + Class c = Class.forName(HTTP_TRACE, true, loader); + return (IHttpTrace) c.newInstance(); + } catch (Throwable e) { + Logger.println("A133", "fail to create", e); + return dummy; + } + } + } diff --git a/scouter.agent.java/src/scouter/agent/proxy/IHttpTrace.java b/scouter.agent.java/src/scouter/agent/proxy/IHttpTrace.java index bc2d10c9b..2b7fbf5dc 100644 --- a/scouter.agent.java/src/scouter/agent/proxy/IHttpTrace.java +++ b/scouter.agent.java/src/scouter/agent/proxy/IHttpTrace.java @@ -28,6 +28,8 @@ public interface IHttpTrace { public void rejectText(Object res, String text); - public void rejectUrl(Object res, String url); + public void rejectUrl(Object res, String url); + + public String getHeader(Object req, String key); } \ No newline at end of file diff --git a/scouter.agent.java/src/scouter/agent/summary/EndUserAjaxData.java b/scouter.agent.java/src/scouter/agent/summary/EndUserAjaxData.java new file mode 100644 index 000000000..21ecd3605 --- /dev/null +++ b/scouter.agent.java/src/scouter/agent/summary/EndUserAjaxData.java @@ -0,0 +1,26 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package scouter.agent.summary; + +public class EndUserAjaxData { + public int uri; + public int ip; + public int count; + // + public long duration; + public int userAgent; +} diff --git a/scouter.agent.java/src/scouter/agent/summary/EndUserErrorData.java b/scouter.agent.java/src/scouter/agent/summary/EndUserErrorData.java new file mode 100644 index 000000000..6f66d0a93 --- /dev/null +++ b/scouter.agent.java/src/scouter/agent/summary/EndUserErrorData.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package scouter.agent.summary; + +public class EndUserErrorData { + public int stacktrace; + public int userAgent; + public int count; + // + public int uri; + public int message; + public int file; + public int lineNumber;// :1 + public int columnNumber;// :26 + public int payloadVersion;// :2 +} diff --git a/scouter.agent.java/src/scouter/agent/summary/EndUserNavigationData.java b/scouter.agent.java/src/scouter/agent/summary/EndUserNavigationData.java new file mode 100644 index 000000000..919b968f4 --- /dev/null +++ b/scouter.agent.java/src/scouter/agent/summary/EndUserNavigationData.java @@ -0,0 +1,43 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package scouter.agent.summary; + +public class EndUserNavigationData { + public int uri; + public int ip; + public int count; + // + public long navigationStart; + public long unloadEventStart; + public long unloadEventEnd; + public long fetchStart; + public long domainLookupStart; + public long domainLookupEnd; + public long connectStart; + public long connectEnd; + public long requestStart; + public long responseStart; + public long responseEnd; + public long domLoading; + public long domInteractive; + public long domContentLoadedEventStart; + public long domContentLoadedEventEnd; + public long domComplete; + public long loadEventStart; + public long loadEventEnd; + +} diff --git a/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java b/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java new file mode 100644 index 000000000..4dc456009 --- /dev/null +++ b/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java @@ -0,0 +1,251 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package scouter.agent.summary; + +import java.util.Enumeration; + +import scouter.agent.Configure; +import scouter.lang.SummaryEnum; +import scouter.lang.pack.SummaryPack; +import scouter.lang.value.ListValue; +import scouter.util.BitUtil; +import scouter.util.LongKeyLinkedMap; + +public class EndUserSummary { + + private static EndUserSummary instance = null; + + public final static synchronized EndUserSummary getInstance() { + if (instance == null) { + instance = new EndUserSummary(); + } + return instance; + } + + private Configure conf = Configure.getInstance(); + + public void process(EndUserNavigationData p) { + if (conf.enable_summary == false) + return; + // service summary + long key = BitUtil.composite(p.uri, p.ip); + EndUserNavigationData d = navTable.get(key); + if (d == null) { + navTable.put(key, p); + return; + } + d.count += p.count; + d.unloadEventStart += p.unloadEventStart; + d.unloadEventEnd += p.unloadEventEnd; + d.fetchStart += p.fetchStart; + d.domainLookupStart += p.domainLookupStart; + d.domainLookupEnd += p.domainLookupEnd; + d.connectStart += p.connectStart; + d.connectEnd += p.connectEnd; + d.requestStart += p.requestStart; + d.responseStart += p.responseStart; + d.responseEnd += p.responseEnd; + d.domLoading += p.domLoading; + d.domInteractive += p.domInteractive; + d.domContentLoadedEventStart += p.domContentLoadedEventStart; + d.domContentLoadedEventEnd += p.domContentLoadedEventEnd; + d.domComplete += p.domComplete; + d.loadEventStart += p.loadEventStart; + d.loadEventEnd += p.loadEventEnd; + } + + public void process(EndUserErrorData p) { + if (conf.enable_summary == false) + return; + long key = BitUtil.composite(p.stacktrace, p.userAgent); + EndUserErrorData d = errorTable.get(key); + if (d == null) { + errorTable.put(key, p); + return; + } + d.count += p.count; + } + + public void process(EndUserAjaxData p) { + if (conf.enable_summary == false) + return; + long key = BitUtil.composite(p.uri, p.ip); + EndUserAjaxData d = ajaxTable.get(key); + if (d == null) { + ajaxTable.put(key, p); + return; + } + d.count += p.count; + d.duration += p.duration; + } + + private LongKeyLinkedMap navTable = new LongKeyLinkedMap() + .setMax(conf.summary_enduser_nav_max); + private LongKeyLinkedMap ajaxTable = new LongKeyLinkedMap() + .setMax(conf.summary_enduser_ajax_max); + private LongKeyLinkedMap errorTable = new LongKeyLinkedMap() + .setMax(conf.summary_enduser_error_max); + + public SummaryPack getAndClearNavTable() { + + if (navTable.size() == 0) + return null; + + LongKeyLinkedMap temp = navTable; + navTable = new LongKeyLinkedMap().setMax(conf.summary_enduser_nav_max); + + SummaryPack p = new SummaryPack(); + p.stype = SummaryEnum.ENDUSER_NAVIGATION_TIME; + + int cnt = temp.size(); + ListValue id = p.table.newList("id"); + ListValue count = p.table.newList("count"); + ListValue uri = p.table.newList("uri"); + ListValue ip = p.table.newList("ip"); + + ListValue unloadEventStart = p.table.newList("unloadEventStart"); + ListValue unloadEventEnd = p.table.newList("unloadEventEnd"); + ListValue fetchStart = p.table.newList("fetchStart"); + ListValue domainLookupStart = p.table.newList("domainLookupStart"); + ListValue domainLookupEnd = p.table.newList("domainLookupEnd"); + ListValue connectStart = p.table.newList("connectStart"); + ListValue connectEnd = p.table.newList("connectEnd"); + ListValue requestStart = p.table.newList("requestStart"); + ListValue responseStart = p.table.newList("responseStart"); + ListValue responseEnd = p.table.newList("responseEnd"); + ListValue domLoading = p.table.newList("domLoading"); + ListValue domInteractive = p.table.newList("domInteractive"); + ListValue domContentLoadedEventStart = p.table.newList("domContentLoadedEventStart"); + ListValue domContentLoadedEventEnd = p.table.newList("domContentLoadedEventEnd"); + + ListValue domComplete = p.table.newList("domComplete"); + ListValue loadEventStart = p.table.newList("loadEventStart"); + ListValue loadEventEnd = p.table.newList("loadEventEnd"); + + Enumeration en = temp.entries(); + for (int i = 0; i < cnt; i++) { + LongKeyLinkedMap.ENTRY ent = en.nextElement(); + long key = ent.getKey(); + EndUserNavigationData data = ent.getValue(); + id.add(key); + count.add(data.count); + uri.add(data.uri); + ip.add(data.ip); + + unloadEventStart.add(data.unloadEventStart); + unloadEventEnd.add(data.unloadEventEnd); + fetchStart.add(data.fetchStart); + domainLookupStart.add(data.domainLookupStart); + domainLookupEnd.add(data.domainLookupEnd); + connectStart.add(data.connectStart); + connectEnd.add(data.connectEnd); + requestStart.add(data.requestStart); + responseStart.add(data.responseStart); + responseEnd.add(data.responseEnd); + domLoading.add(data.domLoading); + domInteractive.add(data.domInteractive); + domContentLoadedEventStart.add(data.domContentLoadedEventStart); + domContentLoadedEventEnd.add(data.domContentLoadedEventEnd); + domComplete.add(data.domComplete); + loadEventStart.add(data.loadEventStart); + loadEventEnd.add(data.loadEventEnd); + } + return p; + } + + public SummaryPack getAndClearAjaxTable() { + + if (navTable.size() == 0) + return null; + + LongKeyLinkedMap temp = ajaxTable; + ajaxTable = new LongKeyLinkedMap().setMax(conf.summary_enduser_ajax_max); + + SummaryPack p = new SummaryPack(); + p.stype = SummaryEnum.ENDUSER_AJAX_TIME; + + int cnt = temp.size(); + ListValue id = p.table.newList("id"); + ListValue count = p.table.newList("count"); + ListValue uri = p.table.newList("uri"); + ListValue ip = p.table.newList("ip"); + + ListValue duration = p.table.newList("duration"); + ListValue userAgent = p.table.newList("userAgent"); + + Enumeration en = temp.entries(); + for (int i = 0; i < cnt; i++) { + LongKeyLinkedMap.ENTRY ent = en.nextElement(); + long key = ent.getKey(); + EndUserAjaxData data = ent.getValue(); + id.add(key); + count.add(data.count); + uri.add(data.uri); + ip.add(data.ip); + + duration.add(data.duration); + userAgent.add(data.userAgent); + + } + return p; + } + public SummaryPack getAndClearErrorTable() { + + if (navTable.size() == 0) + return null; + + LongKeyLinkedMap temp = errorTable; + errorTable = new LongKeyLinkedMap().setMax(conf.summary_enduser_error_max); + + SummaryPack p = new SummaryPack(); + p.stype = SummaryEnum.ENDUSER_SCRIPT_ERROR; + + int cnt = temp.size(); + ListValue id = p.table.newList("id"); + ListValue count = p.table.newList("count"); + ListValue stacktrace = p.table.newList("stacktrace"); + ListValue userAgent = p.table.newList("userAgent"); + + ListValue uri = p.table.newList("uri"); + ListValue message = p.table.newList("message"); + ListValue file = p.table.newList("file"); + ListValue lineNumber = p.table.newList("lineNumber"); + ListValue columnNumber = p.table.newList("columnNumber"); + ListValue payloadVersion = p.table.newList("payloadVersion"); + + Enumeration en = temp.entries(); + for (int i = 0; i < cnt; i++) { + LongKeyLinkedMap.ENTRY ent = en.nextElement(); + long key = ent.getKey(); + EndUserErrorData data = ent.getValue(); + id.add(key); + count.add(data.count); + stacktrace.add(data.stacktrace); + userAgent.add(data.userAgent); + + uri.add(data.uri); + message.add(data.message); + file.add(data.file); + lineNumber.add(data.lineNumber); + columnNumber.add(data.columnNumber); + payloadVersion.add(data.payloadVersion); + + } + return p; + } + +} \ No newline at end of file diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceContext.java b/scouter.agent.java/src/scouter/agent/trace/TraceContext.java index 8c53581c4..484a55fd5 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceContext.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceContext.java @@ -57,7 +57,7 @@ public TraceContext(boolean profile_summary) { public String remoteIp; public int error; - public boolean done_http_service; + //public boolean done_http_service; public String http_method; public String http_query; public String http_content_type; @@ -119,9 +119,7 @@ public TraceContext createChild() { child.serviceHash = this.serviceHash; child.serviceName = this.serviceName; child.remoteIp = this.remoteIp; - // child.error = this.error; - child.done_http_service = this.done_http_service; - + child.http_method = this.http_method; child.http_query = this.http_query; child.http_content_type = this.http_content_type; diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java index 6d658ee48..7602724c7 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java @@ -64,10 +64,6 @@ public static Object startHttpService(Object req, Object res) { try { TraceContext ctx = TraceContextManager.getLocalContext(); if (ctx != null) { - if (ctx.done_http_service == false) { - ctx.done_http_service = true; - addSeviceName(ctx, req); - } return null; } return startHttp(req, res); @@ -121,6 +117,7 @@ public static Object reject(Object stat, Object req, Object res) { private static void addSeviceName(TraceContext ctx, Object req) { try { Configure conf = Configure.getInstance(); + StringBuilder sb = new StringBuilder(); if (conf.service_post_key != null) { String v = http.getParameter(req, conf.service_post_key); @@ -151,6 +148,11 @@ private static void addSeviceName(TraceContext ctx, Object req) { } } } + if (conf.service_header_key != null) { + String v = http.getHeader(req, conf.service_header_key); + ctx.serviceName = new StringBuilder(ctx.serviceName.length() + v.length() + 5).append(ctx.serviceName) + .append('-').append(v).toString(); + } if (sb.length() > 0) { ctx.serviceName = sb.toString(); } @@ -221,6 +223,13 @@ public static void endHttpService(Object stat, Throwable thr) { return; } TraceContext ctx = stat0.ctx; + + if(conf.enduser_perf_endpoint_hash == ctx.serviceHash){ + TraceContextManager.end(ctx.threadId); + return; + } + //additional service name + addSeviceName(ctx, stat0.req); // HTTP END http.end(ctx, stat0.req, stat0.res); // static-contents -> stop processing diff --git a/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java b/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java index 8fdff9646..bc26a7adb 100644 --- a/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java +++ b/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java @@ -29,6 +29,9 @@ import scouter.agent.counter.meter.MeterUsers; import scouter.agent.netio.data.DataProxy; import scouter.agent.proxy.IHttpTrace; +import scouter.agent.summary.EndUserAjaxData; +import scouter.agent.summary.EndUserErrorData; +import scouter.agent.summary.EndUserNavigationData; import scouter.agent.trace.IProfileCollector; import scouter.agent.trace.TraceContext; import scouter.agent.trace.TraceMain; @@ -75,16 +78,20 @@ public void start(TraceContext ctx, Object req, Object res) { Configure conf = Configure.getInstance(); HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; - + ctx.serviceName = getRequestURI(request); - ctx.isStaticContents = TraceMain.isStaticContents(ctx.serviceName); + ctx.serviceHash = HashUtil.hash(ctx.serviceName); - if (conf.service_header_key != null) { - String v = request.getHeader(conf.service_header_key); - ctx.serviceName = new StringBuilder(ctx.serviceName.length() + v.length() + 5).append(ctx.serviceName) - .append('-').append(v).toString(); + // + if(ctx.serviceHash == conf.enduser_perf_endpoint_hash){ + ctx.isStaticContents=true; + enduser(request); + return; } - ctx.serviceHash = HashUtil.hash(ctx.serviceName); + + ctx.isStaticContents = TraceMain.isStaticContents(ctx.serviceName); + + ctx.http_method = request.getMethod(); ctx.http_query = request.getQueryString(); ctx.http_content_type = request.getContentType(); @@ -146,18 +153,17 @@ public void start(TraceContext ctx, Object req, Object res) { try { if (ctx.gxid == 0) ctx.gxid = ctx.txid; - + String resGxId = Hexa32.toString32(ctx.gxid) + ":" + ctx.startTime; response.setHeader(conf.gxid, resGxId); - + Cookie c = new Cookie(conf.gxid, resGxId); response.addCookie(c); - + } catch (Throwable t) { } } - - + if (conf.enable_trace_web) { try { ctx.web_name = request.getHeader(conf.key_web_name); @@ -178,6 +184,16 @@ public void start(TraceContext ctx, Object req, Object res) { } } + private void enduser(HttpServletRequest request) { + EndUserNavigationData nav; + EndUserErrorData err; + EndUserAjaxData ajax; + + + //EndUserSummary.getInstance().process(p); + + } + private String getRequestURI(HttpServletRequest request) { String uri = request.getRequestURI(); if (uri == null) @@ -283,6 +299,7 @@ public void rejectUrl(Object res, String url) { } } + public static void main(String[] args) { System.out.println("http trace".indexOf(null)); } diff --git a/scouter.common/src/scouter/lang/SummaryEnum.java b/scouter.common/src/scouter/lang/SummaryEnum.java index d2e1efd10..4aed7ce7e 100644 --- a/scouter.common/src/scouter/lang/SummaryEnum.java +++ b/scouter.common/src/scouter/lang/SummaryEnum.java @@ -25,4 +25,9 @@ public class SummaryEnum { final public static byte APICALL = 5; public static final byte USER_AGENT = 8; public static final byte SERVICE_ERROR = 9; + + public static final byte ENDUSER_NAVIGATION_TIME = 10; + public static final byte ENDUSER_AJAX_TIME = 11; + public static final byte ENDUSER_SCRIPT_ERROR = 12; + } \ No newline at end of file diff --git a/scouter.common/src/scouter/net/RequestCmd.java b/scouter.common/src/scouter/net/RequestCmd.java index e9810d5db..001b61a9a 100644 --- a/scouter.common/src/scouter/net/RequestCmd.java +++ b/scouter.common/src/scouter/net/RequestCmd.java @@ -248,5 +248,9 @@ public class RequestCmd { public static final String LOAD_UA_SUMMARY = "LOAD_UA_SUMMARY"; public static final String LOAD_SERVICE_ERROR_SUMMARY = "LOAD_SERVICE_ERROR_SUMMARY"; public static final String LOAD_ALERT_SUMMARY = "LOAD_ALERT_SUMMARY"; - + + public static final String LOAD_ENDUSER_NAV_SUMMARY = "LOAD_ENDUSER_NAV_SUMMARY"; + public static final String LOAD_ENDUSER_AJAX_SUMMARY = "LOAD_ENDUSER_AJAX_SUMMARY"; + public static final String LOAD_ENDUSER_ERROR_SUMMARY = "LOAD_ENDUSER_ERROR_SUMMARY"; + } \ No newline at end of file diff --git a/scouter.server/src/scouter/server/db/SummaryRD.scala b/scouter.server/src/scouter/server/db/SummaryRD.scala index 1a8f497fc..e9853a8b1 100644 --- a/scouter.server/src/scouter/server/db/SummaryRD.scala +++ b/scouter.server/src/scouter/server/db/SummaryRD.scala @@ -27,64 +27,70 @@ import scouter.lang.SummaryEnum object SummaryRD { - def readByTime(stype: Byte, date: String, fromTime: Long, toTime: Long, handler: (Long, Array[Byte]) => Any) { + def readByTime(stype: Byte, date: String, fromTime: Long, toTime: Long, handler: (Long, Array[Byte]) => Any) { - val path = SummaryWR.getDBPath(date); - if (new File(path).canRead()) { - val file = path + "/" + SummaryWR.root; - var reader: SummaryReader = null; - var table: SummaryIndex = null; - try { - reader = SummaryReader.open(file) - stype match { - case SummaryEnum.APP => table = SummaryIndex.open(file + "_app") - case SummaryEnum.SQL => table = SummaryIndex.open(file + "_sql") - case _ => table = SummaryIndex.open(file + "_other") - } - table.read(fromTime, toTime, handler, reader.read) - } catch { - case e: Throwable => e.printStackTrace(); - } finally { - FileUtil.close(table); - FileUtil.close(reader); - } + val path = SummaryWR.getDBPath(date); + if (new File(path).canRead()) { + val file = path + "/" + SummaryWR.root; + var reader: SummaryReader = null; + var table: SummaryIndex = null; + try { + reader = SummaryReader.open(file) + stype match { + case SummaryEnum.APP => table = SummaryIndex.open(file + "_app") + case SummaryEnum.SQL => table = SummaryIndex.open(file + "_sql") + case SummaryEnum.ENDUSER_NAVIGATION_TIME | + SummaryEnum.ENDUSER_AJAX_TIME | + SummaryEnum.ENDUSER_SCRIPT_ERROR => table = SummaryIndex.open(file + "_enduser") + case _ => table = SummaryIndex.open(file + "_other") } + table.read(fromTime, toTime, handler, reader.read) + } catch { + case e: Throwable => e.printStackTrace(); + } finally { + FileUtil.close(table); + FileUtil.close(reader); + } } + } - def readByTime(stype: Byte, date: String, handler: (Long, Array[Byte]) => Any) { - val stime = DateUtil.yyyymmdd(date); - val etime = stime + DateUtil.MILLIS_PER_DAY; - readByTime(stype, date, stime, etime, handler); - } + def readByTime(stype: Byte, date: String, handler: (Long, Array[Byte]) => Any) { + val stime = DateUtil.yyyymmdd(date); + val etime = stime + DateUtil.MILLIS_PER_DAY; + readByTime(stype, date, stime, etime, handler); + } - def readFromEndTime(stype: Byte, date: String, handler: (Long, Array[Byte]) => Any) { - val stime = DateUtil.yyyymmdd(date) - val etime = stime + DateUtil.MILLIS_PER_DAY - readFromEndTime(stype, date, stime, etime, handler) - } + def readFromEndTime(stype: Byte, date: String, handler: (Long, Array[Byte]) => Any) { + val stime = DateUtil.yyyymmdd(date) + val etime = stime + DateUtil.MILLIS_PER_DAY + readFromEndTime(stype, date, stime, etime, handler) + } - def readFromEndTime(stype: Byte, date: String, fromTime: Long, toTime: Long, handler: (Long, Array[Byte]) => Any) { + def readFromEndTime(stype: Byte, date: String, fromTime: Long, toTime: Long, handler: (Long, Array[Byte]) => Any) { - val path = SummaryWR.getDBPath(date); - if (new File(path).canRead()) { - val file = path + "/" + SummaryWR.root; - var reader: SummaryReader = null; - var table: SummaryIndex = null; - try { - reader = SummaryReader.open(file); - stype match { - case SummaryEnum.APP => table = SummaryIndex.open(file + "_app") - case SummaryEnum.SQL => table = SummaryIndex.open(file + "_sql") - case _ => table = SummaryIndex.open(file + "_other") - } - table.readFromEnd(fromTime, toTime, handler, reader.read) - } catch { - case e: Throwable => e.printStackTrace(); - } finally { - FileUtil.close(table); - FileUtil.close(reader); - } + val path = SummaryWR.getDBPath(date); + if (new File(path).canRead()) { + val file = path + "/" + SummaryWR.root; + var reader: SummaryReader = null; + var table: SummaryIndex = null; + try { + reader = SummaryReader.open(file); + stype match { + case SummaryEnum.APP => table = SummaryIndex.open(file + "_app") + case SummaryEnum.SQL => table = SummaryIndex.open(file + "_sql") + case SummaryEnum.ENDUSER_NAVIGATION_TIME | + SummaryEnum.ENDUSER_AJAX_TIME | + SummaryEnum.ENDUSER_SCRIPT_ERROR => table = SummaryIndex.open(file + "_enduser") + case _ => table = SummaryIndex.open(file + "_other") } + table.readFromEnd(fromTime, toTime, handler, reader.read) + } catch { + case e: Throwable => e.printStackTrace(); + } finally { + FileUtil.close(table); + FileUtil.close(reader); + } } + } } \ No newline at end of file diff --git a/scouter.server/src/scouter/server/db/SummaryWR.scala b/scouter.server/src/scouter/server/db/SummaryWR.scala index c3611a4af..116bc56da 100644 --- a/scouter.server/src/scouter/server/db/SummaryWR.scala +++ b/scouter.server/src/scouter/server/db/SummaryWR.scala @@ -31,82 +31,88 @@ import scouter.server.util.OftenAction import scouter.lang.SummaryEnum import scouter.server.core.ServerStat object SummaryWR { - val root = "sum"; - val queue = new RequestQueue[SummaryPack](DBCtr.MAX_QUE_SIZE); - ThreadScala.start("scouter.server.db.SummaryWR") { - var currentDateUnit = 0L - while (DBCtr.running) { - val p = queue.get(); - ServerStat.put("summary.db.queue",queue.size()); - try { - if (currentDateUnit != DateUtil.getDateUnit(p.time)) { - currentDateUnit = DateUtil.getDateUnit(p.time); - close(); - open(DateUtil.yyyymmdd(p.time)); - } - if (iapp == null) { - OftenAction.act("SummaryWR", 10) { - queue.clear(); - currentDateUnit = 0; - } - Logger.println("S210", 10, "can't open db"); - } else { - val b = new DataOutputX().writePack(p).toByteArray() - val location = writer.write(b); - p.stype match { - case SummaryEnum.APP => iapp.add(p.time, location); - case SummaryEnum.SQL => isql.add(p.time, location); - case _ => iothers.add(p.time, location); - } - } - } catch { - case t: Throwable => t.printStackTrace(); - } + val root = "sum"; + val queue = new RequestQueue[SummaryPack](DBCtr.MAX_QUE_SIZE); + ThreadScala.start("scouter.server.db.SummaryWR") { + var currentDateUnit = 0L + while (DBCtr.running) { + val p = queue.get(); + ServerStat.put("summary.db.queue", queue.size()); + try { + if (currentDateUnit != DateUtil.getDateUnit(p.time)) { + currentDateUnit = DateUtil.getDateUnit(p.time); + close(); + open(DateUtil.yyyymmdd(p.time)); } - close() - } - def add(p: SummaryPack) { - val ok = queue.put(p); - if (ok == false) { - Logger.println("S211", 10, "queue exceeded!!"); + if (iapp == null) { + OftenAction.act("SummaryWR", 10) { + queue.clear(); + currentDateUnit = 0; + } + Logger.println("S210", 10, "can't open db"); + } else { + val b = new DataOutputX().writePack(p).toByteArray() + val location = writer.write(b); + p.stype match { + case SummaryEnum.APP => iapp.add(p.time, location); + case SummaryEnum.SQL => isql.add(p.time, location); + case SummaryEnum.ENDUSER_NAVIGATION_TIME | + SummaryEnum.ENDUSER_AJAX_TIME | + SummaryEnum.ENDUSER_SCRIPT_ERROR => ienduser.add(p.time, location); + case _ => iothers.add(p.time, location); + } } + } catch { + case t: Throwable => t.printStackTrace(); + } } - var iapp: SummaryIndex = null - var isql: SummaryIndex = null - var iothers: SummaryIndex = null - var writer: SummaryWriter = null - def close() { - FileUtil.close(iapp); - FileUtil.close(isql); - FileUtil.close(iothers); - FileUtil.close(writer); - iapp = null; - isql = null; - iothers = null; - writer = null; - } - def open(date: String) { - try { - val path = getDBPath(date); - val f = new File(path); - if (f.exists() == false) - f.mkdirs(); - val file = path + "/" + root; - iapp = SummaryIndex.open(file + "_app"); - isql = SummaryIndex.open(file + "_sql"); - iothers = SummaryIndex.open(file + "_other"); - writer = SummaryWriter.open(file); - } catch { - case e: Throwable => { - e.printStackTrace(); - close(); - } - } + close() + } + def add(p: SummaryPack) { + val ok = queue.put(p); + if (ok == false) { + Logger.println("S211", 10, "queue exceeded!!"); } - def getDBPath(date: String): String = { - val sb = new StringBuffer(); - sb.append(DBCtr.getRootPath()); - sb.append("/").append(date).append("/").append(root); - return sb.toString(); + } + var iapp: SummaryIndex = null + var isql: SummaryIndex = null + var ienduser: SummaryIndex = null + var iothers: SummaryIndex = null + var writer: SummaryWriter = null + def close() { + FileUtil.close(iapp); + FileUtil.close(isql); + FileUtil.close(ienduser); + FileUtil.close(iothers); + FileUtil.close(writer); + iapp = null; + isql = null; + iothers = null; + writer = null; + } + def open(date: String) { + try { + val path = getDBPath(date); + val f = new File(path); + if (f.exists() == false) + f.mkdirs(); + val file = path + "/" + root; + iapp = SummaryIndex.open(file + "_app"); + isql = SummaryIndex.open(file + "_sql"); + ienduser = SummaryIndex.open(file + "_enduser"); + iothers = SummaryIndex.open(file + "_other"); + writer = SummaryWriter.open(file); + } catch { + case e: Throwable => { + e.printStackTrace(); + close(); + } } + } + def getDBPath(date: String): String = { + val sb = new StringBuffer(); + sb.append(DBCtr.getRootPath()); + sb.append("/").append(date).append("/").append(root); + return sb.toString(); + } } diff --git a/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserAjax.scala b/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserAjax.scala new file mode 100644 index 000000000..9a9fce3c3 --- /dev/null +++ b/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserAjax.scala @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.server.netio.service.handle; + +import scouter.io.DataInputX +import scouter.io.DataOutputX +import scouter.lang.SummaryEnum +import scouter.lang.pack.MapPack +import scouter.lang.pack.SummaryPack +import scouter.lang.value.ListValue +import scouter.net.TcpFlag +import scouter.server.db.SummaryRD +import scouter.server.netio.service.anotation.ServiceHandler +import scouter.util.LongKeyLinkedMap +import scouter.net.RequestCmd + +class SummaryEndUserAjax { + + class Temp1() { + + var id: Long = 0L; + var uri: Int = 0; + var ip: Int = 0; + var count: Int = 0; + + var duration: Long = 0L; + var userAgent: Int = 0; + } + + @ServiceHandler(RequestCmd.LOAD_ENDUSER_AJAX_SUMMARY) + def LOAD_ENDUSER_AJAX_SUMMARY(din: DataInputX, dout: DataOutputX, login: Boolean): Unit = { + val param = din.readMapPack(); + val date = param.getText("date"); + val stime = param.getLong("stime"); + val etime = param.getLong("etime"); + val objType = param.getText("objType"); + + val tempMap = new LongKeyLinkedMap[Temp1]().setMax(50000) + + val handler = (time: Long, data: Array[Byte]) => { + val p = new DataInputX(data).readPack().asInstanceOf[SummaryPack]; + if (p.stype == SummaryEnum.ENDUSER_AJAX_TIME && (objType == null || objType == p.objType)) { + val id = p.table.getList("id") + + var uri = p.table.getList("uri") + var ip = p.table.getList("ip") + var count = p.table.getList("count") + // + var duration = p.table.getList("duration") + var userAgent = p.table.getList("userAgent") + + + for (i <- 0 to id.size() - 1) { + var tempObj = tempMap.get(id.getInt(i)); + if (tempObj == null) { + tempObj = new Temp1(); + tempObj.id = id.getLong(i); + tempObj.uri = uri.getInt(i); + tempObj.ip = ip.getInt(i); + tempObj.userAgent = userAgent.getInt(i); + + tempMap.put(tempObj.id , tempObj); + } + tempObj.count += count.getInt(i); + tempObj.duration += duration.getLong(i) + + } + } + } + + SummaryRD.readByTime(SummaryEnum.ENDUSER_AJAX_TIME, date, stime, etime, handler) + + val map = new MapPack(); + var id = map.newList("id") + var uri = map.newList("uri") + var ip = map.newList("ip") + var count = map.newList("count") + // + var duration = map.newList("duration") + var userAgent = map.newList("userAgent") + + val itr = tempMap.keys(); + while (itr.hasMoreElements()) { + val key = itr.nextLong(); + val obj = tempMap.get(key); + + id.add(obj.id) + uri.add(obj.uri) + ip.add(obj.ip) + count.add(obj.count) + + duration.add(obj.duration) + userAgent.add(obj.userAgent) + } + + dout.writeByte(TcpFlag.HasNEXT); + dout.writePack(map); + } + +} \ No newline at end of file diff --git a/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserError.scala b/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserError.scala new file mode 100644 index 000000000..ca0afa993 --- /dev/null +++ b/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserError.scala @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.server.netio.service.handle; + +import scouter.io.DataInputX +import scouter.io.DataOutputX +import scouter.lang.SummaryEnum +import scouter.lang.pack.MapPack +import scouter.lang.pack.SummaryPack +import scouter.lang.value.ListValue +import scouter.net.TcpFlag +import scouter.server.db.SummaryRD +import scouter.server.netio.service.anotation.ServiceHandler +import scouter.util.LongKeyLinkedMap +import scouter.net.RequestCmd + +class SummaryEndUserError { + + class Temp1() { + + var id: Long = 0L; + var stacktrace: Int = 0 + var userAgent: Int = 0 + var count: Int = 0 + var uri: Int = 0 + var message: Int = 0 + var file: Int = 0 + var lineNumber: Int = 0 + var columnNumber: Int = 0 + var payloadVersion: Int = 0 + } + + @ServiceHandler(RequestCmd.LOAD_ENDUSER_ERROR_SUMMARY) + def LOAD_ENDUSER_ERROR_SUMMARY(din: DataInputX, dout: DataOutputX, login: Boolean): Unit = { + val param = din.readMapPack(); + val date = param.getText("date"); + val stime = param.getLong("stime"); + val etime = param.getLong("etime"); + val objType = param.getText("objType"); + + val tempMap = new LongKeyLinkedMap[Temp1]().setMax(50000) + + val handler = (time: Long, data: Array[Byte]) => { + val p = new DataInputX(data).readPack().asInstanceOf[SummaryPack]; + if (p.stype == SummaryEnum.ENDUSER_SCRIPT_ERROR && (objType == null || objType == p.objType)) { + val id = p.table.getList("id") + + var stacktrace = p.table.getList("stacktrace") + var userAgent = p.table.getList("userAgent") + var count = p.table.getList("count") + // + var uri = p.table.getList("uri") + var message = p.table.getList("message") + var file = p.table.getList("file") + var lineNumber = p.table.getList("lineNumber") + var columnNumber = p.table.getList("columnNumber") + var payloadVersion = p.table.getList("payloadVersion") + + for (i <- 0 to id.size() - 1) { + var tempObj = tempMap.get(id.getInt(i)); + if (tempObj == null) { + tempObj = new Temp1(); + tempObj.id = id.getLong(i); + tempObj.stacktrace = stacktrace.getInt(i); + tempObj.userAgent = userAgent.getInt(i); + tempObj.uri = uri.getInt(i) + tempObj.message = message.getInt(i) + tempObj.file = file.getInt(i) + tempObj.lineNumber = lineNumber.getInt(i) + tempObj.columnNumber = columnNumber.getInt(i) + tempObj.payloadVersion = payloadVersion.getInt(i) + + tempMap.put(tempObj.id, tempObj); + } + tempObj.count += count.getInt(i); + } + } + } + + SummaryRD.readByTime(SummaryEnum.ENDUSER_SCRIPT_ERROR, date, stime, etime, handler) + + val map = new MapPack(); + var id = map.newList("id") + var stacktrace = map.newList("stacktrace"); + var userAgent = map.newList("userAgent"); + var uri = map.newList("uri"); + var message = map.newList("message"); + var file = map.newList("file"); + var lineNumber = map.newList("lineNumber"); + var columnNumber = map.newList("columnNumber"); + var payloadVersion = map.newList("payloadVersion"); + + val itr = tempMap.keys(); + while (itr.hasMoreElements()) { + val key = itr.nextLong(); + val obj = tempMap.get(key); + + id.add(obj.id) + stacktrace.add(obj.stacktrace) + userAgent.add(obj.userAgent) + uri.add(obj.uri) + message.add(obj.message) + file.add(obj.file) + lineNumber.add(obj.lineNumber) + columnNumber.add(obj.columnNumber) + payloadVersion.add(obj.payloadVersion) + } + + dout.writeByte(TcpFlag.HasNEXT); + dout.writePack(map); + } + +} \ No newline at end of file diff --git a/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserNav.scala b/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserNav.scala new file mode 100644 index 000000000..75e1c91d8 --- /dev/null +++ b/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserNav.scala @@ -0,0 +1,194 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.server.netio.service.handle; + +import scouter.io.DataInputX +import scouter.io.DataOutputX +import scouter.lang.SummaryEnum +import scouter.lang.pack.MapPack +import scouter.lang.pack.SummaryPack +import scouter.lang.value.ListValue +import scouter.net.TcpFlag +import scouter.server.db.SummaryRD +import scouter.server.netio.service.anotation.ServiceHandler +import scouter.util.LongKeyLinkedMap +import scouter.net.RequestCmd + +class SummaryEndUserNav { + + class Temp1() { + + var id: Long = 0L; + var uri: Int = 0; + var ip: Int = 0; + var count: Int = 0; + // + var navigationStart: Long = 0L; + var unloadEventStart: Long = 0L; + var unloadEventEnd: Long = 0L; + var fetchStart: Long = 0L; + var domainLookupStart: Long = 0L; + var domainLookupEnd: Long = 0L; + var connectStart: Long = 0L; + var connectEnd: Long = 0L; + var requestStart: Long = 0L; + var responseStart: Long = 0L; + var responseEnd: Long = 0L; + var domLoading: Long = 0L; + var domInteractive: Long = 0L; + var domContentLoadedEventStart: Long = 0L; + var domContentLoadedEventEnd: Long = 0L; + var domComplete: Long = 0L; + var loadEventStart: Long = 0L; + var loadEventEnd: Long = 0L; + + } + + @ServiceHandler(RequestCmd.LOAD_ENDUSER_NAV_SUMMARY) + def LOAD_ENDUSER_NAV_SUMMARY(din: DataInputX, dout: DataOutputX, login: Boolean): Unit = { + val param = din.readMapPack(); + val date = param.getText("date"); + val stime = param.getLong("stime"); + val etime = param.getLong("etime"); + val objType = param.getText("objType"); + + val tempMap = new LongKeyLinkedMap[Temp1]().setMax(50000) + + val handler = (time: Long, data: Array[Byte]) => { + val p = new DataInputX(data).readPack().asInstanceOf[SummaryPack]; + if (p.stype == SummaryEnum.ENDUSER_NAVIGATION_TIME && (objType == null || objType == p.objType)) { + val id = p.table.getList("id") + + var uri = p.table.getList("uri") + var ip = p.table.getList("ip") + var count = p.table.getList("count") + // + var navigationStart = p.table.getList("navigationStart") + var unloadEventStart = p.table.getList("unloadEventStart") + var unloadEventEnd = p.table.getList("unloadEventEnd") + var fetchStart = p.table.getList("fetchStart") + var domainLookupStart = p.table.getList("domainLookupStart") + var domainLookupEnd = p.table.getList("domainLookupEnd") + var connectStart = p.table.getList("connectStart") + var connectEnd = p.table.getList("connectEnd") + var requestStart = p.table.getList("requestStart") + var responseStart = p.table.getList("responseStart") + var responseEnd = p.table.getList("responseEnd") + var domLoading = p.table.getList("domLoading") + var domInteractive = p.table.getList("domInteractive") + var domContentLoadedEventStart = p.table.getList("domContentLoadedEventStart") + var domContentLoadedEventEnd = p.table.getList("domContentLoadedEventEnd") + var domComplete = p.table.getList("domComplete") + var loadEventStart = p.table.getList("loadEventStart") + var loadEventEnd = p.table.getList("loadEventEnd") + + for (i <- 0 to id.size() - 1) { + var tempObj = tempMap.get(id.getInt(i)); + if (tempObj == null) { + tempObj = new Temp1(); + tempObj.id = id.getLong(i); + tempObj.uri = uri.getInt(i); + tempObj.ip = ip.getInt(i); + tempMap.put(id.getLong(i), tempObj); + } + tempObj.count += count.getInt(i); + tempObj.navigationStart += navigationStart.getLong(i) + tempObj.unloadEventStart += unloadEventStart.getLong(i) + tempObj.unloadEventEnd += unloadEventEnd.getLong(i) + tempObj.fetchStart += fetchStart.getLong(i) + tempObj.domainLookupStart += domainLookupStart.getLong(i) + tempObj.domainLookupEnd += domainLookupEnd.getLong(i) + tempObj.connectStart += connectStart.getLong(i) + tempObj.connectEnd += connectEnd.getLong(i) + tempObj.requestStart += requestStart.getLong(i) + tempObj.responseStart += responseStart.getLong(i) + tempObj.responseEnd += responseEnd.getLong(i) + tempObj.domLoading += domLoading.getLong(i) + tempObj.domInteractive += domInteractive.getLong(i) + tempObj.domContentLoadedEventStart += domContentLoadedEventStart.getLong(i) + tempObj.domContentLoadedEventEnd += domContentLoadedEventEnd.getLong(i) + tempObj.domComplete += domComplete.getLong(i) + tempObj.loadEventStart += loadEventStart.getLong(i) + tempObj.loadEventEnd += loadEventEnd.getLong(i) + + } + } + } + + SummaryRD.readByTime(SummaryEnum.ENDUSER_NAVIGATION_TIME, date, stime, etime, handler) + + val map = new MapPack(); + var id = map.newList("id") + var uri = map.newList("uri") + var ip = map.newList("ip") + var count = map.newList("count") + // + var navigationStart = map.newList("navigationStart") + var unloadEventStart = map.newList("unloadEventStart") + var unloadEventEnd = map.newList("unloadEventEnd") + var fetchStart = map.newList("fetchStart") + var domainLookupStart = map.newList("domainLookupStart") + var domainLookupEnd = map.newList("domainLookupEnd") + var connectStart = map.newList("connectStart") + var connectEnd = map.newList("connectEnd") + var requestStart = map.newList("requestStart") + var responseStart = map.newList("responseStart") + var responseEnd = map.newList("responseEnd") + var domLoading = map.newList("domLoading") + var domInteractive = map.newList("domInteractive") + var domContentLoadedEventStart = map.newList("domContentLoadedEventStart") + var domContentLoadedEventEnd = map.newList("domContentLoadedEventEnd") + var domComplete = map.newList("domComplete") + var loadEventStart = map.newList("loadEventStart") + var loadEventEnd = map.newList("loadEventEnd") + + val itr = tempMap.keys(); + while (itr.hasMoreElements()) { + val key = itr.nextLong(); + val obj = tempMap.get(key); + + id.add(obj.id) + uri.add(obj.uri) + ip.add(obj.ip) + count.add(obj.count) + + navigationStart.add(obj.navigationStart) + unloadEventStart.add(obj.unloadEventStart) + unloadEventEnd.add(obj.unloadEventEnd) + fetchStart.add(obj.fetchStart) + domainLookupStart.add(obj.domainLookupStart) + domainLookupEnd.add(obj.domainLookupEnd) + connectStart.add(obj.connectStart) + connectEnd.add(obj.connectEnd) + requestStart.add(obj.requestStart) + responseStart.add(obj.responseStart) + responseEnd.add(obj.responseEnd) + domLoading.add(obj.domLoading) + domInteractive.add(obj.domInteractive) + domContentLoadedEventStart.add(obj.domContentLoadedEventStart) + domContentLoadedEventEnd.add(obj.domContentLoadedEventEnd) + domComplete.add(obj.domComplete) + loadEventStart.add(obj.loadEventStart) + loadEventEnd.add(obj.loadEventEnd) + + } + + dout.writeByte(TcpFlag.HasNEXT); + dout.writePack(map); + } + +} \ No newline at end of file From 80ac14cdaa97bf5a36278b65398bf499c8d5b90b Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Thu, 3 Dec 2015 09:09:38 +0900 Subject: [PATCH 15/42] refactoring --- scouter.client/src/scouter/client/net/LoginMgr.java | 4 ++-- scouter.client/src/scouter/client/server/Server.java | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scouter.client/src/scouter/client/net/LoginMgr.java b/scouter.client/src/scouter/client/net/LoginMgr.java index 1a4a85a38..756a5c621 100644 --- a/scouter.client/src/scouter/client/net/LoginMgr.java +++ b/scouter.client/src/scouter/client/net/LoginMgr.java @@ -56,7 +56,7 @@ public static boolean login(int serverId, String user, String password){ Server server = ServerManager.getInstance().getServer(serverId); server.setOpen(true); server.setSession(session); - server.setName(hostname + "_" + server.getPort()); + server.setName(hostname); server.setDelta(time); server.setUserId(user); server.setPassword(encrypted); @@ -118,7 +118,7 @@ public static boolean silentLogin(Server server, String user, String encryptedPw String timezone = out.getText("timezone"); server.setSession(session); - server.setName(hostname + "_" + server.getPort()); + server.setName(hostname); server.setDelta(time); server.setUserId(user); server.setPassword(encryptedPwd); diff --git a/scouter.client/src/scouter/client/server/Server.java b/scouter.client/src/scouter/client/server/Server.java index eb1a07259..389faedbe 100644 --- a/scouter.client/src/scouter/client/server/Server.java +++ b/scouter.client/src/scouter/client/server/Server.java @@ -217,6 +217,10 @@ public void setDirty(boolean dirty) { public boolean isDirty() { return this.dirty; } + + public long getCurrentTime() { + return System.currentTimeMillis() + getDelta(); + } public String toString() { return "Server [id=" + id + ", name=" + name + ", ip=" + ip + ", port=" From 245d45f16fd36daeac2fbd48bfd4fe35739f29b9 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Thu, 3 Dec 2015 14:21:56 +0900 Subject: [PATCH 16/42] missspell --- ...oServiceStartAnalizer.java => AutoServiceStartAnalyzer.java} | 2 +- scouter.agent.java/src/scouter/agent/trace/TraceMain.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename scouter.agent.java/src/scouter/agent/trace/{AutoServiceStartAnalizer.java => AutoServiceStartAnalyzer.java} (91%) diff --git a/scouter.agent.java/src/scouter/agent/trace/AutoServiceStartAnalizer.java b/scouter.agent.java/src/scouter/agent/trace/AutoServiceStartAnalyzer.java similarity index 91% rename from scouter.agent.java/src/scouter/agent/trace/AutoServiceStartAnalizer.java rename to scouter.agent.java/src/scouter/agent/trace/AutoServiceStartAnalyzer.java index f5d871b03..e03612978 100644 --- a/scouter.agent.java/src/scouter/agent/trace/AutoServiceStartAnalizer.java +++ b/scouter.agent.java/src/scouter/agent/trace/AutoServiceStartAnalyzer.java @@ -3,7 +3,7 @@ import scouter.util.StringEnumer; import scouter.util.StringKeyLinkedMap; -public class AutoServiceStartAnalizer { +public class AutoServiceStartAnalyzer { private static StringKeyLinkedMap table = new StringKeyLinkedMap().setMax(200); public static void put(String classMethod, String stack) { diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java index 7602724c7..443b7b949 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java @@ -567,7 +567,7 @@ public static Object startMethod(int hash, String classMethod) { Object stat = startService(classMethod, null, null, null, null, null, XLogTypes.APP_SERVICE); if (conf.enable_auto_service_backstack) { String stack = ThreadUtil.getStackTrace(Thread.currentThread().getStackTrace(), 2); - AutoServiceStartAnalizer.put(classMethod, stack); + AutoServiceStartAnalyzer.put(classMethod, stack); MessageStep m = new MessageStep(); m.message = "SERVICE BACKSTACK:\n" + stack; ((Stat) stat).ctx.profile.add(m); From 84dc38c26e8d29eefdf6cd6291088153a15dace8 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Thu, 3 Dec 2015 14:22:32 +0900 Subject: [PATCH 17/42] context menu in profile view --- .../client/xlog/views/XLogProfileView.java | 76 ++++++++++--------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java b/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java index f2c438621..f6a9dff25 100644 --- a/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java +++ b/scouter.client/src/scouter/client/xlog/views/XLogProfileView.java @@ -24,6 +24,8 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; @@ -32,6 +34,8 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; @@ -63,6 +67,7 @@ public class XLogProfileView extends ViewPart { private StyledText text; private XLogData xLogData; private String txid; + Menu contextMenu; IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); @@ -91,42 +96,35 @@ public void createPartControl(Composite parent) { text.addKeyListener(adapter); IToolBarManager man = getViewSite().getActionBars().getToolBarManager(); - - man.add( new Action("SQL Statistics", ImageUtil.getImageDescriptor(Images.sum)) { - public void run() { - XlogSummarySQLDialog summberSQLDialog = new XlogSummarySQLDialog(new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN), steps, xLogData); - summberSQLDialog.open(); - } - }); + man.add(openSqlSummaryDialog); - Action gridBackAct = new Action("Grid Background", IAction.AS_CHECK_BOX) { - public void run() { - if (isChecked()) { - text.setBackgroundImage(Activator.getImage("icons/grid.jpg")); - } else { - text.setBackgroundImage(null); - } - } - }; - gridBackAct.setImageDescriptor(ImageUtil.getImageDescriptor(Images.grid)); - gridBackAct.setChecked(true); - man.add(gridBackAct); - IMenuManager menuManager = getViewSite().getActionBars().getMenuManager(); - menuManager.add(new Action("Save Full Profile") { - public void run() { - makeFullProfileToFile(); + menuManager.add(saveFullProfile); + + createContextMenu(); + } + + private void createContextMenu() { + contextMenu = new Menu(text); + MenuItem sqlSummary = new MenuItem(contextMenu, SWT.PUSH); + sqlSummary.setText("SQL Statistics"); + sqlSummary.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + openSqlSummaryDialog.run(); } - }); + }); + MenuItem saveProfile = new MenuItem(contextMenu, SWT.PUSH); + saveProfile.setText("Save Full Profile"); + saveProfile.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + saveFullProfile.run(); + } + }); + text.setMenu(contextMenu); } public static boolean isSummary; - private void makeFullProfileToFile() { - SaveProfileJob job = new SaveProfileJob("Save Profile...", xLogData.p.endTime, xLogData, txid, serverId, isSummary); - job.schedule(); - } - boolean truncated; private int serverId; @@ -236,13 +234,17 @@ public void dispose() { super.dispose(); } - public static void main(String[] args) { - String fulltxt = "call: UCON:http://127.0.0.1:8080/e2end.jsp 117 ms "; - int startIndex = fulltxt.lastIndexOf("<"); - if (startIndex > -1) { - int endIndex = fulltxt.lastIndexOf(">"); - String txIdStr = fulltxt.substring(startIndex + 1, endIndex); - System.out.println(txIdStr); + Action openSqlSummaryDialog = new Action("SQL Statistics", ImageUtil.getImageDescriptor(Images.sum)) { + public void run() { + XlogSummarySQLDialog summberSQLDialog = new XlogSummarySQLDialog(new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN), steps, xLogData); + summberSQLDialog.open(); } - } + }; + + Action saveFullProfile = new Action("Save Full Profile") { + public void run() { + SaveProfileJob job = new SaveProfileJob("Save Profile...", xLogData.p.endTime, xLogData, txid, serverId, isSummary); + job.schedule(); + } + }; } From f961f5f7e474f03c73eb7b811feafba8de1b0a6a Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Thu, 3 Dec 2015 14:22:59 +0900 Subject: [PATCH 18/42] full profile view refactoring --- scouter.client/plugin.xml | 6 +++--- .../src/scouter/client/views/WorkspaceExplorer.java | 6 +++--- ...ogProfilePageView.java => XLogFullProfileView.java} | 10 +++++++--- .../scouter/client/xlog/views/XLogSelectionView.java | 4 ++++ 4 files changed, 17 insertions(+), 9 deletions(-) rename scouter.client/src/scouter/client/xlog/views/{XLogProfilePageView.java => XLogFullProfileView.java} (98%) diff --git a/scouter.client/plugin.xml b/scouter.client/plugin.xml index 26488d5ea..18181c22a 100644 --- a/scouter.client/plugin.xml +++ b/scouter.client/plugin.xml @@ -377,10 +377,10 @@ Date: Thu, 3 Dec 2015 17:23:18 +0900 Subject: [PATCH 19/42] typos --- .../src/scouter/server/netio/service/ServiceHandlingProxy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scouter.server/src/scouter/server/netio/service/ServiceHandlingProxy.java b/scouter.server/src/scouter/server/netio/service/ServiceHandlingProxy.java index 97c346b38..260bae6d0 100644 --- a/scouter.server/src/scouter/server/netio/service/ServiceHandlingProxy.java +++ b/scouter.server/src/scouter/server/netio/service/ServiceHandlingProxy.java @@ -79,7 +79,7 @@ public static void load() { Logger.println("Warning duplicated Handler key=" + key + " old=" + olds + " new=" + news); } else { if (Configure.getInstance().debug_request) { - Logger.println("RequestHandler " + key + "=>" + news); + Logger.println("ServiceHandler " + key + "=>" + news); } } handlers.put(key, news); From 5cde49ab2f1bc6ae9489410b0f6bee3fee50c27d Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Thu, 3 Dec 2015 18:09:12 +0900 Subject: [PATCH 20/42] refactoring --- scouter.client/src/scouter/client/net/ClientTCP.java | 2 +- scouter.server/scripts/sample1.startcon.sh | 5 +++++ scouter.server/scripts/startcon.sh | 5 +---- .../src/scouter/server/netio/service/net/TcpServer.scala | 1 - 4 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 scouter.server/scripts/sample1.startcon.sh diff --git a/scouter.client/src/scouter/client/net/ClientTCP.java b/scouter.client/src/scouter/client/net/ClientTCP.java index a7766bc7a..e3bc7245f 100644 --- a/scouter.client/src/scouter/client/net/ClientTCP.java +++ b/scouter.client/src/scouter/client/net/ClientTCP.java @@ -63,7 +63,7 @@ public void open(int serverId) { server.setConnected(true); } } catch (Throwable t) { - t.printStackTrace(); + System.out.println(t.getMessage()); close(); server.setConnected(false); } diff --git a/scouter.server/scripts/sample1.startcon.sh b/scouter.server/scripts/sample1.startcon.sh new file mode 100644 index 000000000..7db9ccabd --- /dev/null +++ b/scouter.server/scripts/sample1.startcon.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +. $(dirname $0)/env.sh + +java -Xmx512m -classpath "$TUNAHOME/boot.jar" scouter.boot.Boot "$TUNAHOME/lib" -console diff --git a/scouter.server/scripts/startcon.sh b/scouter.server/scripts/startcon.sh index 7db9ccabd..0a1df62bd 100644 --- a/scouter.server/scripts/startcon.sh +++ b/scouter.server/scripts/startcon.sh @@ -1,5 +1,2 @@ -#!/usr/bin/env bash +java -Xmx512m -cp boot.jar scouter.boot.Boot ./lib -console -. $(dirname $0)/env.sh - -java -Xmx512m -classpath "$TUNAHOME/boot.jar" scouter.boot.Boot "$TUNAHOME/lib" -console diff --git a/scouter.server/src/scouter/server/netio/service/net/TcpServer.scala b/scouter.server/src/scouter/server/netio/service/net/TcpServer.scala index 006d0277a..cc42da8ca 100644 --- a/scouter.server/src/scouter/server/netio/service/net/TcpServer.scala +++ b/scouter.server/src/scouter/server/netio/service/net/TcpServer.scala @@ -41,7 +41,6 @@ object TcpServer { server = new ServerSocket( conf.tcp_port); while (true) { val client = server.accept(); - // TODO 주의하여 테스트해야 client.setSoTimeout(conf.tcp_client_so_timeout); client.setReuseAddress(true); try { From de42a40b462a6ac7459c37f24dd73cb7b555623a Mon Sep 17 00:00:00 2001 From: SkyWorker Date: Fri, 4 Dec 2015 01:40:37 +0900 Subject: [PATCH 21/42] rename ServiceCore to XLogCore --- .../src/scouter/server/core/XLogCore.scala | 36 +++++++++---------- .../server/netio/data/NetDataProcessor.scala | 4 +-- .../scouter/server/term/handler/DEBUG.scala | 4 +-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/scouter.server/src/scouter/server/core/XLogCore.scala b/scouter.server/src/scouter/server/core/XLogCore.scala index 55de239b1..50d38742f 100644 --- a/scouter.server/src/scouter/server/core/XLogCore.scala +++ b/scouter.server/src/scouter/server/core/XLogCore.scala @@ -1,19 +1,19 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * */ package scouter.server.core; @@ -34,7 +34,7 @@ import scouter.server.tagcnt.XLogTagCount import scouter.server.util.ThreadScala import scouter.util.RequestQueue -object ServiceCore { +object XLogCore { val queue = new RequestQueue[XLogPack](CoreRun.MAX_QUE_SIZE); @@ -85,4 +85,4 @@ object ServiceCore { } } -} +} diff --git a/scouter.server/src/scouter/server/netio/data/NetDataProcessor.scala b/scouter.server/src/scouter/server/netio/data/NetDataProcessor.scala index 2caa41956..dc1cd476f 100644 --- a/scouter.server/src/scouter/server/netio/data/NetDataProcessor.scala +++ b/scouter.server/src/scouter/server/netio/data/NetDataProcessor.scala @@ -36,7 +36,7 @@ import scouter.server.core.AgentManager import scouter.server.core.AlertCore import scouter.server.core.PerfCountCore import scouter.server.core.ProfileCore -import scouter.server.core.ServiceCore +import scouter.server.core.XLogCore import scouter.server.core.StackAnalyzerCore import scouter.server.core.StatusCore import scouter.server.core.TextCore @@ -147,7 +147,7 @@ object NetDataProcessor { System.out.println("DEBUG UDP COUNTER: " + p) } case PackEnum.XLOG => - ServiceCore.add(p.asInstanceOf[XLogPack]) + XLogCore.add(p.asInstanceOf[XLogPack]) if (conf.debug_udp_xlog) { System.out.println("DEBUG UDP XLOG: " + p) } diff --git a/scouter.server/src/scouter/server/term/handler/DEBUG.scala b/scouter.server/src/scouter/server/term/handler/DEBUG.scala index df11a4376..8fe30cd9a 100644 --- a/scouter.server/src/scouter/server/term/handler/DEBUG.scala +++ b/scouter.server/src/scouter/server/term/handler/DEBUG.scala @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015 the original author or authors. * @https://github.com/scouter-project/scouter * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +36,7 @@ import scouter.lang.pack.XLogPack import scouter.util.CastUtil import scouter.server.db.VisitorDB import scouter.lang.ObjectType -import scouter.server.core.ServiceCore +import scouter.server.core.XLogCore import scouter.server.db.XLogProfileWR import scouter.server.db.XLogWR import scouter.server.core.ServerStat From bf0f8baf63d0f55e9df41be7ecba289f71a7c9d7 Mon Sep 17 00:00:00 2001 From: SkyWorker Date: Fri, 4 Dec 2015 12:19:12 +0900 Subject: [PATCH 22/42] bugfix --- scouter.server/src/scouter/server/geoip/GeoIpUtil.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scouter.server/src/scouter/server/geoip/GeoIpUtil.scala b/scouter.server/src/scouter/server/geoip/GeoIpUtil.scala index 138c11350..dca2b7689 100644 --- a/scouter.server/src/scouter/server/geoip/GeoIpUtil.scala +++ b/scouter.server/src/scouter/server/geoip/GeoIpUtil.scala @@ -58,11 +58,12 @@ object GeoIpUtil { private def isPrivateIp(ip: Array[Byte]): Boolean = { ip(0) & 0xff match { - case 127 => - case 10 => return true; - case 172 => return (ip(1) >= 16 && ip(1) <= 31); - case 192 => return ip(1) == 168; + case 127 | 10 => return true + case 172 => return (ip(1) >= 16 && ip(1) <= 31) + case 192 => return ip(1) == 168 + case _ => return false } return false; } + } From b08f2b6e1d831712293d9f0a565708160a87265b Mon Sep 17 00:00:00 2001 From: SkyWorker Date: Fri, 4 Dec 2015 16:30:26 +0900 Subject: [PATCH 23/42] no message --- .../src/scouter/server/ConfObserver.scala | 16 ++++++++++++++++ .../src/scouter/server/LoginManager.scala | 13 +++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/scouter.server/src/scouter/server/ConfObserver.scala b/scouter.server/src/scouter/server/ConfObserver.scala index 1125d381f..5f615dece 100644 --- a/scouter.server/src/scouter/server/ConfObserver.scala +++ b/scouter.server/src/scouter/server/ConfObserver.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package scouter.server import scouter.util.StringKeyLinkedMap diff --git a/scouter.server/src/scouter/server/LoginManager.scala b/scouter.server/src/scouter/server/LoginManager.scala index fc47d5b97..c77eb7b27 100644 --- a/scouter.server/src/scouter/server/LoginManager.scala +++ b/scouter.server/src/scouter/server/LoginManager.scala @@ -15,16 +15,9 @@ * limitations under the License. */ package scouter.server; -import java.util.Enumeration import scouter.server.account.AccountManager -import scouter.lang.Account -import scouter.util.CacheTable -import scouter.util.CacheTable.ENTRY -import scouter.util.DateUtil -import scouter.util.KeyGen -import scouter.util.ThreadUtil -import scouter.server.util.EnumerScala -import scouter.server.util.ThreadScala +import scouter.server.util.{EnumerScala, ThreadScala} +import scouter.util.{CacheTable, DateUtil, KeyGen, ThreadUtil} object LoginManager { val sessionTable = new CacheTable[Long, LoginUser]().setDefaultKeepTime(DateUtil.MILLIS_PER_MINUTE); ThreadScala.startDaemon("scouter.server.LoginManager") { @@ -56,7 +49,7 @@ object LoginManager { return sessionTable.getKeepAlive(key) != null } def validSession(key: Long): Int = { - var u = sessionTable.getKeepAlive(key); + val u = sessionTable.getKeepAlive(key); return if (u == null) 0 else 1 } def getLoginUserList(): Array[LoginUser] = { From e2ccc4d16e18ba7a57269cd0a5aa663d8a2a2b74 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Fri, 4 Dec 2015 18:03:52 +0900 Subject: [PATCH 24/42] refactoring --- .../src/scouter/agent/counter/task/JBossJMXPerf.java | 2 -- .../src/scouter/client/views/ObjectNavigationView.java | 10 ++++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java b/scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java index 3e6d7ac12..1369aae16 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java @@ -122,8 +122,6 @@ public void process(CounterBasket pw) { } getContextList(); } - collectCnt++; - collectCnt++; MBeanServer server = servers.get(0); for (CtxObj ctx : ctxList) { diff --git a/scouter.client/src/scouter/client/views/ObjectNavigationView.java b/scouter.client/src/scouter/client/views/ObjectNavigationView.java index 4fb6da198..0e1945119 100644 --- a/scouter.client/src/scouter/client/views/ObjectNavigationView.java +++ b/scouter.client/src/scouter/client/views/ObjectNavigationView.java @@ -110,6 +110,7 @@ import scouter.client.util.ImageUtil; import scouter.client.util.MenuUtil; import scouter.client.util.ScouterUtil; +import scouter.lang.ObjectType; import scouter.lang.counters.CounterConstants; import scouter.lang.counters.CounterEngine; import scouter.lang.value.Value; @@ -487,9 +488,14 @@ private void fillTreeViewerContextMenu(IMenuManager mgr){ private void addExistObjectTypeMenus(IWorkbenchWindow win, IMenuManager mgr, CounterEngine counterEngine, Map actionMap, int serverId) { Set agentTypeList = agentThread.getCurrentObjectTypeList(serverId); for(String objType : agentTypeList){ - String objTypeDisplay = counterEngine.getDisplayNameObjectType(objType); + ObjectType type = counterEngine.getObjectType(objType); + if (type.isSubObject()) { + // DataSource, RequestProcessor.....etc. + continue; + } + String displayName = type.getDisplayName(); ImageDescriptor objImage = Images.getObjectImageDescriptor(objType, true, serverId); - MenuManager objTitle = new MenuManager(objTypeDisplay, objImage, "scouter.menu.id."+objTypeDisplay); + MenuManager objTitle = new MenuManager(displayName, objImage, "scouter.menu.id."+displayName); mgr.add(objTitle); addObjectTypeMenu(objTitle, counterEngine, actionMap, serverId, objType); } From d13078b68ab38fbd53f0533f26019926a07c8491 Mon Sep 17 00:00:00 2001 From: KwonMunsoo Date: Sat, 5 Dec 2015 11:08:23 +0900 Subject: [PATCH 25/42] add a license statement --- .../src/scouter/client/util/SqlMakerUtil.java | 17 +++++++++++++++++ .../xlog/dialog/XlogSummarySQLDialog.java | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/scouter.client/src/scouter/client/util/SqlMakerUtil.java b/scouter.client/src/scouter/client/util/SqlMakerUtil.java index 0e2a8de92..0f97d523a 100644 --- a/scouter.client/src/scouter/client/util/SqlMakerUtil.java +++ b/scouter.client/src/scouter/client/util/SqlMakerUtil.java @@ -1,3 +1,20 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package scouter.client.util; import java.util.ArrayList; diff --git a/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java b/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java index ed348fac2..8a0e81833 100644 --- a/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java +++ b/scouter.client/src/scouter/client/xlog/dialog/XlogSummarySQLDialog.java @@ -1,3 +1,20 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package scouter.client.xlog.dialog; import java.util.ArrayList; From 015694c4c8eb23798f6be13be43d0f4b3e584c37 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Sun, 6 Dec 2015 21:02:06 +0900 Subject: [PATCH 26/42] ***** java agent - rename configure keys ***** --- .../src/scouter/agent/AgentTransformer.java | 76 +- .../src/scouter/agent/Configure.java | 738 +++++++++--------- .../src/scouter/agent/DirectPatch.java | 2 +- .../src/scouter/agent/Logger.java | 41 +- .../src/scouter/agent/asm/AddFieldASM.java | 5 +- .../src/scouter/agent/asm/ApicallASM.java | 5 +- .../src/scouter/agent/asm/ApicallInfoASM.java | 5 +- .../src/scouter/agent/asm/CapArgsASM.java | 6 +- .../src/scouter/agent/asm/CapReturnASM.java | 6 +- .../src/scouter/agent/asm/CapThisASM.java | 6 +- .../src/scouter/agent/asm/HttpServiceASM.java | 4 + .../scouter/agent/asm/InitialContextASM.java | 6 +- .../agent/asm/JDBCConnectionOpenASM.java | 6 +- .../src/scouter/agent/asm/JDBCDriverASM.java | 5 +- .../agent/asm/JDBCPreparedStatementASM.java | 7 +- .../scouter/agent/asm/JDBCResultSetASM.java | 7 +- .../scouter/agent/asm/JDBCStatementASM.java | 7 +- .../src/scouter/agent/asm/JspServletASM.java | 6 +- .../src/scouter/agent/asm/MethodASM.java | 13 +- .../src/scouter/agent/asm/ServiceASM.java | 6 +- .../src/scouter/agent/asm/SocketASM.java | 5 +- .../scouter/agent/asm/SpringReqMapASM.java | 2 +- .../src/scouter/agent/asm/SqlMapASM.java | 5 +- .../src/scouter/agent/asm/UserTxASM.java | 2 +- .../scouter/agent/counter/CounterBasket.java | 2 +- .../counter/CounterExecutingManager.java | 3 +- .../agent/counter/meter/MeterUsers.java | 47 +- .../agent/counter/task/AgentHeartBeat.java | 17 +- .../src/scouter/agent/counter/task/Debug.java | 6 +- .../scouter/agent/counter/task/HostPerf.java | 8 +- .../agent/counter/task/JBossJMXPerf.java | 14 +- .../scouter/agent/counter/task/MakeStack.java | 4 +- .../scouter/agent/counter/task/PermGen.java | 4 +- .../agent/counter/task/ServicePerf.java | 2 +- .../agent/counter/task/TomcatJMXPerf.java | 13 +- .../scouter/agent/netio/data/DataProxy.java | 20 +- .../agent/netio/data/UDPDataSendThread.java | 56 +- .../agent/netio/data/net/DataUdpAgent.java | 20 +- .../agent/netio/data/net/TcpRequestMgr.java | 4 +- .../agent/netio/data/net/TcpWorker.java | 23 +- .../agent/netio/request/handle/AgentEnv.java | 90 +-- .../scouter/agent/plugin/PluginLoader.java | 4 +- .../scouter/agent/proxy/LoaderManager.java | 2 +- .../scouter/agent/summary/EndUserSummary.java | 18 +- .../scouter/agent/summary/ServiceSummary.java | 32 +- .../src/scouter/agent/trace/AlertProxy.java | 3 +- .../scouter/agent/trace/LoadedContext.java | 2 +- .../scouter/agent/trace/ProfileCollector.java | 46 +- .../src/scouter/agent/trace/SocketTable.java | 2 +- .../src/scouter/agent/trace/TraceApiCall.java | 12 +- .../agent/trace/TraceContextManager.java | 4 +- .../src/scouter/agent/trace/TraceMain.java | 72 +- .../src/scouter/agent/trace/TraceSQL.java | 42 +- .../agent/trace/api/ForHttpClient40.java | 9 +- .../agent/trace/api/ForHttpClient43.java | 9 +- .../agent/trace/api/ForHttpURLConnection.java | 8 +- .../agent/trace/api/ForNettyHttpRequest.java | 10 +- .../scouter/agent/trace/api/ForRibbonLB.java | 10 +- .../src/scouter/agent/util/DumpUtil.java | 8 +- .../src/scouter/jdbc/DetectConnection.java | 4 +- .../src/scouter/test/Service24H.java | 110 +-- .../src/scouter/test/ShardMain.java | 2 +- .../src/scouter/test/TpsRush.java | 112 +-- .../src/scouter/xtra/http/HttpTrace.java | 42 +- 64 files changed, 913 insertions(+), 954 deletions(-) diff --git a/scouter.agent.java/src/scouter/agent/AgentTransformer.java b/scouter.agent.java/src/scouter/agent/AgentTransformer.java index 818ab1af6..f4a1aef51 100644 --- a/scouter.agent.java/src/scouter/agent/AgentTransformer.java +++ b/scouter.agent.java/src/scouter/agent/AgentTransformer.java @@ -15,43 +15,21 @@ * limitations under the License. */ package scouter.agent; -import java.lang.instrument.ClassFileTransformer; -import java.lang.instrument.IllegalClassFormatException; -import java.security.ProtectionDomain; -import java.util.ArrayList; -import java.util.List; -import scouter.agent.asm.AddFieldASM; -import scouter.agent.asm.ApicallASM; -import scouter.agent.asm.ApicallInfoASM; -import scouter.agent.asm.CapArgsASM; -import scouter.agent.asm.CapReturnASM; -import scouter.agent.asm.CapThisASM; -import scouter.agent.asm.HttpServiceASM; + import scouter.agent.asm.IASM; -import scouter.agent.asm.InitialContextASM; -import scouter.agent.asm.JDBCConnectionOpenASM; -import scouter.agent.asm.JDBCDriverASM; -import scouter.agent.asm.JDBCPreparedStatementASM; -import scouter.agent.asm.JDBCResultSetASM; -import scouter.agent.asm.JDBCStatementASM; -import scouter.agent.asm.JspServletASM; -import scouter.agent.asm.MethodASM; import scouter.agent.asm.ScouterClassWriter; -import scouter.agent.asm.ServiceASM; -import scouter.agent.asm.SocketASM; -import scouter.agent.asm.SpringReqMapASM; -import scouter.agent.asm.SqlMapASM; -import scouter.agent.asm.UserTxASM; import scouter.agent.asm.util.AsmUtil; import scouter.agent.util.AsyncRunner; import scouter.lang.conf.ConfObserver; -import scouter.org.objectweb.asm.AnnotationVisitor; -import scouter.org.objectweb.asm.ClassReader; -import scouter.org.objectweb.asm.ClassVisitor; -import scouter.org.objectweb.asm.ClassWriter; -import scouter.org.objectweb.asm.Opcodes; +import scouter.org.objectweb.asm.*; import scouter.util.FileUtil; import scouter.util.IntSet; + +import java.lang.instrument.ClassFileTransformer; +import java.lang.instrument.IllegalClassFormatException; +import java.security.ProtectionDomain; +import java.util.ArrayList; +import java.util.List; public class AgentTransformer implements ClassFileTransformer { public static ThreadLocal hookingCtx = new ThreadLocal(); private static List asms = new ArrayList(); @@ -73,42 +51,6 @@ public void run() { public static void reload() { Configure conf = Configure.getInstance(); List temp = new ArrayList(); - if (conf.enable_hook_service) { - temp.add(new HttpServiceASM()); - temp.add(new ServiceASM()); - } - if (conf.enable_hook_dbsql) { - temp.add(new JDBCPreparedStatementASM()); - temp.add(new JDBCResultSetASM()); - temp.add(new JDBCStatementASM()); - temp.add(new SqlMapASM()); - temp.add(new UserTxASM()); - } - if (conf.enable_hook_dbconn) { - temp.add(new JDBCConnectionOpenASM()); - temp.add(new JDBCDriverASM()); - temp.add(new InitialContextASM()); - } - if (conf.enable_hook_cap) { - temp.add(new CapArgsASM()); - temp.add(new CapReturnASM()); - temp.add(new CapThisASM()); - } - if (conf.enable_hook_methods) { - temp.add(new MethodASM()); - temp.add(new ApicallASM()); - temp.add(new ApicallInfoASM()); - temp.add(new SpringReqMapASM()); - } - if (conf.enable_hook_socket) { - temp.add(new SocketASM()); - } - if (conf.enable_hook_jsp) { - temp.add(new JspServletASM()); - } - if (conf.enable_hook_async) { - temp.add(new AddFieldASM()); - } asms = temp; } // ////////////////////////////////////////////////////////////// @@ -170,7 +112,7 @@ public AnnotationVisitor visitAnnotation(String desc, boolean visible) { cr.accept(cv, ClassReader.EXPAND_FRAMES); classfileBuffer = cw.toByteArray(); cv = cw = getClassWriter(classDesc); - if (conf.debug_asm) { + if (conf.log_asm_enabled) { if (this.bciOut == null) { this.bciOut = new Logger.FileLog("./scouter.bci"); } diff --git a/scouter.agent.java/src/scouter/agent/Configure.java b/scouter.agent.java/src/scouter/agent/Configure.java index 8df68d2ae..5382e3ef0 100644 --- a/scouter.agent.java/src/scouter/agent/Configure.java +++ b/scouter.agent.java/src/scouter/agent/Configure.java @@ -15,16 +15,7 @@ * limitations under the License. */ package scouter.agent; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; -import java.util.Set; + import scouter.Version; import scouter.agent.netio.data.DataProxy; import scouter.lang.conf.ConfObserver; @@ -33,17 +24,10 @@ import scouter.lang.value.ListValue; import scouter.lang.value.MapValue; import scouter.net.NetConstants; -import scouter.util.DateUtil; -import scouter.util.FileUtil; -import scouter.util.HashUtil; -import scouter.util.IntSet; -import scouter.util.StringEnumer; -import scouter.util.StringKeyLinkedMap; -import scouter.util.StringSet; -import scouter.util.StringUtil; -import scouter.util.SysJMX; -import scouter.util.SystemUtil; -import scouter.util.ThreadUtil; +import scouter.util.*; + +import java.io.*; +import java.util.*; public class Configure extends Thread { public static boolean JDBC_REDEFINED = false; private static Configure instance = null; @@ -56,172 +40,189 @@ public final static synchronized Configure getInstance() { } return instance; } - public String local_udp_addr = null; - public int local_udp_port; - public String server_addr = "127.0.0.1"; - public int server_udp_port = NetConstants.SERVER_UDP_PORT; - public int server_tcp_port = NetConstants.SERVER_TCP_PORT; - public int server_tcp_session_count = 1; - public int server_tcp_so_timeout = 60000; - public int server_tcp_connection_timeout = 3000; - public String scouter_type = ""; - public String scouter_name = ""; - public String objhost_type = ""; - public String objhost_name = ""; - public int objHash; - public String objName; - public int objHostHash; - public String objHostName; - public boolean enable_host_agent = false; - public boolean enable_objname_pid = false; - public boolean enable_plus_objtype = false; - public boolean enable_asm_jdbc = true; - public boolean enable_asm_socket = true; - public boolean http_debug_querystring; - public boolean http_debug_header; - public String http_debug_header_url = "/"; - public boolean http_debug_parameter; - public String http_debug_parameter_url = "/"; - /* - * user: 0 - remoteIp 1 - JSESSIONID + remoteIp 2 - SCOUTER(set-cookie) - */ - public int mode_userid = 2; - public boolean enable_profile_summary = false; - public boolean profile_thread_cputime = false; - public boolean profile_socket_openstack = false; - public int profile_socket_openstack_port = 0; - public boolean profile_framework_sqlmap = true; - public boolean listup_background_socket = true; - public int xlog_time_limit = 0; - public String http_error_status = ""; - private IntSet http_error_status_set = new IntSet(); - public String service_header_key; - public String service_get_key; - public String service_post_key; - public File dump_dir = new File("."); - public File subagent_dir = new File("./_scouter_"); - public File plugin_dir = new File("./_scouter_"); - public boolean enable_auto_dump = false; - public int auto_dump_trigger = 10000; - public long auto_dump_interval = 30000; - public int auto_dump_level = 1; - - public int debug_long_tx_autostack = 0; - public String http_static_contents = "js, htm, html, gif, png, jpg, css"; - private Set static_contents = new HashSet(); + + //Network + public String net_local_udp_ip = null; + public int net_local_udp_port; + public String net_collector_ip = "127.0.0.1"; + public int net_collector_udp_port = NetConstants.SERVER_UDP_PORT; + public int net_collector_tcp_port = NetConstants.SERVER_TCP_PORT; + public int net_collector_tcp_session_count = 1; + public int net_collector_tcp_so_timeout_ms = 60000; + public int net_collector_tcp_connection_timeout_ms = 3000; + public int net_udp_packet_max_bytes = 60000; + public long udp_udp_collection_interval_ms = 100; + + //Object + public String obj_type = ""; + public String obj_name = ""; + public String obj_host_type = ""; + public String obj_host_name = ""; + public boolean obj_host_enabled = false; + public boolean obj_name_auto_pid_enabled = false; + public boolean obj_type_inherit_to_child_enabled = false; + + //profile + public boolean profile_http_querystring_enabled; + public boolean profile_http_header_enabled; + public String profile_http_header_url_prefix = "/"; + public boolean profile_http_parameter_enabled; + public String profile_http_parameter_url_prefix = "/"; + public boolean profile_summary_mode_enabled = false; + public boolean profile_thread_cputime_enabled = false; + public boolean profile_socket_open_fullstack_enabled = false; + public int profile_socket_open_fullstack_port = 0; + public boolean profile_sqlmap_name_enabled = true; + public boolean profile_connection_open_enabled = true; + public boolean profile_connection_open_fullstack_enabled = false; + public boolean profile_connection_autocommit_status_enabled = false; + public boolean profile_method_enabled = true; + public int profile_step_max_count = 1024; + public boolean profile_fullstack_service_error_enabled = false; + public boolean profile_fullstack_apicall_error_enabled = false; + public boolean profile_fullstack_sql_error_enabled = false; + public boolean profile_fullstack_sql_commit_enabled = false; + public int profile_fullstack_max_lines = 0; + public boolean profile_sql_escape_enabled = true; + public boolean _profile_fullstack_sql_connection_enabled = false; + + //Trace + public int trace_user_mode = 2; // 0:Remote IP, 1:JSessionID, 2:SetCookie + public boolean trace_background_socket_enabled = true; + public String trace_service_name_header_key; + public String trace_service_name_get_key; + public String trace_service_name_post_key; + public long trace_activeserivce_yellow_time = 3000; + public long trace_activeservice_red_time = 8000; + public String trace_http_client_ip_header_key = ""; + public boolean trace_interservice_enabled = false; + public String trace_interservice_gxid_header_key = "X-Scouter-Gxid"; + public boolean trace_response_gxid_enabled = false; + public String trace_interservice_callee_header_key = "X-Scouter-Callee"; + public String trace_interservice_caller_header_key = "X-Scouter-Caller"; + public String trace_user_session_key = "JSESSIONID"; + public boolean _trace_auto_service_enabled = false; + public boolean _trace_auto_service_backstack_enabled = true; + public boolean trace_db2_enabled = true; + public boolean trace_webserver_enabled = false; + public String trace_webserver_name_header_key = "X-Forwarded-Host"; + public String trace_webserver_time_header_key = "X-Forwarded-Time"; + public int _trace_fullstack_socket_open_port = 0; + + //Manage + public File mgr_plugin_dir = new File("./_scouter_"); + public File mgr_dump_dir = new File("."); + public File mgr_agent_lib_dir = new File("./_scouter_"); + public String mgr_static_content_extensions = "js, htm, html, gif, png, jpg, css"; + public String mgr_log_ignore_ids = ""; + + //Autodump + public boolean autodump_enabled = false; + public int autodump_trigger_active_service_cnt = 10000; + public long autodump_interval_ms = 30000; + public int autodump_level = 1; // 1:ThreadDump, 2:ActiveService, 3:ThreadList + public int autodump_stuck_thread_ms = 0; + + //XLog + public int xlog_lower_bound_time_ms = 0; + public int xlog_error_jdbc_fetch_max = 10000; + public int xlog_error_sql_time_max_ms = 30000; + + //Alert public int alert_message_length = 3000; - public long alert_send_interval = 3000; - - public int jdbc_fetch_max = 10000; - public int sql_time_max = 30000; - public int udp_packet_max = 60000; - public boolean debug_asm; - public boolean debug_udp_xlog; - public boolean debug_udp_object; - public long yellow_line_time = 3000; - public long red_line_time = 8000; - public String log_ignore = ""; - public StringSet log_ignore_set = new StringSet(); - public String hook_args = ""; - public String hook_return = ""; - public String hook_init = ""; - public String hook_connection_open = ""; - public String hook_context = "javax/naming/InitialContext"; - public boolean debug_datasource_lookup=true; - public boolean enable_trace_connection_open = true; - public boolean enable_leaktrace_fullstack = false; - public boolean debug_connection_open_fullstack = false; - public boolean debug_connection_autocommit = false; - public String hook_method = ""; - public String hook_method_ignore_prefix = "get,set"; - private String[] _hook_method_ignore_prefix = null; - private int _hook_method_ignore_prefix_len = 0; + public long alert_send_interval_ms = 3000; + public int alert_perm_warning_pct = 90; + public long alert_perm_interval_ms = 30000; + + //Log + public boolean log_asm_enabled; + public boolean log_udp_xlog_enabled; + public boolean log_udp_object_enabled; + public boolean log_datasource_lookup_enabled = true; + public boolean log_background_sql = false; + public String log_dir =""; + public boolean log_rotation_enabled =true; + public int log_keep_days =7; + + //Hook + public String hook_args_patterns = ""; + public String hook_return_patterns = ""; + public String hook_constructor_patterns = ""; + public String hook_connection_open_patterns = ""; + public String hook_context_classes = "javax/naming/InitialContext"; + public String hook_method_patterns = ""; + public String hook_method_ignore_prefixes = "get,set"; public String hook_method_ignore_classes = ""; private StringSet _hook_method_ignore_classes = new StringSet(); - public boolean hook_method_access_public = true; - public boolean hook_method_access_private = false; - 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 = ""; - public String hook_jsp = ""; - public String hook_jdbc_pstmt = ""; - public String hook_jdbc_stmt = ""; - public String hook_jdbc_rs = ""; - public String hook_driver_connect_wrapper = ""; - public String hook_add_field = ""; - // /LOAD CONTROL///// - public boolean enable_reject_service = false; - public int max_active_service = 10000; - public boolean enable_reject_url = false; - public String reject_text = "too many request!!"; - public String reject_url = "/error.html"; - public int profile_step_max = 1024; - public boolean debug_background_sql = false; - public boolean profile_fullstack_service_error = false; - public boolean profile_fullstack_apicall_error = false; - public boolean profile_fullstack_sql_error = false; - public boolean profile_fullstack_sql_commit = false; - public int profile_fullstack_lines = 0; - public long udp_collection_interval = 100; - public boolean profile_sql_escape = true; - public String http_remote_ip_header_key = ""; - public boolean enable_trace_e2e = false; - public String gxid = "X-Scouter-Gxid"; - public boolean enable_response_gxid = false; - public String this_txid = "X-Scouter-Callee"; - public String caller_txid = "X-Scouter-Caller"; - private int hook_signature; - public String userid_jsessionid = "JSESSIONID"; - public boolean enable_auto_service_trace = false; - public boolean enable_auto_service_backstack = true; - // DEBUG OPTIONS - public boolean enable_counter_task = true; - public boolean enable_hook_service = true; - public boolean enable_hook_dbsql = true; - public boolean enable_hook_dbconn = true; - public boolean enable_hook_cap = true; - public boolean enable_hook_methods = true; - public boolean enable_hook_socket = true; - public boolean enable_hook_jsp = true; - public boolean enable_hook_async = true; - // ////////////////////////////////////////// - public boolean enable_usertx = true; - public boolean enable_dbc_wrapper = true; - public String direct_patch_class = ""; - public long max_think_time = DateUtil.MILLIS_PER_FIVE_MINUTE; - public String object_registry = "/tmp/scouter"; + public boolean hook_method_access_public_enabled = true; + public boolean hook_method_access_private_enabled = false; + public boolean hook_method_access_protected_enabled = false; + public boolean hook_method_access_none_enabled = false; + public String hook_service_patterns = ""; + public String hook_apicall_patterns = ""; + public String hook_apicall_info_patterns = ""; + public String hook_jsp_patterns = ""; + public String hook_jdbc_pstmt_classes = ""; + public String hook_jdbc_stmt_classes = ""; + public String hook_jdbc_rs_classes = ""; + public String hook_jdbc_wrapping_driver_patterns = ""; + public String hook_add_fields = ""; + public boolean _hook_serivce_enabled = true; + public boolean _hook_dbsql_enabled = true; + public boolean _hook_dbconn_enabled = true; + public boolean _hook_cap_enabled = true; + public boolean _hook_methods_enabled = true; + public boolean _hook_socket_enabled = true; + public boolean _hook_jsp_enabled = true; + public boolean _hook_async_enabled = true; + public boolean _hook_usertx_enabled = true; + public String _hook_direct_patch_classes = ""; + public boolean _hook_spring_rest_enabled = false; + + //Control + public boolean control_reject_service_enabled = false; + public int control_reject_service_max_count = 10000; + public boolean control_reject_redirect_url_enabled = false; + public String control_reject_text = "too many request!!"; + public String control_reject_redirect_url = "/error.html"; + + // Counter + public boolean counter_enabled = true; + public long counter_recentuser_valid_ms = DateUtil.MILLIS_PER_FIVE_MINUTE; + public String counter_object_registry_path = "/tmp/scouter"; + + // SFA(Stack Frequency Analyzer) public boolean sfa_dump_enabled = false; - public int sfa_dump_interval = 10000; - 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 = 5000; - public int summary_sql_max = 5000; - public int summary_api_max = 5000; - public int summary_service_ip_max = 5000; - public int summary_service_ua_max = 5000; - public int summary_service_error_max = 500; - - public int summary_enduser_nav_max = 5000; - public int summary_enduser_ajax_max = 5000; - public int summary_enduser_error_max = 5000; - - public int heap_perm_warning_pct = 90; - public long heap_perm_alert_interval = 30000; - public boolean hook_spring_request_mapping = false; - public boolean debug_sql_call = false; - public int socket_open_fullstack_port = 0; - public String logs_dir=""; - public boolean log_rotation=true; - public int log_keep_dates=7; - - public String enduser_perf_endpoint = "_scouter_browser.jsp"; - public int enduser_perf_endpoint_hash = HashUtil.hash(enduser_perf_endpoint); + public int sfa_dump_interval_ms = 10000; + + //Summary + public boolean summary_enabled = true; + public boolean summary_connection_leak_fullstack_enabled = false; + public int summary_service_max_count = 5000; + public int summary_sql_max_count = 5000; + public int summary_api_max_count = 5000; + public int summary_ip_max_count = 5000; + public int summary_useragent_max_count = 5000; + public int summary_error_max_count = 500; + public int summary_enduser_nav_max_count = 5000; + public int summary_enduser_ajax_max_count = 5000; + public int summary_enduser_error_max_count = 5000; + //EndUser + public String enduser_trace_endpoint_url = "_scouter_browser.jsp"; + + //internal variables + private int objHash; + private String objName; + private int objHostHash; + private String objHostName; + private Set static_contents = new HashSet(); + private StringSet log_ignore_set = new StringSet(); + private String[] _hook_method_ignore_prefix = null; + private int _hook_method_ignore_prefix_len = 0; + private int hook_signature; + private int enduser_perf_endpoint_hash = HashUtil.hash(enduser_trace_endpoint_url); + /** * sometimes call by sample application, at that time normally set some * properties directly @@ -293,196 +294,215 @@ public synchronized boolean reload(boolean force) { return true; } private void apply() { - this.http_debug_querystring = getBoolean("http_debug_querystring", false); - this.http_debug_header = getBoolean("http_debug_header", false); - this.http_debug_parameter = getBoolean("http_debug_parameter", false); - this.enable_profile_summary = getBoolean("enable_profile_summary", getBoolean("enable.profile.summary", false)); - this.xlog_time_limit = getInt("xlog_time_limit", getInt("xlog.time.limit", 0)); - this.service_header_key = getValue("service_header_key", getValue("service.header.key", null)); - this.service_get_key = getValue("service_get_key"); - this.service_post_key = getValue("service_post_key"); - this.http_error_status = getValue("http_error_status", getValue("http.error.status", "")); - this.dump_dir = new File(getValue("dump_dir", getValue("dump.dir", "."))); + this.profile_http_querystring_enabled = getBoolean("profile_http_querystring_enabled", false); + this.profile_http_header_enabled = getBoolean("profile_http_header_enabled", false); + this.profile_http_parameter_enabled = getBoolean("profile_http_parameter_enabled", false); + this.profile_summary_mode_enabled = getBoolean("profile_summary_mode_enabled", false); + this.xlog_lower_bound_time_ms = getInt("xlog_lower_bound_time_ms", 0); + this.trace_service_name_header_key = getValue("trace_service_name_header_key", null); + this.trace_service_name_get_key = getValue("trace_service_name_get_key"); + this.trace_service_name_post_key = getValue("trace_service_name_post_key"); + this.mgr_dump_dir = new File(getValue("mgr_dump_dir", ".")); try { - this.dump_dir.mkdirs(); + this.mgr_dump_dir.mkdirs(); } catch (Exception e) { } - this.subagent_dir = new File(getValue("subagent_dir", getValue("subagent.dir", "./_scouter_"))); + this.mgr_agent_lib_dir = new File(getValue("mgr_agent_lib_dir", "./_scouter_")); try { - this.subagent_dir.mkdirs(); + this.mgr_agent_lib_dir.mkdirs(); } catch (Exception e) { } - this.plugin_dir = new File(getValue("plugin_dir", getValue("plugin.dir", "./_scouter_"))); + this.mgr_plugin_dir = new File(getValue("mgr_plugin_dir", "./_scouter_")); - this.enable_auto_dump = getBoolean("enable_auto_dump", getBoolean("enable.auto.dump", false)); - this.auto_dump_trigger = getInt("auto_dump_trigger", getInt("auto.dump.trigger", 10000)); - if (this.auto_dump_trigger < 1) { - this.auto_dump_trigger = 1; + this.autodump_enabled = getBoolean("autodump_enabled", false); + this.autodump_trigger_active_service_cnt = getInt("autodump_trigger_active_service_cnt", 10000); + if (this.autodump_trigger_active_service_cnt < 1) { + this.autodump_trigger_active_service_cnt = 1; } - this.auto_dump_level = getInt("auto_dump_level", getInt("auto.dump.level", 1)); - this.auto_dump_interval = getInt("auto_dump_interval", getInt("auto.dump.interval", 30000)); - if (this.auto_dump_interval < 5000) { - this.auto_dump_interval = 5000; + this.autodump_level = getInt("autodump_level", 1); + this.autodump_interval_ms = getInt("autodump_interval_ms", 30000); + if (this.autodump_interval_ms < 5000) { + this.autodump_interval_ms = 5000; } - this.debug_long_tx_autostack = getInt("debug_long_tx_autostack", 0); - this.http_static_contents = getValue("http_static_contents", - getValue("http.static.contents", "js, htm, html, gif, png, jpg, css")); - this.profile_thread_cputime = getBoolean("profile_thread_cputime", getBoolean("profile.thread.cputime", false)); - this.profile_socket_openstack = getBoolean("profile_socket_openstack", - getBoolean("profile.socket.openstack", false)); - this.listup_background_socket = getBoolean("listup_background_socket", true); - this.profile_socket_openstack_port = getInt("profile_socket_openstack_port", 0); - this.profile_sql_escape = getBoolean("profile_sql_escape", true); - this.profile_framework_sqlmap = getBoolean("profile_framework_sqlmap", true); - this.enable_asm_jdbc = getBoolean("enable_asm_jdbc", getBoolean("enable.asm.jdbc", true)); - this.enable_asm_socket = getBoolean("enable_asm_socket", getBoolean("enable.asm.socket", true)); - this.udp_packet_max = getInt("udp_packet_max", getInt("udp.packet.max", 60000)); - this.yellow_line_time = getLong("yellow_line_time", getLong("yellow.line.time", 3000)); - this.red_line_time = getLong("red_line_time", getLong("red.line.time", 8000)); - this.log_ignore = getValue("log_ignore", ""); - this.log_ignore_set = getStringSet("log_ignore", ","); - this.debug_udp_xlog = getBoolean("debug_udp_xlog", getBoolean("debug.udp.xlog", false)); - this.debug_udp_object = getBoolean("debug_udp_object", getBoolean("debug.udp.object", false)); - this.local_udp_addr = getValue("local_udp_addr"); - this.local_udp_port = getInt("local_udp_port", 0); - this.server_addr = getValue("server_addr", getValue("server.addr", "127.0.0.1")); - this.server_udp_port = getInt("server_udp_port", getInt("server.port", NetConstants.SERVER_UDP_PORT)); - this.server_tcp_port = getInt("server_tcp_port", getInt("server.port", NetConstants.SERVER_TCP_PORT)); - this.server_tcp_session_count = getInt("server_tcp_session_count", 1, 1); - this.server_tcp_connection_timeout = getInt("server_tcp_connection_timeout", 3000); - this.server_tcp_so_timeout = getInt("server_tcp_so_timeout", 60000); + this.autodump_stuck_thread_ms = getInt("autodump_stuck_thread_ms", 0); + this.mgr_static_content_extensions = getValue("mgr_static_content_extensions", "js, htm, html, gif, png, jpg, css"); + this.profile_thread_cputime_enabled = getBoolean("profile_thread_cputime_enabled", false); + this.profile_socket_open_fullstack_enabled = getBoolean("profile_socket_open_fullstack_enabled", false); + this.trace_background_socket_enabled = getBoolean("trace_background_socket_enabled", true); + this.profile_socket_open_fullstack_port = getInt("profile_socket_open_fullstack_port", 0); + this.profile_sql_escape_enabled = getBoolean("profile_sql_escape_enabled", true); + this.profile_sqlmap_name_enabled = getBoolean("profile_sqlmap_name_enabled", true); + this.net_udp_packet_max_bytes = getInt("net_udp_packet_max_bytes", 60000); + this.trace_activeserivce_yellow_time = getLong("trace_activeserivce_yellow_time", 3000); + this.trace_activeservice_red_time = getLong("trace_activeservice_red_time", 8000); + this.mgr_log_ignore_ids = getValue("mgr_log_ignore_ids", ""); + this.log_ignore_set = getStringSet("mgr_log_ignore_ids", ","); + this.log_udp_xlog_enabled = getBoolean("log_udp_xlog_enabled", false); + this.log_udp_object_enabled = getBoolean("log_udp_object_enabled", false); + this.net_local_udp_ip = getValue("net_local_udp_ip"); + this.net_local_udp_port = getInt("net_local_udp_port", 0); + this.net_collector_ip = getValue("net_collector_ip", "127.0.0.1"); + this.net_collector_udp_port = getInt("net_collector_udp_port", NetConstants.SERVER_UDP_PORT); + this.net_collector_tcp_port = getInt("net_collector_tcp_port", NetConstants.SERVER_TCP_PORT); + this.net_collector_tcp_session_count = getInt("net_collector_tcp_session_count", 1, 1); + this.net_collector_tcp_connection_timeout_ms = getInt("net_collector_tcp_connection_timeout_ms", 3000); + this.net_collector_tcp_so_timeout_ms = getInt("net_collector_tcp_so_timeout_ms", 60000); this.hook_signature = 0; - this.hook_args = getValue("hook_args", getValue("hook.args", "")); - this.hook_return = getValue("hook_return", getValue("hook.return", "")); - this.hook_init = getValue("hook_init", getValue("hook.init", "")); - this.hook_connection_open = getValue("hook_connection_open", ""); - - this.debug_datasource_lookup = getBoolean("debug_datasource_lookup", true); - this.enable_trace_connection_open = getBoolean("enable_trace_connection_open", true); - this.enable_leaktrace_fullstack = getBoolean("enable_leaktrace_fullstack", false); - this.hook_method = getValue("hook_method", ""); - this.hook_method_access_public = getBoolean("hook_method_access_public", true); - this.hook_method_access_protected = getBoolean("hook_method_access_protected", false); - this.hook_method_access_private = getBoolean("hook_method_access_private", false); - this.hook_method_access_none = getBoolean("hook_method_access_none", false); - this.hook_method_ignore_prefix = StringUtil.removeWhitespace(getValue("hook_method_ignore_prefix", "get,set")); - this._hook_method_ignore_prefix = StringUtil.split(this.hook_method_ignore_prefix, ","); + this.hook_args_patterns = getValue("hook_args_patterns", ""); + this.hook_return_patterns = getValue("hook_return_patterns", ""); + this.hook_constructor_patterns = getValue("hook_constructor_patterns", ""); + this.hook_connection_open_patterns = getValue("hook_connection_open_patterns", ""); + + this.log_datasource_lookup_enabled = getBoolean("log_datasource_lookup_enabled", true); + this.profile_connection_open_enabled = getBoolean("profile_connection_open_enabled", true); + this.summary_connection_leak_fullstack_enabled = getBoolean("summary_connection_leak_fullstack_enabled", false); + this.hook_method_patterns = getValue("hook_method_patterns", ""); + this.hook_method_access_public_enabled = getBoolean("hook_method_access_public_enabled", true); + this.hook_method_access_protected_enabled = getBoolean("hook_method_access_protected_enabled", false); + this.hook_method_access_private_enabled = getBoolean("hook_method_access_private_enabled", false); + this.hook_method_access_none_enabled = getBoolean("hook_method_access_none_enabled", false); + this.hook_method_ignore_prefixes = StringUtil.removeWhitespace(getValue("hook_method_ignore_prefixes", "get,set")); + this._hook_method_ignore_prefix = StringUtil.split(this.hook_method_ignore_prefixes, ","); this._hook_method_ignore_prefix_len = this._hook_method_ignore_prefix == null ? 0 : this._hook_method_ignore_prefix.length; this.hook_method_ignore_classes = StringUtil.trimEmpty(StringUtil.removeWhitespace(getValue( "hook_method_ignore_classes", ""))); this._hook_method_ignore_classes = new StringSet(StringUtil.tokenizer( this.hook_method_ignore_classes.replace('.', '/'), ",")); - this.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", ""); - this.hook_jsp = getValue("hook_jsp", ""); + this.profile_method_enabled = getBoolean("profile_method_enabled", true); + this.hook_service_patterns = getValue("hook_service_patterns", ""); + this.hook_apicall_patterns = getValue("hook_apicall_patterns", ""); + this.hook_apicall_info_patterns = getValue("hook_apicall_info_patterns", ""); + this.hook_jsp_patterns = getValue("hook_jsp_patterns", ""); - this.hook_jdbc_pstmt = getValue("hook_jdbc_pstmt", ""); - this.hook_jdbc_stmt = getValue("hook_jdbc_stmt", ""); - this.hook_jdbc_rs = getValue("hook_jdbc_rs", ""); - this.hook_driver_connect_wrapper = getValue("hook_driver_connect_wrapper", ""); - this.hook_add_field = getValue("hook_add_field", ""); - this.hook_context = getValue("hook_context", "javax/naming/InitialContext"); + this.hook_jdbc_pstmt_classes = getValue("hook_jdbc_pstmt_classes", ""); + this.hook_jdbc_stmt_classes = getValue("hook_jdbc_stmt_classes", ""); + this.hook_jdbc_rs_classes = getValue("hook_jdbc_rs_classes", ""); + this.hook_jdbc_wrapping_driver_patterns = getValue("hook_jdbc_wrapping_driver_patterns", ""); + this.hook_add_fields = getValue("hook_add_fields", ""); + this.hook_context_classes = getValue("hook_context_classes", "javax/naming/InitialContext"); - this.hook_signature ^= this.hook_args.hashCode(); - this.hook_signature ^= this.hook_return.hashCode(); - this.hook_signature ^= this.hook_init.hashCode(); - this.hook_signature ^= this.hook_connection_open.hashCode(); - this.hook_signature ^= this.hook_method.hashCode(); - this.hook_signature ^= this.hook_service.hashCode(); - this.hook_signature ^= this.hook_apicall.hashCode(); - this.hook_signature ^= this.hook_jsp.hashCode(); - this.hook_signature ^= this.hook_driver_connect_wrapper.hashCode(); + this.hook_signature ^= this.hook_args_patterns.hashCode(); + this.hook_signature ^= this.hook_return_patterns.hashCode(); + this.hook_signature ^= this.hook_constructor_patterns.hashCode(); + this.hook_signature ^= this.hook_connection_open_patterns.hashCode(); + this.hook_signature ^= this.hook_method_patterns.hashCode(); + this.hook_signature ^= this.hook_service_patterns.hashCode(); + this.hook_signature ^= this.hook_apicall_patterns.hashCode(); + this.hook_signature ^= this.hook_jsp_patterns.hashCode(); + this.hook_signature ^= this.hook_jdbc_wrapping_driver_patterns.hashCode(); - this.enable_reject_service = getBoolean("enable_reject_service", false); - this.max_active_service = getInt("max_active_service", 10000); - this.enable_reject_url = getBoolean("enable_reject_url", false); - this.reject_text = getValue("reject_text", "too many request!!"); - this.reject_url = getValue("reject_url", "/error.html"); - this.profile_step_max = getInt("profile_step_max", 1024); - if (this.profile_step_max < 100) - this.profile_step_max = 100; - this.debug_background_sql = getBoolean("debug_background_sql", false); - this.profile_fullstack_service_error = getBoolean("profile_fullstack_service_error", false); - this.profile_fullstack_apicall_error = getBoolean("profile_fullstack_apicall_error", false); - this.profile_fullstack_sql_error = getBoolean("profile_fullstack_sql_error", false); - this.profile_fullstack_sql_commit = getBoolean("profile_fullstack_sql_commit", false); - this.profile_fullstack_lines = getInt("profile_fullstack_lines", 0); - this.udp_collection_interval = getInt("udp_collection_interval", 100); - this.http_debug_parameter_url = getValue("http_debug_parameter_url", "/"); - this.http_debug_header_url = getValue("http_debug_header_url", "/"); - this.http_remote_ip_header_key = getValue("http_remote_ip_header_key", ""); - this.enable_trace_e2e = getBoolean("enable_trace_e2e", false); - this.enable_response_gxid = getBoolean("enable_response_gxid", false); - this.gxid = getValue("gxid", "X-Scouter-Gxid"); - this.this_txid = getValue("this_txid", "X-Scouter-Callee"); - this.caller_txid = getValue("caller_txid", "X-Scouter-Caller"); - this.debug_connection_open_fullstack = getBoolean("debug_connection_open_fullstack", false); - this.debug_connection_autocommit = getBoolean("debug_connection_autocommit", false); - this.mode_userid = getInt("mode_userid", 2); - this.userid_jsessionid = getValue("userid_jsessionid", "JSESSIONID"); - this.enable_host_agent = getBoolean("enable_host_agent", false); - this.enable_auto_service_trace = getBoolean("enable_auto_service_trace", false); - this.enable_auto_service_backstack = getBoolean("enable_auto_service_backstack", true); - this.enable_counter_task = getBoolean("enable_counter_task", true); - this.enable_hook_service = getBoolean("enable_hook_service", true); - this.enable_hook_dbsql = getBoolean("enable_hook_dbsql", true); - this.enable_hook_dbconn = getBoolean("enable_hook_dbconn", true); - this.enable_hook_cap = getBoolean("enable_hook_cap", true); - this.enable_hook_methods = getBoolean("enable_hook_methods", true); - this.enable_hook_socket = getBoolean("enable_hook_socket", true); - this.enable_hook_jsp = getBoolean("enable_hook_jsp", true); - this.enable_hook_async = getBoolean("enable_hook_async", true); - this.enable_dbc_wrapper = getBoolean("enable_dbc_wrapper", true); - this.enable_usertx = getBoolean("enable_usertx", true); - this.direct_patch_class = getValue("direct_patch_class", ""); - this.max_think_time = getLong("max_think_time", DateUtil.MILLIS_PER_FIVE_MINUTE); - this.object_registry = getValue("object_registry", "/tmp/scouter"); + this.control_reject_service_enabled = getBoolean("control_reject_service_enabled", false); + this.control_reject_service_max_count = getInt("control_reject_service_max_count", 10000); + this.control_reject_redirect_url_enabled = getBoolean("control_reject_redirect_url_enabled", false); + this.control_reject_text = getValue("control_reject_text", "too many request!!"); + this.control_reject_redirect_url = getValue("control_reject_redirect_url", "/error.html"); + this.profile_step_max_count = getInt("profile_step_max_count", 1024); + if (this.profile_step_max_count < 100) + this.profile_step_max_count = 100; + this.log_background_sql = getBoolean("log_background_sql", false); + this.profile_fullstack_service_error_enabled = getBoolean("profile_fullstack_service_error_enabled", false); + this.profile_fullstack_apicall_error_enabled = getBoolean("profile_fullstack_apicall_error_enabled", false); + this.profile_fullstack_sql_error_enabled = getBoolean("profile_fullstack_sql_error_enabled", false); + this.profile_fullstack_sql_commit_enabled = getBoolean("profile_fullstack_sql_commit_enabled", false); + this.profile_fullstack_max_lines = getInt("profile_fullstack_max_lines", 0); + this.udp_udp_collection_interval_ms = getInt("udp_udp_collection_interval_ms", 100); + this.profile_http_parameter_url_prefix = getValue("profile_http_parameter_url_prefix", "/"); + this.profile_http_header_url_prefix = getValue("profile_http_header_url_prefix", "/"); + this.trace_http_client_ip_header_key = getValue("trace_http_client_ip_header_key", ""); + this.trace_interservice_enabled = getBoolean("trace_interservice_enabled", false); + this.trace_response_gxid_enabled = getBoolean("trace_response_gxid_enabled", false); + this.trace_interservice_gxid_header_key = getValue("trace_interservice_gxid_header_key", "X-Scouter-Gxid"); + this.trace_interservice_callee_header_key = getValue("trace_interservice_callee_header_key", "X-Scouter-Callee"); + this.trace_interservice_caller_header_key = getValue("trace_interservice_caller_header_key", "X-Scouter-Caller"); + this.profile_connection_open_fullstack_enabled = getBoolean("profile_connection_open_fullstack_enabled", false); + this.profile_connection_autocommit_status_enabled = getBoolean("profile_connection_autocommit_status_enabled", false); + this.trace_user_mode = getInt("trace_user_mode", 2); + this.trace_user_session_key = getValue("trace_user_session_key", "JSESSIONID"); + this.obj_host_enabled = getBoolean("obj_host_enabled", false); + this._trace_auto_service_enabled = getBoolean("_trace_auto_service_enabled", false); + this._trace_auto_service_backstack_enabled = getBoolean("_trace_auto_service_backstack_enabled", true); + this.counter_enabled = getBoolean("counter_enabled", true); + this._hook_serivce_enabled = getBoolean("_hook_serivce_enabled", true); + this._hook_dbsql_enabled = getBoolean("_hook_dbsql_enabled", true); + this._hook_dbconn_enabled = getBoolean("_hook_dbconn_enabled", true); + this._hook_cap_enabled = getBoolean("_hook_cap_enabled", true); + this._hook_methods_enabled = getBoolean("_hook_methods_enabled", true); + this._hook_socket_enabled = getBoolean("_hook_socket_enabled", true); + this._hook_jsp_enabled = getBoolean("_hook_jsp_enabled", true); + this._hook_async_enabled = getBoolean("_hook_async_enabled", true); + this.trace_db2_enabled = getBoolean("trace_db2_enabled", true); + this._hook_usertx_enabled = getBoolean("_hook_usertx_enabled", true); + this._hook_direct_patch_classes = getValue("_hook_direct_patch_classes", ""); + this.counter_recentuser_valid_ms = getLong("counter_recentuser_valid_ms", DateUtil.MILLIS_PER_FIVE_MINUTE); + this.counter_object_registry_path = getValue("counter_object_registry_path", "/tmp/scouter"); this.sfa_dump_enabled = getBoolean("sfa_dump_enabled", false); - this.sfa_dump_interval = getInt("sfa_dump_interval", 10000); + this.sfa_dump_interval_ms = getInt("sfa_dump_interval_ms", 10000); // 웹시스템으로 부터 WAS 사이의 성능과 어떤 웹서버가 요청을 보내 왔는지를 추적하는 기능을 ON/OFF하고 // 관련 키정보를 지정한다. - this.enable_trace_web = getBoolean("enable_trace_web", false); - this.key_web_name = getValue("key_web_name", "X-Forwarded-Host"); - this.key_web_time = getValue("key_web_time", "X-Forwarded-Time"); + this.trace_webserver_enabled = getBoolean("trace_webserver_enabled", false); + this.trace_webserver_name_header_key = getValue("trace_webserver_name_header_key", "X-Forwarded-Host"); + this.trace_webserver_time_header_key = getValue("trace_webserver_time_header_key", "X-Forwarded-Time"); // SUMMARY최대 갯수를 관리한다. - this.enable_summary = getBoolean("enable_summary", true); - this.summary_sql_max = getInt("summary_sql_max", 5000); - this.summary_api_max = getInt("summary_api_max", 5000); - this.summary_service_max = getInt("summary_service_max", 5000); - this.summary_service_ip_max = getInt("summary_service_ip_max", 5000); - this.summary_service_ua_max = getInt("summary_service_ua_max", 5000); - this.summary_service_error_max = getInt("summary_service_error_max", 500); + this.summary_enabled = getBoolean("summary_enabled", true); + this.summary_sql_max_count = getInt("summary_sql_max_count", 5000); + this.summary_api_max_count = getInt("summary_api_max_count", 5000); + this.summary_service_max_count = getInt("summary_service_max_count", 5000); + this.summary_ip_max_count = getInt("summary_ip_max_count", 5000); + this.summary_useragent_max_count = getInt("summary_useragent_max_count", 5000); + this.summary_error_max_count = getInt("summary_error_max_count", 500); - this.summary_enduser_nav_max = getInt("summary_enduser_nav_max", 5000); - this.summary_enduser_ajax_max = getInt("summary_enduser_ajax_max", 5000); - this.summary_enduser_error_max = getInt("summary_enduser_error_max", 5000); + this.summary_enduser_nav_max_count = getInt("summary_enduser_nav_max_count", 5000); + this.summary_enduser_ajax_max_count = getInt("summary_enduser_ajax_max_count", 5000); + this.summary_enduser_error_max_count = getInt("summary_enduser_error_max_count", 5000); - this.heap_perm_alert_interval = getLong("heap_perm_alert_interval", 30000); - this.heap_perm_warning_pct = getInt("heap_perm_warning_pct", 90); - this.hook_spring_request_mapping = getBoolean("hook_spring_request_mapping", false); + this.alert_perm_interval_ms = getLong("alert_perm_interval_ms", 30000); + this.alert_perm_warning_pct = getInt("alert_perm_warning_pct", 90); + this._hook_spring_rest_enabled = getBoolean("_hook_spring_rest_enabled", false); this.alert_message_length = getInt("alert_message_length", 3000); - this.alert_send_interval = getInt("alert_send_interval", 3000); - this.jdbc_fetch_max = getInt("jdbc_fetch_max", 10000); - this.sql_time_max = getInt("sql_time_max", 30000); - this.debug_asm = getBoolean("debug_asm", getBoolean("debug.asm", false)); - this.enable_plus_objtype = getBoolean("enable_plus_objtype", false); - this.debug_sql_call = getBoolean("debug_sql_call", false); - this.socket_open_fullstack_port = getInt("socket_open_fullstack_port", 0); - this.logs_dir= getValue("logs_dir", ""); - this.log_rotation = getBoolean("log_rotation", true); - this.log_keep_dates = getInt("log_keep_dates", 7); + this.alert_send_interval_ms = getInt("alert_send_interval_ms", 3000); + this.xlog_error_jdbc_fetch_max = getInt("xlog_error_jdbc_fetch_max", 10000); + this.xlog_error_sql_time_max_ms = getInt("xlog_error_sql_time_max_ms", 30000); + this.log_asm_enabled = getBoolean("log_asm_enabled", false); + this.obj_type_inherit_to_child_enabled = getBoolean("obj_type_inherit_to_child_enabled", false); + this._profile_fullstack_sql_connection_enabled = getBoolean("_profile_fullstack_sql_connection_enabled", false); + this._trace_fullstack_socket_open_port = getInt("_trace_fullstack_socket_open_port", 0); + this.log_dir = getValue("log_dir", ""); + this.log_rotation_enabled = getBoolean("log_rotation_enabled", true); + this.log_keep_days = getInt("log_keep_days", 7); - this.enduser_perf_endpoint = getValue("enduser_perf_endpoint", "_scouter_browser.jsp"); - this.enduser_perf_endpoint_hash = HashUtil.hash(this.enduser_perf_endpoint); + this.enduser_trace_endpoint_url = getValue("enduser_trace_endpoint_url", "_scouter_browser.jsp"); + this.enduser_perf_endpoint_hash = HashUtil.hash(this.enduser_trace_endpoint_url); resetObjInfo(); - setErrorStatus(); setStaticContents(); } + + public int getObjHash() { + return this.objHash; + } + + public String getObjName() { + return this.objName; + } + + public int getObjHostHash(){ + return this.objHostHash; + } + + public String getObjHostName() { + return this.objHostName; + } + + public int getEndUserPerfEndpointHash() { + return this.enduser_perf_endpoint_hash; + } + + public boolean isIgnoreLog(String id) { + return log_ignore_set.hasKey(id); + } + private StringSet getStringSet(String key, String deli) { StringSet set = new StringSet(); String v = getValue(key); @@ -498,7 +518,7 @@ private StringSet getStringSet(String key, String deli) { } private void setStaticContents() { Set tmp = new HashSet(); - String[] s = StringUtil.split(this.http_static_contents, ','); + String[] s = StringUtil.split(this.mgr_static_content_extensions, ','); for (int i = 0; i < s.length; i++) { String ss = s[i].trim(); if (ss.length() > 0) { @@ -523,7 +543,7 @@ public boolean isIgnoreMethodClass(String classname) { public synchronized void resetObjInfo() { String detected = ObjTypeDetector.drivedType != null ? ObjTypeDetector.drivedType : ObjTypeDetector.objType != null ? ObjTypeDetector.objType : CounterConstants.JAVA; - this.scouter_type = getValue("scouter_type", detected); + this.obj_type = getValue("obj_type", detected); detected = CounterConstants.HOST; if (SystemUtil.IS_LINUX) { detected = CounterConstants.LINUX; @@ -536,40 +556,24 @@ public synchronized void resetObjInfo() { } else if (SystemUtil.IS_HP_UX) { detected = CounterConstants.HPUX; } - this.objhost_type = getValue("objhost_type", detected); - this.objhost_name = getValue("objhost_name", SysJMX.getHostName()); - this.objHostName = "/" + this.objhost_name; + this.obj_host_type = getValue("obj_host_type", detected); + this.obj_host_name = getValue("obj_host_name", SysJMX.getHostName()); + this.objHostName = "/" + this.obj_host_name; this.objHostHash = HashUtil.hash(objHostName); - this.enable_objname_pid = getBoolean("enable_objname_pid", false); + this.obj_name_auto_pid_enabled = getBoolean("obj_name_auto_pid_enabled", false); String defaultName; - if (this.enable_objname_pid == true) { + if (this.obj_name_auto_pid_enabled == true) { defaultName = "" + SysJMX.getProcessPID(); } else { - defaultName = this.scouter_type + "1"; + defaultName = this.obj_type + "1"; } - this.scouter_name = getValue("scouter_name", System.getProperty("jvmRoute", defaultName)); - this.objName = objHostName + "/" + this.scouter_name; + this.obj_name = getValue("obj_name", System.getProperty("jvmRoute", defaultName)); + this.objName = objHostName + "/" + this.obj_name; this.objHash = HashUtil.hash(objName); System.setProperty("scouter.objname", this.objName); - System.setProperty("scouter.objtype", this.scouter_type); + System.setProperty("scouter.objtype", this.obj_type); System.setProperty("scouter.dir", new File(".").getAbsolutePath()); } - private void setErrorStatus() { - String[] status = StringUtil.split(this.http_error_status, ','); - http_error_status_set.clear(); - for (int i = 0; i < status.length; i++) { - try { - int code = Integer.parseInt(status[i].trim()); - if (code > 0) { - http_error_status_set.add(code); - } - } catch (Exception e) { - } - } - } - public boolean isErrorStatus(int status) { - return http_error_status_set.contains(status); - } public String getValue(String key) { return StringUtil.trim(property.getProperty(key)); } diff --git a/scouter.agent.java/src/scouter/agent/DirectPatch.java b/scouter.agent.java/src/scouter/agent/DirectPatch.java index 27a296d5d..504fccfb5 100644 --- a/scouter.agent.java/src/scouter/agent/DirectPatch.java +++ b/scouter.agent.java/src/scouter/agent/DirectPatch.java @@ -31,7 +31,7 @@ public class DirectPatch { static { try { - String patch = Configure.getInstance().direct_patch_class; + String patch = Configure.getInstance()._hook_direct_patch_classes; String[] files = StringUtil.tokenizer(patch, ",;"); for (int i = 0; files!=null && i < files.length; i++) { byte[] bytes = FileUtil.readAll(new File(files[i])); diff --git a/scouter.agent.java/src/scouter/agent/Logger.java b/scouter.agent.java/src/scouter/agent/Logger.java index 174489a86..2cca70c6b 100644 --- a/scouter.agent.java/src/scouter/agent/Logger.java +++ b/scouter.agent.java/src/scouter/agent/Logger.java @@ -22,8 +22,6 @@ import java.io.PrintWriter; import java.io.StringWriter; -import scouter.lang.conf.ConfObserver; -import scouter.lang.conf.ConfigValueUtil; import scouter.util.CompareUtil; import scouter.util.DateUtil; import scouter.util.FileUtil; @@ -77,7 +75,7 @@ public static String getCallStack(Throwable t) { } private static boolean checkOk(String id, int sec) { - if (Configure.getInstance().log_ignore_set.hasKey(id)) + if (Configure.getInstance().isIgnoreLog(id)) return false; if (sec > 0) { long last = lastLog.get(id); @@ -112,8 +110,8 @@ private static void println(String msg, boolean sysout) { } private static synchronized void openFile(String prefix) throws IOException { - if (pw == null && StringUtil.isEmpty(conf.logs_dir) == false) { - File root = new File(conf.logs_dir); + if (pw == null && StringUtil.isEmpty(conf.log_dir) == false) { + File root = new File(conf.log_dir); if (root.canWrite() == false) { root.mkdirs(); } @@ -121,13 +119,13 @@ private static synchronized void openFile(String prefix) throws IOException { return; } - if (conf.log_rotation) { - File file = new File(conf.logs_dir, "scouter-" + prefix + "-" + DateUtil.yyyymmdd() + ".log"); + if (conf.log_rotation_enabled) { + File file = new File(conf.log_dir, "scouter-" + prefix + "-" + DateUtil.yyyymmdd() + ".log"); FileWriter fw = new FileWriter(file, true); pw = new PrintWriter(fw); logfile = file; } else { - File file = new File(conf.logs_dir, "scouter-" + prefix + ".log"); + File file = new File(conf.log_dir, "scouter-" + prefix + ".log"); pw = new PrintWriter(new FileWriter(file, true)); logfile = file; } @@ -139,11 +137,10 @@ private static synchronized void openFile(String prefix) throws IOException { static Runnable initializer = new Runnable() { long last = System.currentTimeMillis(); long lastDataUnit = DateUtil.getDateUnit(); - String lastDir = conf.logs_dir; - boolean lastFileRotation = conf.log_rotation; + String lastDir = conf.log_dir; + boolean lastFileRotation = conf.log_rotation_enabled; String scouter_name = "boot"; - @Override public void run() { try { process(); @@ -158,17 +155,17 @@ private synchronized void process() { clearOldLog(); } - if (CompareUtil.equals(lastDir, conf.logs_dir) == false // - || lastFileRotation != conf.log_rotation // + if (CompareUtil.equals(lastDir, conf.log_dir) == false // + || lastFileRotation != conf.log_rotation_enabled // || lastDataUnit != DateUtil.getDateUnit() // - || scouter_name.equals(conf.scouter_name) == false// + || scouter_name.equals(conf.obj_name) == false// || (logfile != null && logfile.exists() == false)) { pw = (PrintWriter) FileUtil.close(pw); logfile = null; - lastDir = conf.logs_dir; - lastFileRotation = conf.log_rotation; + lastDir = conf.log_dir; + lastFileRotation = conf.log_rotation_enabled; lastDataUnit = DateUtil.getDateUnit(); - scouter_name = conf.scouter_name; + scouter_name = conf.obj_name; } try { @@ -180,13 +177,13 @@ private synchronized void process() { }; protected static void clearOldLog() { - if (conf.log_rotation == false) + if (conf.log_rotation_enabled == false) return; - if (conf.log_keep_dates <= 0) + if (conf.log_keep_days <= 0) return; - String scouter_prefix = "scouter-" + conf.scouter_name; + String scouter_prefix = "scouter-" + conf.obj_name; long nowUnit = DateUtil.getDateUnit(); - File dir = new File(conf.logs_dir); + File dir = new File(conf.log_dir); File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) @@ -204,7 +201,7 @@ protected static void clearOldLog() { try { long d = DateUtil.yyyymmdd(date); long fileUnit = DateUtil.getDateUnit(d); - if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_dates) { + if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_days) { files[i].delete(); } } catch (Exception e) { diff --git a/scouter.agent.java/src/scouter/agent/asm/AddFieldASM.java b/scouter.agent.java/src/scouter/agent/asm/AddFieldASM.java index 35943ab0a..9de789d29 100644 --- a/scouter.agent.java/src/scouter/agent/asm/AddFieldASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/AddFieldASM.java @@ -25,7 +25,7 @@ import scouter.org.objectweb.asm.Opcodes; import scouter.org.objectweb.asm.Type; public class AddFieldASM implements IASM, Opcodes { - public final Map target = HookingSet.getClassFieldSet(Configure.getInstance().hook_add_field); + public final Map target = HookingSet.getClassFieldSet(Configure.getInstance().hook_add_fields); public AddFieldASM() { } public boolean isTarget(String className) { @@ -33,6 +33,9 @@ public boolean isTarget(String className) { } Configure conf = Configure.getInstance(); public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { + if (Configure.getInstance()._hook_async_enabled == false) { + return cv; + } String field = target.get(className); if (field != null) { return new AddFieldCV(cv, className, field); diff --git a/scouter.agent.java/src/scouter/agent/asm/ApicallASM.java b/scouter.agent.java/src/scouter/agent/asm/ApicallASM.java index dd238bbdd..1a24192a2 100644 --- a/scouter.agent.java/src/scouter/agent/asm/ApicallASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/ApicallASM.java @@ -31,7 +31,7 @@ import scouter.org.objectweb.asm.Type; import scouter.org.objectweb.asm.commons.LocalVariablesSorter; public class ApicallASM implements IASM, Opcodes { - private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_apicall); + private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_apicall_patterns); private Map reserved = new HashMap(); public ApicallASM() { AsmUtil.add(reserved, "sun/net/www/protocol/http/HttpURLConnection", "getInputStream()Ljava/io/InputStream;"); @@ -66,6 +66,9 @@ public boolean isTarget(String className) { return false; } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { + if (Configure.getInstance()._hook_methods_enabled == false) { + return cv; + } HookingSet mset = reserved.get(className); if (mset != null) return new ApicallExtCV(cv, mset, className); diff --git a/scouter.agent.java/src/scouter/agent/asm/ApicallInfoASM.java b/scouter.agent.java/src/scouter/agent/asm/ApicallInfoASM.java index cad8638f9..7fcaf7371 100644 --- a/scouter.agent.java/src/scouter/agent/asm/ApicallInfoASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/ApicallInfoASM.java @@ -30,7 +30,7 @@ import scouter.org.objectweb.asm.Type; import scouter.org.objectweb.asm.commons.LocalVariablesSorter; public class ApicallInfoASM implements IASM, Opcodes { - private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_apicall_info); + private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_apicall_info_patterns); private Map reserved = new HashMap(); public ApicallInfoASM() { AsmUtil.add(reserved, "io/reactivex/netty/protocol/http/client/HttpClientRequest", "setDynamicUriParts"); @@ -50,6 +50,9 @@ public boolean isTarget(String className) { return false; } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { + if (Configure.getInstance()._hook_methods_enabled == false) { + return cv; + } HookingSet mset = reserved.get(className); if (mset != null) return new ApicallInfoCV(cv, mset, className); diff --git a/scouter.agent.java/src/scouter/agent/asm/CapArgsASM.java b/scouter.agent.java/src/scouter/agent/asm/CapArgsASM.java index e01f8e200..9cf6f5651 100644 --- a/scouter.agent.java/src/scouter/agent/asm/CapArgsASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/CapArgsASM.java @@ -31,7 +31,7 @@ import scouter.org.objectweb.asm.commons.LocalVariablesSorter; public class CapArgsASM implements IASM, Opcodes { - private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_args); + private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_args_patterns); public boolean isTarget(String className) { for (int i = 0; i < target.size(); i++) { @@ -44,7 +44,9 @@ public boolean isTarget(String className) { } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - + if (Configure.getInstance()._hook_cap_enabled == false) { + return cv; + } for (int i = 0; i < target.size(); i++) { HookingSet mset = target.get(i); if (mset.classMatch.include(className)) { diff --git a/scouter.agent.java/src/scouter/agent/asm/CapReturnASM.java b/scouter.agent.java/src/scouter/agent/asm/CapReturnASM.java index 57ba67869..f089bc9ce 100644 --- a/scouter.agent.java/src/scouter/agent/asm/CapReturnASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/CapReturnASM.java @@ -32,7 +32,7 @@ public class CapReturnASM implements IASM, Opcodes { - private List< HookingSet> target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_return); + private List< HookingSet> target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_return_patterns); public boolean isTarget(String className) { @@ -45,7 +45,9 @@ public boolean isTarget(String className) { return false; } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - + if (Configure.getInstance()._hook_cap_enabled == false) { + return cv; + } for (int i = 0; i < target.size(); i++) { HookingSet mset = target.get(i); if (mset.classMatch.include(className)) { diff --git a/scouter.agent.java/src/scouter/agent/asm/CapThisASM.java b/scouter.agent.java/src/scouter/agent/asm/CapThisASM.java index e968c7850..364ca78f4 100644 --- a/scouter.agent.java/src/scouter/agent/asm/CapThisASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/CapThisASM.java @@ -29,7 +29,7 @@ import scouter.org.objectweb.asm.Opcodes; public class CapThisASM implements IASM, Opcodes { - private List< HookingSet> target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_init); + private List< HookingSet> target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_constructor_patterns); public boolean isTarget(String className) { @@ -42,7 +42,9 @@ public boolean isTarget(String className) { return false; } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - + if (Configure.getInstance()._hook_cap_enabled == false) { + return cv; + } for (int i = 0; i < target.size(); i++) { HookingSet mset = target.get(i); if (mset.classMatch.include(className)) { diff --git a/scouter.agent.java/src/scouter/agent/asm/HttpServiceASM.java b/scouter.agent.java/src/scouter/agent/asm/HttpServiceASM.java index 5a396fb01..87cb967b1 100644 --- a/scouter.agent.java/src/scouter/agent/asm/HttpServiceASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/HttpServiceASM.java @@ -17,6 +17,7 @@ package scouter.agent.asm; import java.util.HashSet; import scouter.agent.ClassDesc; +import scouter.agent.Configure; import scouter.agent.Logger; import scouter.agent.trace.TraceMain; import scouter.org.objectweb.asm.ClassVisitor; @@ -37,6 +38,9 @@ public boolean isTarget(String className) { return false; } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { + if (Configure.getInstance()._hook_serivce_enabled == false) { + return cv; + } if (servlets.contains(className)) { return new HttpServiceCV(cv, className); } diff --git a/scouter.agent.java/src/scouter/agent/asm/InitialContextASM.java b/scouter.agent.java/src/scouter/agent/asm/InitialContextASM.java index d2522fcc6..790c8d18c 100644 --- a/scouter.agent.java/src/scouter/agent/asm/InitialContextASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/InitialContextASM.java @@ -31,14 +31,16 @@ import scouter.org.objectweb.asm.commons.LocalVariablesSorter; public class InitialContextASM implements IASM, Opcodes { - private Set target = HookingSet.getClassSet(Configure.getInstance().hook_context); + private Set target = HookingSet.getClassSet(Configure.getInstance().hook_context_classes); public boolean isTarget(String className) { return target.contains(className); } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - + if (Configure.getInstance()._hook_dbconn_enabled == false) { + return cv; + } if (target.contains(className)) { return new InitialContextCV(cv, className); } diff --git a/scouter.agent.java/src/scouter/agent/asm/JDBCConnectionOpenASM.java b/scouter.agent.java/src/scouter/agent/asm/JDBCConnectionOpenASM.java index d1d058367..b81482179 100644 --- a/scouter.agent.java/src/scouter/agent/asm/JDBCConnectionOpenASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/JDBCConnectionOpenASM.java @@ -36,7 +36,7 @@ import scouter.util.StringUtil; public class JDBCConnectionOpenASM implements IASM, Opcodes { - private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_connection_open); + private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_connection_open_patterns); private Map reserved = new HashMap(); public JDBCConnectionOpenASM() { @@ -61,9 +61,9 @@ public boolean isTarget(String className) { } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - if (Configure.getInstance().enable_asm_jdbc == false) + if (Configure.getInstance()._hook_dbconn_enabled == false) { return cv; - + } HookingSet mset = reserved.get(className); if (mset != null) return new DbcOpenCV(cv, mset, className); diff --git a/scouter.agent.java/src/scouter/agent/asm/JDBCDriverASM.java b/scouter.agent.java/src/scouter/agent/asm/JDBCDriverASM.java index a50f97aed..5b85da4dd 100644 --- a/scouter.agent.java/src/scouter/agent/asm/JDBCDriverASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/JDBCDriverASM.java @@ -30,7 +30,7 @@ import scouter.org.objectweb.asm.commons.LocalVariablesSorter; public class JDBCDriverASM implements IASM, Opcodes { //user can define driver.connect() - private Map reserved =HookingSet.getHookingSet(Configure.getInstance().hook_driver_connect_wrapper); + private Map reserved =HookingSet.getHookingSet(Configure.getInstance().hook_jdbc_wrapping_driver_patterns); public JDBCDriverASM() { AsmUtil.add(reserved, "com/ibm/db2/jcc/DB2Driver", "connect(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;"); } @@ -42,8 +42,9 @@ public boolean isTarget(String className) { return false; } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - if(Configure.getInstance().enable_asm_jdbc==false) + if (Configure.getInstance()._hook_dbconn_enabled == false) { return cv; + } HookingSet mset = reserved.get(className); if (mset != null){ return new JDBCDriverCV(cv, mset, className); diff --git a/scouter.agent.java/src/scouter/agent/asm/JDBCPreparedStatementASM.java b/scouter.agent.java/src/scouter/agent/asm/JDBCPreparedStatementASM.java index 8b7cb1b72..6e0db6b7f 100644 --- a/scouter.agent.java/src/scouter/agent/asm/JDBCPreparedStatementASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/JDBCPreparedStatementASM.java @@ -32,7 +32,7 @@ import scouter.org.objectweb.asm.Opcodes; import scouter.org.objectweb.asm.Type; public class JDBCPreparedStatementASM implements IASM, Opcodes { - public final HashSet target = HookingSet.getHookingClassSet(Configure.getInstance().hook_jdbc_pstmt); + public final HashSet target = HookingSet.getHookingClassSet(Configure.getInstance().hook_jdbc_pstmt_classes); public final HashSet noField = new HashSet(); public JDBCPreparedStatementASM() { target.add("org/mariadb/jdbc/MySQLPreparedStatement"); @@ -55,11 +55,12 @@ public boolean isTarget(String className) { return target.contains(className); } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - if (target.contains(className) == false) { + if (Configure.getInstance()._hook_dbsql_enabled == false) { return cv; } - if (Configure.getInstance().enable_asm_jdbc == false) + if (target.contains(className) == false) { return cv; + } Logger.println("A106", "jdbc pstmt found: " + className); return new PreparedStatementCV(cv, noField); } diff --git a/scouter.agent.java/src/scouter/agent/asm/JDBCResultSetASM.java b/scouter.agent.java/src/scouter/agent/asm/JDBCResultSetASM.java index 492883829..dcc4c9277 100644 --- a/scouter.agent.java/src/scouter/agent/asm/JDBCResultSetASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/JDBCResultSetASM.java @@ -26,7 +26,7 @@ import scouter.org.objectweb.asm.MethodVisitor; import scouter.org.objectweb.asm.Opcodes; public class JDBCResultSetASM implements IASM, Opcodes { - public final HashSet target = HookingSet.getHookingClassSet(Configure.getInstance().hook_jdbc_rs); + public final HashSet target = HookingSet.getHookingClassSet(Configure.getInstance().hook_jdbc_rs_classes); public JDBCResultSetASM() { target.add("org/mariadb/jdbc/MySQLResultSet"); target.add("oracle/jdbc/driver/OracleResultSetImpl"); @@ -45,11 +45,12 @@ public boolean isTarget(String className) { return target.contains(className); } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - if (target.contains(className) == false) { + if (Configure.getInstance()._hook_dbsql_enabled == false) { return cv; } - if (Configure.getInstance().enable_asm_jdbc == false) + if (target.contains(className) == false) { return cv; + } Logger.println("A107", "jdbc rs found: " + className); return new ResultSetCV(cv); } diff --git a/scouter.agent.java/src/scouter/agent/asm/JDBCStatementASM.java b/scouter.agent.java/src/scouter/agent/asm/JDBCStatementASM.java index 507d1f577..834e4abd5 100644 --- a/scouter.agent.java/src/scouter/agent/asm/JDBCStatementASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/JDBCStatementASM.java @@ -25,7 +25,7 @@ import scouter.org.objectweb.asm.MethodVisitor; import scouter.org.objectweb.asm.Opcodes; public class JDBCStatementASM implements IASM, Opcodes { - public final HashSet target = HookingSet.getHookingClassSet(Configure.getInstance().hook_jdbc_stmt); + public final HashSet target = HookingSet.getHookingClassSet(Configure.getInstance().hook_jdbc_stmt_classes); public JDBCStatementASM() { target.add("org/mariadb/jdbc/MySQLStatement"); @@ -42,11 +42,12 @@ public boolean isTarget(String className) { return target.contains(className) ; } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - if (target.contains(className) == false) { + if (Configure.getInstance()._hook_dbsql_enabled == false) { return cv; } - if(Configure.getInstance().enable_asm_jdbc==false) + if (target.contains(className) == false) { return cv; + } Logger.println("A108", "jdbc stmt found: " + className); return new StatementCV(cv); } diff --git a/scouter.agent.java/src/scouter/agent/asm/JspServletASM.java b/scouter.agent.java/src/scouter/agent/asm/JspServletASM.java index e59270b61..48f34b55b 100644 --- a/scouter.agent.java/src/scouter/agent/asm/JspServletASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/JspServletASM.java @@ -31,7 +31,7 @@ import scouter.org.objectweb.asm.commons.LocalVariablesSorter; public class JspServletASM implements IASM, Opcodes { - private Map target = HookingSet.getHookingSet(Configure.getInstance().hook_jsp); + private Map target = HookingSet.getHookingSet(Configure.getInstance().hook_jsp_patterns); public JspServletASM() { AsmUtil.add(target, "org/apache/jasper/servlet/JspServlet", "serviceJspFile"); @@ -42,7 +42,9 @@ public boolean isTarget(String className) { } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - + if (Configure.getInstance()._hook_jsp_enabled == false) { + return cv; + } HookingSet mset = target.get(className); if (mset == null) return cv; diff --git a/scouter.agent.java/src/scouter/agent/asm/MethodASM.java b/scouter.agent.java/src/scouter/agent/asm/MethodASM.java index 1d15e9734..ed6137cf4 100644 --- a/scouter.agent.java/src/scouter/agent/asm/MethodASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/MethodASM.java @@ -34,7 +34,7 @@ public class MethodASM implements IASM, Opcodes { - private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_method); + private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_method_patterns); public boolean isTarget(String className) { if (target.size() == 0) @@ -52,6 +52,9 @@ public boolean isTarget(String className) { Configure conf = Configure.getInstance(); public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { + if (conf._hook_methods_enabled == false) { + return cv; + } if (target.size() == 0) return cv; @@ -90,10 +93,10 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si } Configure conf = Configure.getInstance(); - boolean isPublic = conf.hook_method_access_public; - boolean isProtected = conf.hook_method_access_protected; - boolean isPrivate = conf.hook_method_access_private; - boolean isNone = conf.hook_method_access_none; + boolean isPublic = conf.hook_method_access_public_enabled; + boolean isProtected = conf.hook_method_access_protected_enabled; + boolean isPrivate = conf.hook_method_access_private_enabled; + boolean isNone = conf.hook_method_access_none_enabled; switch (access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE)) { case Opcodes.ACC_PUBLIC: if (isPublic == false) diff --git a/scouter.agent.java/src/scouter/agent/asm/ServiceASM.java b/scouter.agent.java/src/scouter/agent/asm/ServiceASM.java index 41245372a..79778289c 100644 --- a/scouter.agent.java/src/scouter/agent/asm/ServiceASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/ServiceASM.java @@ -33,7 +33,7 @@ import scouter.org.objectweb.asm.commons.LocalVariablesSorter; public class ServiceASM implements IASM, Opcodes { - private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_service); + private List target = HookingSet.getHookingMethodSet(Configure.getInstance().hook_service_patterns); public ServiceASM() { } @@ -50,7 +50,9 @@ public boolean isTarget(String className) { } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - + if (Configure.getInstance()._hook_serivce_enabled == false) { + return cv; + } for (int i = 0; i < target.size(); i++) { HookingSet mset = target.get(i); if (mset.classMatch.include(className)) { diff --git a/scouter.agent.java/src/scouter/agent/asm/SocketASM.java b/scouter.agent.java/src/scouter/agent/asm/SocketASM.java index 845df4e09..a3501c826 100644 --- a/scouter.agent.java/src/scouter/agent/asm/SocketASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/SocketASM.java @@ -42,10 +42,11 @@ public boolean isTarget(String className) { return reserved.containsKey(className); } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { + if (Configure.getInstance()._hook_socket_enabled == false) { + return cv; + } HookingSet mset = reserved.get(className); if (mset != null){ - if(Configure.getInstance().enable_asm_socket==false) - return cv; return new SocketCV(cv, mset, className); } return cv; diff --git a/scouter.agent.java/src/scouter/agent/asm/SpringReqMapASM.java b/scouter.agent.java/src/scouter/agent/asm/SpringReqMapASM.java index c8b8cf238..751e3bc87 100644 --- a/scouter.agent.java/src/scouter/agent/asm/SpringReqMapASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/SpringReqMapASM.java @@ -34,7 +34,7 @@ public boolean isTarget(String className) { } Configure conf = Configure.getInstance(); public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - if (conf.hook_spring_request_mapping == false) + if (conf._hook_spring_rest_enabled == false) return cv; if (classDesc.anotation != null) { for (int i = 0; i < SpringReqMapASM.springControllerNames.length; i++) { diff --git a/scouter.agent.java/src/scouter/agent/asm/SqlMapASM.java b/scouter.agent.java/src/scouter/agent/asm/SqlMapASM.java index 0c80a99eb..6f5d28635 100644 --- a/scouter.agent.java/src/scouter/agent/asm/SqlMapASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/SqlMapASM.java @@ -21,6 +21,7 @@ import java.util.Set; import scouter.agent.ClassDesc; +import scouter.agent.Configure; import scouter.agent.asm.util.AsmUtil; import scouter.agent.trace.TraceSQL; import scouter.org.objectweb.asm.ClassVisitor; @@ -54,7 +55,9 @@ public boolean isTarget(String className) { } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - + if (Configure.getInstance()._hook_dbsql_enabled == false) { + return cv; + } for (int i = 0; i < classDesc.interfaces.length; i++) { for (int j = 0; j < targetInf.length; j++) { if (targetInf[j].equals(classDesc.interfaces[i])) { diff --git a/scouter.agent.java/src/scouter/agent/asm/UserTxASM.java b/scouter.agent.java/src/scouter/agent/asm/UserTxASM.java index 1cfc3291f..03d5dba1b 100644 --- a/scouter.agent.java/src/scouter/agent/asm/UserTxASM.java +++ b/scouter.agent.java/src/scouter/agent/asm/UserTxASM.java @@ -36,7 +36,7 @@ public boolean isTarget(String className) { } public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) { - if (Configure.getInstance().enable_usertx == false) + if (Configure.getInstance()._hook_usertx_enabled == false) return cv; for (int i = 0; i < classDesc.interfaces.length; i++) { diff --git a/scouter.agent.java/src/scouter/agent/counter/CounterBasket.java b/scouter.agent.java/src/scouter/agent/counter/CounterBasket.java index cf41bc7fd..537a73b6f 100644 --- a/scouter.agent.java/src/scouter/agent/counter/CounterBasket.java +++ b/scouter.agent.java/src/scouter/agent/counter/CounterBasket.java @@ -66,7 +66,7 @@ public PerfCounterPack getPack(String objName, byte timeType) { } public PerfCounterPack getPack(byte timeType) { - return getPack(Configure.getInstance().objName, timeType); + return getPack(Configure.getInstance().getObjName(), timeType); } public PerfCounterPack[] getList() { diff --git a/scouter.agent.java/src/scouter/agent/counter/CounterExecutingManager.java b/scouter.agent.java/src/scouter/agent/counter/CounterExecutingManager.java index 767bcde0c..be6acc410 100644 --- a/scouter.agent.java/src/scouter/agent/counter/CounterExecutingManager.java +++ b/scouter.agent.java/src/scouter/agent/counter/CounterExecutingManager.java @@ -24,7 +24,6 @@ import scouter.agent.Configure; import scouter.agent.Logger; import scouter.agent.counter.anotation.Counter; -import scouter.agent.counter.task.HeapUsage; import scouter.agent.netio.data.DataProxy; import scouter.lang.pack.PerfCounterPack; import scouter.util.ThreadUtil; @@ -45,7 +44,7 @@ public final static synchronized CounterExecutingManager getInstance() { public void run() { while (true) { ThreadUtil.sleep(1000); - if (conf.enable_counter_task == false) { + if (conf.counter_enabled == false) { continue; } long now = System.currentTimeMillis(); diff --git a/scouter.agent.java/src/scouter/agent/counter/meter/MeterUsers.java b/scouter.agent.java/src/scouter/agent/counter/meter/MeterUsers.java index 46b8cc3aa..162b31d2a 100644 --- a/scouter.agent.java/src/scouter/agent/counter/meter/MeterUsers.java +++ b/scouter.agent.java/src/scouter/agent/counter/meter/MeterUsers.java @@ -1,26 +1,25 @@ -/* - * Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package scouter.agent.counter.meter; -import java.util.Enumeration; -import scouter.agent.Configure; -import scouter.agent.Logger; -import scouter.util.DateUtil; -import scouter.util.LongLongLinkedMap; +import java.util.Enumeration; +import scouter.agent.Configure; +import scouter.agent.Logger; +import scouter.util.LongLongLinkedMap; public class MeterUsers { @@ -36,8 +35,8 @@ public static void add(long userid) { } } - public synchronized static int getUsers() { - long max_think_time=Configure.getInstance().max_think_time; + public synchronized static int getUsers() { + long max_think_time=Configure.getInstance().counter_recentuser_valid_ms; int v = 0; long now = System.currentTimeMillis(); try { @@ -69,4 +68,4 @@ public static void main(String[] args) throws InterruptedException { Thread.sleep(1000); System.out.println(getUsers()); } -} +} diff --git a/scouter.agent.java/src/scouter/agent/counter/task/AgentHeartBeat.java b/scouter.agent.java/src/scouter/agent/counter/task/AgentHeartBeat.java index 996e338c3..6da4e915d 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/AgentHeartBeat.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/AgentHeartBeat.java @@ -16,7 +16,6 @@ */ package scouter.agent.counter.task; import java.io.File; -import java.io.FileOutputStream; import java.util.Enumeration; import scouter.Version; import scouter.agent.Configure; @@ -33,14 +32,14 @@ import scouter.util.SysJMX; public class AgentHeartBeat { static { - Logger.println("objType:" + Configure.getInstance().scouter_type); - Logger.println("objName:" + Configure.getInstance().objName); + Logger.println("objType:" + Configure.getInstance().obj_type); + Logger.println("objName:" + Configure.getInstance().getObjName()); } private static StringKeyLinkedMap objects = new StringKeyLinkedMap(); public static void addObject(String objType, int objHash, String objName) { if (objName == null) return; - if (objName.equals(Configure.getInstance().objName)) + if (objName.equals(Configure.getInstance().getObjName())) return; ObjectPack old = objects.get(objName); if (old != null && objType.equals(old.objType)) { @@ -63,9 +62,9 @@ public void alive(CounterBasket pw) { private ObjectPack getMainObject() { Configure conf = Configure.getInstance(); ObjectPack p = new ObjectPack(); - p.objType = conf.scouter_type; - p.objHash = conf.objHash; - p.objName = conf.objName; + p.objType = conf.obj_type; + p.objHash = conf.getObjHash(); + p.objName = conf.getObjName(); p.version = Version.getAgentFullVersion(); p.address = TcpWorker.localAddr; if (ToolsMainFactory.activeStack) { @@ -81,10 +80,10 @@ public void regist(CounterBasket pw) { Configure conf = Configure.getInstance(); try { int pid = SysJMX.getProcessPID(); - File dir = new File(conf.object_registry); + File dir = new File(conf.counter_object_registry_path); File file = new File(dir, pid + ".scouter"); if (dir.canWrite()) { - FileUtil.save(file, conf.objName.getBytes()); + FileUtil.save(file, conf.getObjName().getBytes()); } } catch (Exception e) { e.printStackTrace(); diff --git a/scouter.agent.java/src/scouter/agent/counter/task/Debug.java b/scouter.agent.java/src/scouter/agent/counter/task/Debug.java index 12d0a2015..bb7874571 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/Debug.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/Debug.java @@ -19,7 +19,7 @@ public class Debug { @Counter public void autoStack(CounterBasket pw) { Configure conf = Configure.getInstance(); - if (conf.debug_long_tx_autostack <= 0) + if (conf.autodump_stuck_thread_ms <= 0) return; PrintWriter out = null; try { @@ -27,7 +27,7 @@ public void autoStack(CounterBasket pw) { while (en.hasMoreElements()) { TraceContext ctx = en.nextElement(); long etime = System.currentTimeMillis() - ctx.startTime; - if (etime > conf.debug_long_tx_autostack) { + if (etime > conf.autodump_stuck_thread_ms) { try { if (out == null) { out = open(); @@ -64,7 +64,7 @@ public void autoStack(CounterBasket pw) { } } public PrintWriter open() throws IOException { - File file = new File(Configure.getInstance().dump_dir, "longtx_" +Configure.getInstance().scouter_name+ "_"+DateUtil.timestampFileName()+".txt"); + File file = new File(Configure.getInstance().mgr_dump_dir, "longtx_" +Configure.getInstance().obj_name + "_"+DateUtil.timestampFileName()+".txt"); return new PrintWriter(new FileWriter(file)); } } diff --git a/scouter.agent.java/src/scouter/agent/counter/task/HostPerf.java b/scouter.agent.java/src/scouter/agent/counter/task/HostPerf.java index 737df7d2d..c2718e364 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/HostPerf.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/HostPerf.java @@ -38,10 +38,10 @@ public void cpuLoad(CounterBasket pw) { } private void process(CounterBasket pw) { Configure conf = Configure.getInstance(); - if (conf.enable_host_agent == false) + if (conf.obj_host_enabled == false) return; com.sun.management.OperatingSystemMXBean osm = (com.sun.management.OperatingSystemMXBean) osmxbean; - AgentHeartBeat.addObject(conf.objhost_type, conf.objHostHash, conf.objHostName); + AgentHeartBeat.addObject(conf.obj_host_type, conf.getObjHostHash(), conf.getObjHostName()); float cpu = (float) osm.getSystemLoadAverage(); if (cpu <= 0) { cpu = 0; @@ -53,14 +53,14 @@ private void process(CounterBasket pw) { long tswap = osm.getTotalSwapSpaceSize(); long fswap = osm.getFreeSwapSpaceSize(); long uswap = tswap - fswap; - PerfCounterPack p = pw.getPack(conf.objHostName, TimeTypeEnum.REALTIME); + PerfCounterPack p = pw.getPack(conf.getObjHostName(), TimeTypeEnum.REALTIME); p.put(CounterConstants.HOST_CPU, new FloatValue(cpu)); p.put(CounterConstants.HOST_MEM_TOTAL, new DecimalValue(tmem / 1024 / 1024)); p.put(CounterConstants.HOST_MEM_USED, new DecimalValue(umem / 1024 / 1024)); p.put(CounterConstants.HOST_MEM_AVALIABLE, new DecimalValue(fmem / 1024 / 1024)); p.put(CounterConstants.HOST_SWAP_TOTAL, new DecimalValue(tswap / 1024 / 1024)); p.put(CounterConstants.HOST_SWAP_USED, new DecimalValue(uswap / 1024 / 1024)); - p = pw.getPack(conf.objHostName, TimeTypeEnum.FIVE_MIN); + p = pw.getPack(conf.getObjHostName(), TimeTypeEnum.FIVE_MIN); p.put(CounterConstants.HOST_CPU, new FloatValue((float) cpuLoad.getSum(300))); // 단순히 메모리는 평균이 큰 의미가 없음으로 평균을 계산하지 않는다. p.put(CounterConstants.HOST_MEM_TOTAL, new DecimalValue(tmem / 1024 / 1024)); diff --git a/scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java b/scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java index 1369aae16..3e4584336 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/JBossJMXPerf.java @@ -33,8 +33,6 @@ 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; @@ -169,15 +167,15 @@ private void getMBeanServer() { Configure conf = Configure.getInstance(); private String getDataSourceType() { - if (conf.enable_plus_objtype) { - return conf.scouter_type + "_ds"; + if (conf.obj_type_inherit_to_child_enabled) { + return conf.obj_type + "_ds"; } return CounterConstants.DATASOURCE; } private String getReqProcType() { - if (conf.enable_plus_objtype) { - return conf.scouter_type + "_req"; + if (conf.obj_type_inherit_to_child_enabled) { + return conf.obj_type + "_req"; } return CounterConstants.REQUESTPROCESS; } @@ -197,7 +195,7 @@ private void getContextList() { String name = mbean.getKeyProperty("data-source"); if (StringUtil.isNotEmpty(name)) { try { - String objName = conf.objName + "/" + checkObjName(name); + String objName = conf.getObjName() + "/" + checkObjName(name); String objType = getDataSourceType(); AgentHeartBeat.addObject(objType, HashUtil.hash(objName), objName); @@ -216,7 +214,7 @@ private void getContextList() { continue; } try { - String objName = conf.objName + "/" + checkObjName(connector); + String objName = conf.getObjName() + "/" + checkObjName(connector); String objType = getReqProcType(); AgentHeartBeat.addObject(objType, HashUtil.hash(objName), objName); diff --git a/scouter.agent.java/src/scouter/agent/counter/task/MakeStack.java b/scouter.agent.java/src/scouter/agent/counter/task/MakeStack.java index 00b16c579..13761a8ea 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/MakeStack.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/MakeStack.java @@ -36,7 +36,7 @@ public void make(CounterBasket pw) { StackPack p = new StackPack(); p.time = System.currentTimeMillis(); - p.objHash = Configure.getInstance().objHash; + p.objHash = Configure.getInstance().getObjHash(); p.setStack(stack); DataProxy.sendDirect(p); @@ -47,6 +47,6 @@ private boolean isPStackEnabled() { return Configure.getInstance().sfa_dump_enabled || System.currentTimeMillis() < pstack_requested; } private long getInterval() { - return Configure.getInstance().sfa_dump_interval; + return Configure.getInstance().sfa_dump_interval_ms; } } diff --git a/scouter.agent.java/src/scouter/agent/counter/task/PermGen.java b/scouter.agent.java/src/scouter/agent/counter/task/PermGen.java index 02e200962..d769269dd 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/PermGen.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/PermGen.java @@ -70,8 +70,8 @@ public void getPermGen(CounterBasket pw) { // ///////////////////////////////////////////////// // PermGen Warning - if (rate >= conf.heap_perm_warning_pct) { - if (now >= heap_perm_last_warning + conf.heap_perm_alert_interval) { + if (rate >= conf.alert_perm_warning_pct) { + if (now >= heap_perm_last_warning + conf.alert_perm_interval_ms) { DataProxy.sendAlert(AlertLevel.WARN, "WARNING_MEMORY_HIGH", "warning perm usage used=" + (used / 1024 / 1024) + "MB rate=" + rate + "%", null); heap_perm_last_warning = now; 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 f41cc7b46..340ceec0f 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/ServicePerf.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/ServicePerf.java @@ -53,7 +53,7 @@ public void getServicePerf(CounterBasket pw) { int[] act = TraceContextManager.getActiveCount(); int active = act[0] + act[1] + act[2]; - if (conf.auto_dump_trigger <= active) { + if (conf.autodump_trigger_active_service_cnt <= active) { DumpUtil.autoDump(); } activeCounter.add(active); diff --git a/scouter.agent.java/src/scouter/agent/counter/task/TomcatJMXPerf.java b/scouter.agent.java/src/scouter/agent/counter/task/TomcatJMXPerf.java index 246e5d3a2..8a963df75 100644 --- a/scouter.agent.java/src/scouter/agent/counter/task/TomcatJMXPerf.java +++ b/scouter.agent.java/src/scouter/agent/counter/task/TomcatJMXPerf.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Set; import javax.management.MBeanServer; @@ -165,7 +164,7 @@ private void getContextList() { if ("GlobalRequestProcessor".equals(type)) { String port = mbean.getKeyProperty("name"); try { - String objName = conf.objName + "/" + checkObjName(port); + String objName = conf.getObjName() + "/" + checkObjName(port); String objType = getReqProcType(); AgentHeartBeat.addObject(objType, HashUtil.hash(objName), objName); add(objName, mbean, objType, ValueEnum.DECIMAL, "bytesReceived", @@ -184,7 +183,7 @@ private void getContextList() { String name = mbean.getKeyProperty("name"); if (StringUtil.isNotEmpty(name)) { try { - String objName = conf.objName + "/" + checkObjName(name); + String objName = conf.getObjName() + "/" + checkObjName(name); String objType = getDataSourceType(); AgentHeartBeat.addObject(objType, HashUtil.hash(objName), objName); add(objName, mbean, objType, ValueEnum.DECIMAL, "numActive", @@ -198,14 +197,14 @@ private void getContextList() { } } private String getReqProcType() { - if (Configure.getInstance().enable_plus_objtype) { - return Configure.getInstance().scouter_type + "_req"; + if (Configure.getInstance().obj_type_inherit_to_child_enabled) { + return Configure.getInstance().obj_type + "_req"; } return CounterConstants.REQUESTPROCESS; } private String getDataSourceType() { - if (Configure.getInstance().enable_plus_objtype) { - return Configure.getInstance().scouter_type + "_ds"; + if (Configure.getInstance().obj_type_inherit_to_child_enabled) { + return Configure.getInstance().obj_type + "_ds"; } return CounterConstants.DATASOURCE; } 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 3da7df128..34fdacbf2 100644 --- a/scouter.agent.java/src/scouter/agent/netio/data/DataProxy.java +++ b/scouter.agent.java/src/scouter/agent/netio/data/DataProxy.java @@ -119,8 +119,8 @@ public static int sendApicall( String name) { static Configure conf = Configure.getInstance(); public static void sendAlert(byte level, String title, String message, MapValue tags) { AlertPack p = new AlertPack(); - p.objType = conf.scouter_type; - p.objHash = conf.objHash; + p.objType = conf.obj_type; + p.objHash = conf.getObjHash(); p.level = level; p.title = title; p.message = message; @@ -167,15 +167,15 @@ public static void reset() { sqlText.clear(); } public static void sendXLog(XLogPack p) { - p.objHash = conf.objHash; + p.objHash = conf.getObjHash(); sendDirect(p); - if (conf.debug_udp_xlog) { + if (conf.log_udp_xlog_enabled) { Logger.println(p.toString()); } } public static void send(SummaryPack p) { - p.objHash = conf.objHash; - p.objType = conf.scouter_type; + p.objHash = conf.getObjHash(); + p.objType = conf.obj_type; sendDirect(p); } static DataUdpAgent udpNet = DataUdpAgent.getInstance(); @@ -202,7 +202,7 @@ public static void sendProfile(Step[] p, TraceContext x) { return; XLogProfilePack pk = new XLogProfilePack(); pk.txid = x.txid; - pk.objHash = conf.objHash; + pk.objHash = conf.getObjHash(); pk.profile = Step.toBytes(p); pk.service = x.serviceHash; pk.elapsed = (int) (System.currentTimeMillis() - x.startTime); @@ -213,7 +213,7 @@ public static void sendProfile(List p, TraceContext x) { return; XLogProfilePack pk = new XLogProfilePack(); pk.txid = x.txid; - pk.objHash = conf.objHash; + pk.objHash = conf.getObjHash(); pk.profile = Step.toBytes(p); // udp.add(pk); sendDirect(pk); @@ -225,7 +225,7 @@ public static void sendCounter(PerfCounterPack[] p) { int bytes = 0; for (int k = 0; k < p.length; k++) { byte[] b = new DataOutputX().writePack(p[k]).toByteArray(); - if (bytes + b.length >= conf.udp_packet_max) { + if (bytes + b.length >= conf.net_udp_packet_max_bytes) { sendDirect(buff); // buff.size가 0일수도 있다. bytes = 0;// bytes 값 초기화.. buff.clear(); @@ -239,7 +239,7 @@ public static void sendCounter(PerfCounterPack[] p) { } public static void sendHeartBeat(ObjectPack p) { udpCollect.add(p); - if (conf.debug_udp_object) { + if (conf.log_udp_object_enabled) { Logger.println(p.toString()); } } diff --git a/scouter.agent.java/src/scouter/agent/netio/data/UDPDataSendThread.java b/scouter.agent.java/src/scouter/agent/netio/data/UDPDataSendThread.java index a47692111..6daac27c7 100644 --- a/scouter.agent.java/src/scouter/agent/netio/data/UDPDataSendThread.java +++ b/scouter.agent.java/src/scouter/agent/netio/data/UDPDataSendThread.java @@ -1,31 +1,31 @@ -/* - * Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package scouter.agent.netio.data; -import java.util.ArrayList; -import java.util.List; - -import scouter.agent.Configure; -import scouter.agent.netio.data.net.DataUdpAgent; -import scouter.io.DataOutputX; -import scouter.lang.pack.Pack; -import scouter.util.Queue; -import scouter.util.ThreadUtil; +import java.util.ArrayList; +import java.util.List; + +import scouter.agent.Configure; +import scouter.agent.netio.data.net.DataUdpAgent; +import scouter.io.DataOutputX; +import scouter.lang.pack.Pack; +import scouter.util.Queue; +import scouter.util.ThreadUtil; public class UDPDataSendThread extends Thread { @@ -77,7 +77,7 @@ public void run() { int size = queue.size(); switch (size) { case 0: - ThreadUtil.sleep(conf.udp_collection_interval); + ThreadUtil.sleep(conf.udp_udp_collection_interval_ms); break; case 1: udp.write(queue.pop()); @@ -96,7 +96,7 @@ private void send(DataUdpAgent udp, int size) { int bytes = 0; for (int k = 0; k < size; k++) { byte[] b = queue.pop(); - if (bytes + b.length >= conf.udp_packet_max) { + if (bytes + b.length >= conf.net_udp_packet_max_bytes) { send(udp, buff); //buff.size가 0일수도 있다. bytes = 0;// bytes 값 초기화.. buff.clear(); diff --git a/scouter.agent.java/src/scouter/agent/netio/data/net/DataUdpAgent.java b/scouter.agent.java/src/scouter/agent/netio/data/net/DataUdpAgent.java index bee979120..f9891e5b8 100644 --- a/scouter.agent.java/src/scouter/agent/netio/data/net/DataUdpAgent.java +++ b/scouter.agent.java/src/scouter/agent/netio/data/net/DataUdpAgent.java @@ -50,8 +50,8 @@ public void run() { } private void setTarget() { Configure conf = Configure.getInstance(); - String host = conf.server_addr; - int port = conf.server_udp_port; + String host = conf.net_collector_ip; + int port = conf.net_collector_udp_port; try { server_host = InetAddress.getByName(host); server_port = port; @@ -70,8 +70,8 @@ protected void close(DatagramSocket d) { private void openDatagramSocket() { try { Configure conf = Configure.getInstance(); - String host = conf.local_udp_addr; - int port = conf.local_udp_port; + String host = conf.net_local_udp_ip; + int port = conf.net_local_udp_port; if (datagram == null || CompareUtil.equals(host, local_udp_addr) == false || local_udp_port != port) { close(datagram); local_udp_addr = host; @@ -99,8 +99,8 @@ public boolean write(byte[] p) { try { if (server_host == null) return false; - if (p.length > conf.udp_packet_max) { - return writeMTU(p, conf.udp_packet_max); + if (p.length > conf.net_udp_packet_max_bytes) { + return writeMTU(p, conf.net_udp_packet_max_bytes); } DataOutputX out = new DataOutputX(); out.write(NetCafe.CAFE); @@ -141,7 +141,7 @@ private boolean writeMTU(byte[] data, int packetSize) { private void writeMTU(long pkid, int total, int num, int packetSize, byte[] data) throws IOException { DataOutputX out = new DataOutputX(); out.write(NetCafe.CAFE_MTU); - out.writeInt(conf.objHash); + out.writeInt(conf.getObjHash()); out.writeLong(pkid); out.writeShort(total); out.writeShort(num); @@ -165,9 +165,9 @@ public boolean write(List p) { int bufferCount = 0; for (int i = 0; i < p.size(); i++) { byte[] b = p.get(i); - if (b.length > conf.udp_packet_max) { - writeMTU(b, conf.udp_packet_max); - } else if (b.length + buffer.getWriteSize() > conf.udp_packet_max) { + if (b.length > conf.net_udp_packet_max_bytes) { + writeMTU(b, conf.net_udp_packet_max_bytes); + } else if (b.length + buffer.getWriteSize() > conf.net_udp_packet_max_bytes) { sendList(bufferCount, buffer.toByteArray()); buffer = new DataOutputX(); bufferCount = 0; diff --git a/scouter.agent.java/src/scouter/agent/netio/data/net/TcpRequestMgr.java b/scouter.agent.java/src/scouter/agent/netio/data/net/TcpRequestMgr.java index 91ccb150f..459a11f9d 100644 --- a/scouter.agent.java/src/scouter/agent/netio/data/net/TcpRequestMgr.java +++ b/scouter.agent.java/src/scouter/agent/netio/data/net/TcpRequestMgr.java @@ -1,8 +1,6 @@ package scouter.agent.netio.data.net; import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import scouter.agent.Configure; import scouter.util.ThreadUtil; @@ -27,7 +25,7 @@ public static synchronized TcpRequestMgr getInstance() { public void run() { while (true) { - int sessionCount = Configure.getInstance().server_tcp_session_count; + int sessionCount = Configure.getInstance().net_collector_tcp_session_count; ThreadUtil.sleep(1000); try { for (int i = 0; i < sessionCount && TcpWorker.LIVE.size() < sessionCount; i++) { 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 0eb574ba4..d82cc50e7 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 @@ -5,9 +5,6 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.concurrent.atomic.AtomicInteger; import scouter.agent.Configure; import scouter.agent.netio.request.ReqestHandlingProxy; @@ -23,7 +20,7 @@ public class TcpWorker implements Runnable { public static IntKeyLinkedMap LIVE = new IntKeyLinkedMap(); public static String localAddr = null; - public int objHash = Configure.getInstance().objHash; + public int objHash = Configure.getInstance().getObjHash(); public void run() { if (socket == null) @@ -46,10 +43,10 @@ public void close() { public boolean prepare() { Configure conf = Configure.getInstance(); - String host = conf.server_addr; - int port = conf.server_tcp_port; - int so_timeout = conf.server_tcp_so_timeout; - int connection_timeout = conf.server_tcp_connection_timeout; + String host = conf.net_collector_ip; + int port = conf.net_collector_tcp_port; + int so_timeout = conf.net_collector_tcp_so_timeout_ms; + int connection_timeout = conf.net_collector_tcp_connection_timeout_ms; socket = new Socket(); try { @@ -76,7 +73,7 @@ private void process(Socket socket) throws IOException { out.writeInt(objHash); out.flush(); - while (objHash == Configure.getInstance().objHash) { + while (objHash == Configure.getInstance().getObjHash()) { String cmd = in.readText(); Pack parameter = (Pack) in.readPack(); Pack res = ReqestHandlingProxy.process(cmd, parameter, in, out); @@ -103,16 +100,16 @@ private void processV2(Socket socket) throws IOException { 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; + String server_addr = conf.net_collector_ip; + int port = conf.net_collector_tcp_port; out.writeInt(NetCafe.TCP_AGENT_V2); out.writeInt(objHash); out.flush(); //에이전트 이름, 서버 주소포트가 같은 동안만 세션을 유지하라. - while (objHash == Configure.getInstance().objHash && server_addr.equals(conf.server_addr) - && port == conf.server_tcp_port) { + while (objHash == Configure.getInstance().getObjHash() && server_addr.equals(conf.net_collector_ip) + && port == conf.net_collector_tcp_port) { byte[] buff = in.readIntBytes(); diff --git a/scouter.agent.java/src/scouter/agent/netio/request/handle/AgentEnv.java b/scouter.agent.java/src/scouter/agent/netio/request/handle/AgentEnv.java index 9939f95ea..981f6b7bc 100644 --- a/scouter.agent.java/src/scouter/agent/netio/request/handle/AgentEnv.java +++ b/scouter.agent.java/src/scouter/agent/netio/request/handle/AgentEnv.java @@ -1,43 +1,43 @@ -/* - * Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package scouter.agent.netio.request.handle; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.Properties; -import scouter.agent.Configure; -import scouter.agent.JavaAgent; -import scouter.agent.Logger; -import scouter.agent.netio.data.DataProxy; -import scouter.agent.netio.request.anotation.RequestHandler; -import scouter.io.DataInputX; -import scouter.io.DataOutputX; -import scouter.lang.pack.MapPack; -import scouter.lang.pack.Pack; -import scouter.lang.value.ListValue; -import scouter.lang.value.TextValue; -import scouter.net.RequestCmd; -import scouter.net.TcpFlag; -import scouter.util.StringUtil; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Properties; +import scouter.agent.Configure; +import scouter.agent.JavaAgent; +import scouter.agent.Logger; +import scouter.agent.netio.data.DataProxy; +import scouter.agent.netio.request.anotation.RequestHandler; +import scouter.io.DataInputX; +import scouter.io.DataOutputX; +import scouter.lang.pack.MapPack; +import scouter.lang.pack.Pack; +import scouter.lang.value.ListValue; +import scouter.lang.value.TextValue; +import scouter.net.RequestCmd; +import scouter.net.TcpFlag; +import scouter.util.StringUtil; public class AgentEnv { @@ -68,8 +68,8 @@ public Pack getAgentEnv(Pack param) { @RequestHandler(RequestCmd.OBJECT_INFO) public Pack getAgentInfo(Pack param) { MapPack p = new MapPack(); - p.put("objHash", conf.objHash); - p.put("objName", conf.objName); + p.put("objHash", conf.getObjHash()); + p.put("objName", conf.getObjName()); p.put("java.version", System.getProperty("java.version")); p.put("os.name", System.getProperty("os.name")); p.put("user.home", System.getProperty("user.home")); @@ -89,7 +89,7 @@ public Pack getDumpFileList(Pack param) { ListValue nameLv = result.newList("name"); ListValue sizeLv = result.newList("size"); ListValue lastModifedLv = result.newList("last_modified"); - File dumpDir = Configure.getInstance().dump_dir; + File dumpDir = Configure.getInstance().mgr_dump_dir; if (dumpDir.canRead()) { for (File file : dumpDir.listFiles()) { if (file.isFile() && file.getName().startsWith("scouter.") && file.getName().endsWith(".dump")) { @@ -106,7 +106,7 @@ public Pack getDumpFileList(Pack param) { public Pack getDumpFileDetail(Pack param, DataInputX in, DataOutputX out) { MapPack p = (MapPack) param; String name = p.getText("name"); - File dumpDir = Configure.getInstance().dump_dir; + File dumpDir = Configure.getInstance().mgr_dump_dir; File dumpFile = new File(dumpDir, name); if (dumpFile.canRead()) { try { @@ -190,12 +190,12 @@ public Pack getLoadedClassList(Pack param) { if (classLoader == null) { classLoader = ClassLoader.getSystemClassLoader(); } - String resource = ""; + String resource = ""; try{ URL url = classLoader.getResource(clazz.getName().replace('.', '/') + ".class"); if (url != null) { resource = url.toString(); - } + } }catch(Throwable t){} resourceLv.add(resource); } catch (Exception e) { @@ -206,4 +206,4 @@ public Pack getLoadedClassList(Pack param) { } return p; } -} +} diff --git a/scouter.agent.java/src/scouter/agent/plugin/PluginLoader.java b/scouter.agent.java/src/scouter/agent/plugin/PluginLoader.java index d30af62f0..1bda0d70e 100644 --- a/scouter.agent.java/src/scouter/agent/plugin/PluginLoader.java +++ b/scouter.agent.java/src/scouter/agent/plugin/PluginLoader.java @@ -26,14 +26,12 @@ import scouter.agent.Logger; import scouter.agent.trace.HookArgs; import scouter.agent.trace.HookReturn; -import scouter.agent.trace.TraceContext; import scouter.agent.trace.TraceSQL; import scouter.javassist.CannotCompileException; import scouter.javassist.ClassPool; import scouter.javassist.CtClass; import scouter.javassist.CtMethod; import scouter.javassist.CtNewMethod; -import scouter.lang.pack.XLogPack; import scouter.util.FileUtil; import scouter.util.Hexa32; import scouter.util.StringUtil; @@ -52,7 +50,7 @@ public synchronized static PluginLoader getInstance() { public void run() { while (true) { try { - File root = Configure.getInstance().plugin_dir; + File root = Configure.getInstance().mgr_plugin_dir; cleckPluginModified(root); } catch (Throwable t) { Logger.println("A160", t.toString()); diff --git a/scouter.agent.java/src/scouter/agent/proxy/LoaderManager.java b/scouter.agent.java/src/scouter/agent/proxy/LoaderManager.java index cbc57b337..e39c6636a 100644 --- a/scouter.agent.java/src/scouter/agent/proxy/LoaderManager.java +++ b/scouter.agent.java/src/scouter/agent/proxy/LoaderManager.java @@ -93,7 +93,7 @@ public synchronized static ClassLoader getHttpClient(ClassLoader parent) { } private static File deployJar(String jarname) { try { - File target = new File(Configure.getInstance().subagent_dir, jarname + ".jar"); + File target = new File(Configure.getInstance().mgr_agent_lib_dir, jarname + ".jar"); if (target.canRead() == false) { InputStream is = JavaAgent.class.getResourceAsStream("/" + jarname + ".jar"); byte[] newBytes = FileUtil.readAll(is); diff --git a/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java b/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java index 4dc456009..1d8bf207b 100644 --- a/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java +++ b/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java @@ -39,7 +39,7 @@ public final static synchronized EndUserSummary getInstance() { private Configure conf = Configure.getInstance(); public void process(EndUserNavigationData p) { - if (conf.enable_summary == false) + if (conf.summary_enabled == false) return; // service summary long key = BitUtil.composite(p.uri, p.ip); @@ -69,7 +69,7 @@ public void process(EndUserNavigationData p) { } public void process(EndUserErrorData p) { - if (conf.enable_summary == false) + if (conf.summary_enabled == false) return; long key = BitUtil.composite(p.stacktrace, p.userAgent); EndUserErrorData d = errorTable.get(key); @@ -81,7 +81,7 @@ public void process(EndUserErrorData p) { } public void process(EndUserAjaxData p) { - if (conf.enable_summary == false) + if (conf.summary_enabled == false) return; long key = BitUtil.composite(p.uri, p.ip); EndUserAjaxData d = ajaxTable.get(key); @@ -94,11 +94,11 @@ public void process(EndUserAjaxData p) { } private LongKeyLinkedMap navTable = new LongKeyLinkedMap() - .setMax(conf.summary_enduser_nav_max); + .setMax(conf.summary_enduser_nav_max_count); private LongKeyLinkedMap ajaxTable = new LongKeyLinkedMap() - .setMax(conf.summary_enduser_ajax_max); + .setMax(conf.summary_enduser_ajax_max_count); private LongKeyLinkedMap errorTable = new LongKeyLinkedMap() - .setMax(conf.summary_enduser_error_max); + .setMax(conf.summary_enduser_error_max_count); public SummaryPack getAndClearNavTable() { @@ -106,7 +106,7 @@ public SummaryPack getAndClearNavTable() { return null; LongKeyLinkedMap temp = navTable; - navTable = new LongKeyLinkedMap().setMax(conf.summary_enduser_nav_max); + navTable = new LongKeyLinkedMap().setMax(conf.summary_enduser_nav_max_count); SummaryPack p = new SummaryPack(); p.stype = SummaryEnum.ENDUSER_NAVIGATION_TIME; @@ -173,7 +173,7 @@ public SummaryPack getAndClearAjaxTable() { return null; LongKeyLinkedMap temp = ajaxTable; - ajaxTable = new LongKeyLinkedMap().setMax(conf.summary_enduser_ajax_max); + ajaxTable = new LongKeyLinkedMap().setMax(conf.summary_enduser_ajax_max_count); SummaryPack p = new SummaryPack(); p.stype = SummaryEnum.ENDUSER_AJAX_TIME; @@ -209,7 +209,7 @@ public SummaryPack getAndClearErrorTable() { return null; LongKeyLinkedMap temp = errorTable; - errorTable = new LongKeyLinkedMap().setMax(conf.summary_enduser_error_max); + errorTable = new LongKeyLinkedMap().setMax(conf.summary_enduser_error_max_count); SummaryPack p = new SummaryPack(); p.stype = SummaryEnum.ENDUSER_SCRIPT_ERROR; diff --git a/scouter.agent.java/src/scouter/agent/summary/ServiceSummary.java b/scouter.agent.java/src/scouter/agent/summary/ServiceSummary.java index 0bb729481..7626fbed8 100644 --- a/scouter.agent.java/src/scouter/agent/summary/ServiceSummary.java +++ b/scouter.agent.java/src/scouter/agent/summary/ServiceSummary.java @@ -47,7 +47,7 @@ public final static synchronized ServiceSummary getInstance() { private Configure conf = Configure.getInstance(); public void process(XLogPack p) { - if (conf.enable_summary == false) + if (conf.summary_enabled == false) return; // service summary SummaryData d = getSummaryMap(serviceMaster, p.service); @@ -71,7 +71,7 @@ public void process(XLogPack p) { } public ErrorData process(Throwable p, int message, int service, long txid, int sql, int api) { - if (conf.enable_summary == false) + if (conf.summary_enabled == false) return null; String errName = p.getClass().getName(); @@ -91,7 +91,7 @@ public ErrorData process(Throwable p, int message, int service, long txid, int s } public void process(SqlStep sqlStep) { - if (conf.enable_summary == false) + if (conf.summary_enabled == false) return; SummaryData d = getSummaryMap(sqlMaster, sqlStep.hash); d.count++; @@ -102,7 +102,7 @@ public void process(SqlStep sqlStep) { } public void process(ApiCallStep apiStep) { - if (conf.enable_summary == false) + if (conf.summary_enabled == false) return; SummaryData d = getSummaryMap(apiMaster, apiStep.hash); d.count++; @@ -134,14 +134,14 @@ private synchronized ErrorData getSummaryError(LongKeyLinkedMap table } private LongKeyLinkedMap errorMaster = new LongKeyLinkedMap() - .setMax(conf.summary_service_error_max); + .setMax(conf.summary_error_max_count); - private IntKeyLinkedMap sqlMaster = new IntKeyLinkedMap().setMax(conf.summary_sql_max); - private IntKeyLinkedMap apiMaster = new IntKeyLinkedMap().setMax(conf.summary_api_max); + private IntKeyLinkedMap sqlMaster = new IntKeyLinkedMap().setMax(conf.summary_sql_max_count); + private IntKeyLinkedMap apiMaster = new IntKeyLinkedMap().setMax(conf.summary_api_max_count); private IntKeyLinkedMap serviceMaster = new IntKeyLinkedMap() - .setMax(conf.summary_service_max); - private IntIntLinkedMap ipMaster = new IntIntLinkedMap().setMax(conf.summary_service_ip_max); - private IntIntLinkedMap uaMaster = new IntIntLinkedMap().setMax(conf.summary_service_ua_max); + .setMax(conf.summary_service_max_count); + private IntIntLinkedMap ipMaster = new IntIntLinkedMap().setMax(conf.summary_ip_max_count); + private IntIntLinkedMap uaMaster = new IntIntLinkedMap().setMax(conf.summary_useragent_max_count); public SummaryPack getAndClear(byte type) { IntKeyLinkedMap temp; @@ -150,19 +150,19 @@ public SummaryPack getAndClear(byte type) { if (serviceMaster.size() == 0) return null; temp = serviceMaster; - serviceMaster = new IntKeyLinkedMap().setMax(conf.summary_service_max); + serviceMaster = new IntKeyLinkedMap().setMax(conf.summary_service_max_count); break; case SummaryEnum.SQL: if (sqlMaster.size() == 0) return null; temp = sqlMaster; - sqlMaster = new IntKeyLinkedMap().setMax(conf.summary_sql_max); + sqlMaster = new IntKeyLinkedMap().setMax(conf.summary_sql_max_count); break; case SummaryEnum.APICALL: if (apiMaster.size() == 0) return null; temp = apiMaster; - apiMaster = new IntKeyLinkedMap().setMax(conf.summary_api_max); + apiMaster = new IntKeyLinkedMap().setMax(conf.summary_api_max_count); break; default: return null; @@ -207,13 +207,13 @@ public SummaryPack getAndClearX(byte type) { if (ipMaster.size() == 0) return null; temp = ipMaster; - ipMaster = new IntIntLinkedMap().setMax(conf.summary_service_ip_max); + ipMaster = new IntIntLinkedMap().setMax(conf.summary_ip_max_count); break; case SummaryEnum.USER_AGENT: if (uaMaster.size() == 0) return null; temp = uaMaster; - uaMaster = new IntIntLinkedMap().setMax(conf.summary_service_ua_max); + uaMaster = new IntIntLinkedMap().setMax(conf.summary_useragent_max_count); break; default: return null; @@ -242,7 +242,7 @@ public SummaryPack getAndClearError(byte type) { return null; LongKeyLinkedMap temp = errorMaster; - errorMaster = new LongKeyLinkedMap().setMax(conf.summary_service_error_max); + errorMaster = new LongKeyLinkedMap().setMax(conf.summary_error_max_count); SummaryPack p = new SummaryPack(); p.stype = type; diff --git a/scouter.agent.java/src/scouter/agent/trace/AlertProxy.java b/scouter.agent.java/src/scouter/agent/trace/AlertProxy.java index f8021dd82..c4fb06fb9 100644 --- a/scouter.agent.java/src/scouter/agent/trace/AlertProxy.java +++ b/scouter.agent.java/src/scouter/agent/trace/AlertProxy.java @@ -18,7 +18,6 @@ import scouter.agent.Configure; import scouter.agent.netio.data.DataProxy; -import scouter.lang.value.MapValue; import scouter.util.LinkedMap; import scouter.util.StringUtil; @@ -36,7 +35,7 @@ public static void sendAlert(byte level, String title, String emsg) { Long last = sendTimeTable.get(title); - if (last == null || now - last.longValue() >= conf.alert_send_interval) { + if (last == null || now - last.longValue() >= conf.alert_send_interval_ms) { sendTimeTable.put(title, now); DataProxy.sendAlert(level, title, StringUtil.limiting(emsg, conf.alert_message_length), null); } diff --git a/scouter.agent.java/src/scouter/agent/trace/LoadedContext.java b/scouter.agent.java/src/scouter/agent/trace/LoadedContext.java index ee52d0ae3..8883ce434 100644 --- a/scouter.agent.java/src/scouter/agent/trace/LoadedContext.java +++ b/scouter.agent.java/src/scouter/agent/trace/LoadedContext.java @@ -7,7 +7,7 @@ public class LoadedContext { public static StringLinkedSet ctxSet = new StringLinkedSet().setMax(100); public static void put(DataSource ds) { String old = ctxSet.put(ds.getClass().getName()); - if (old == null && Configure.getInstance().debug_datasource_lookup) { + if (old == null && Configure.getInstance().log_datasource_lookup_enabled) { Logger.println("DataSource lookup : " + ds.getClass().getName()); } } diff --git a/scouter.agent.java/src/scouter/agent/trace/ProfileCollector.java b/scouter.agent.java/src/scouter/agent/trace/ProfileCollector.java index d71daec8a..366ecce21 100644 --- a/scouter.agent.java/src/scouter/agent/trace/ProfileCollector.java +++ b/scouter.agent.java/src/scouter/agent/trace/ProfileCollector.java @@ -1,31 +1,31 @@ -/* - * Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package scouter.agent.trace; -import scouter.agent.Configure; -import scouter.agent.netio.data.DataProxy; -import scouter.lang.step.Step; -import scouter.lang.step.StepSingle; +import scouter.agent.Configure; +import scouter.agent.netio.data.DataProxy; +import scouter.lang.step.Step; +import scouter.lang.step.StepSingle; public class ProfileCollector implements IProfileCollector { private Configure conf=Configure.getInstance(); private TraceContext context; - protected Step[] buffer = new Step[conf.profile_step_max]; + protected Step[] buffer = new Step[conf.profile_step_max_count]; protected int position = 0; public int this_index = 0; @@ -46,7 +46,7 @@ protected void process(StepSingle stepSingle) { buffer[position++] = stepSingle; if (position >= buffer.length) { Step[] o = buffer; - buffer = new Step[conf.profile_step_max]; + buffer = new Step[conf.profile_step_max_count]; position = 0; DataProxy.sendProfile(o, context); } diff --git a/scouter.agent.java/src/scouter/agent/trace/SocketTable.java b/scouter.agent.java/src/scouter/agent/trace/SocketTable.java index 9b26240ce..3031e8b3c 100644 --- a/scouter.agent.java/src/scouter/agent/trace/SocketTable.java +++ b/scouter.agent.java/src/scouter/agent/trace/SocketTable.java @@ -41,7 +41,7 @@ public static void add(byte[] ipaddr, int port, int serviceHash, long txid) { } else { info = new Info(serviceHash, txid); socketMap.put(key, info); - if (port == Configure.getInstance().socket_open_fullstack_port) { + if (port == Configure.getInstance()._trace_fullstack_socket_open_port) { info.stack = ThreadUtil.getStackTrace(Thread.currentThread().getStackTrace(), 3); } } diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java b/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java index 7ec1edb44..b6bafa527 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceApiCall.java @@ -125,14 +125,14 @@ public static void endApicall(Object stat, Object returnValue, Throwable thr) { if (thr != null) { String msg = thr.getMessage(); Configure conf = Configure.getInstance(); - if (conf.profile_fullstack_apicall_error) { + if (conf.profile_fullstack_apicall_error_enabled) { StringBuffer sb = new StringBuffer(); sb.append(msg).append("\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); while (thr != null) { sb.append("\nCause...\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); } msg = sb.toString(); @@ -155,7 +155,7 @@ public static Object startSocket(Socket socket, SocketAddress addr, int timeout) return null; TraceContext ctx = TraceContextManager.getLocalContext(); if (ctx == null) { - if (Configure.getInstance().listup_background_socket) { + if (Configure.getInstance().trace_background_socket_enabled) { InetSocketAddress inet = (InetSocketAddress) addr; InetAddress host = inet.getAddress(); int port = inet.getPort(); @@ -201,8 +201,8 @@ public static void endSocket(Object stat, Throwable thr) { tctx.profile.add(step); SocketTable.add(step.ipaddr, step.port, tctx.serviceHash, tctx.txid); Configure conf = Configure.getInstance(); - if (conf.profile_socket_openstack) { - if (conf.profile_socket_openstack_port == 0 || conf.profile_socket_openstack_port == step.port) { + if (conf.profile_socket_open_fullstack_enabled) { + if (conf.profile_socket_open_fullstack_port == 0 || conf.profile_socket_open_fullstack_port == step.port) { tctx.profile.add(new MessageStep(step.start_time, ThreadUtil.getThreadStack())); } } diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceContextManager.java b/scouter.agent.java/src/scouter/agent/trace/TraceContextManager.java index 862116455..d063da231 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceContextManager.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceContextManager.java @@ -45,9 +45,9 @@ public static int[] getActiveCount() { while (en.hasMoreElements()) { TraceContext ctx = en.nextElement(); long tm = now - ctx.startTime; - if (tm < conf.yellow_line_time) { + if (tm < conf.trace_activeserivce_yellow_time) { act[0]++; - } else if (tm < conf.red_line_time) { + } else if (tm < conf.trace_activeservice_red_time) { act[1]++; } else { act[2]++; diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java index 443b7b949..aa7bdb992 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java @@ -88,7 +88,7 @@ public static Object startHttpFilter(Object req, Object res) { private static Error userTxNotClose = new USERTX_NOT_CLOSE("Missing Commit/Rollback Error"); public static Object reject(Object stat, Object req, Object res) { Configure conf = Configure.getInstance(); - if (conf.enable_reject_service) { + if (conf.control_reject_service_enabled) { if (stat == null || req == null || res == null) return null; if (http == null) { @@ -99,13 +99,13 @@ public static Object reject(Object stat, Object req, Object res) { return null; // reject by customized plugin if (PluginHttpServiceTrace.reject(stat0.ctx, req, res) - // reject by max_active_service - || TraceContextManager.size() > conf.max_active_service) { + // reject by control_reject_service_max_count + || TraceContextManager.size() > conf.control_reject_service_max_count) { // howto reject - if (conf.enable_reject_url) { - http.rejectUrl(res, conf.reject_url); // by url + if (conf.control_reject_redirect_url_enabled) { + http.rejectUrl(res, conf.control_reject_redirect_url); // by url } else { - http.rejectText(res, conf.reject_text);// just message + http.rejectText(res, conf.control_reject_text);// just message } // close transaction endHttpService(stat0, REJECT); @@ -119,19 +119,19 @@ private static void addSeviceName(TraceContext ctx, Object req) { Configure conf = Configure.getInstance(); StringBuilder sb = new StringBuilder(); - if (conf.service_post_key != null) { - String v = http.getParameter(req, conf.service_post_key); + if (conf.trace_service_name_post_key != null) { + String v = http.getParameter(req, conf.trace_service_name_post_key); if (v != null) { if (sb.length() == 0) { sb.append(ctx.serviceName); - sb.append('?').append(conf.service_post_key).append("=").append(v); + sb.append('?').append(conf.trace_service_name_post_key).append("=").append(v); } else { - sb.append('&').append(conf.service_post_key).append("=").append(v); + sb.append('&').append(conf.trace_service_name_post_key).append("=").append(v); } } } - if (conf.service_get_key != null && ctx.http_query != null) { - int x = ctx.http_query.indexOf(conf.service_get_key); + if (conf.trace_service_name_get_key != null && ctx.http_query != null) { + int x = ctx.http_query.indexOf(conf.trace_service_name_get_key); if (x >= 0) { String v = null; int y = ctx.http_query.indexOf('&', x + 1); @@ -148,8 +148,8 @@ private static void addSeviceName(TraceContext ctx, Object req) { } } } - if (conf.service_header_key != null) { - String v = http.getHeader(req, conf.service_header_key); + if (conf.trace_service_name_header_key != null) { + String v = http.getHeader(req, conf.trace_service_name_header_key); ctx.serviceName = new StringBuilder(ctx.serviceName.length() + v.length() + 5).append(ctx.serviceName) .append('-').append(v).toString(); } @@ -165,14 +165,14 @@ private static Object startHttp(Object req, Object res) { initHttp(req); } Configure conf = Configure.getInstance(); - TraceContext ctx = new TraceContext(conf.enable_profile_summary); + TraceContext ctx = new TraceContext(conf.profile_summary_mode_enabled); ctx.thread = Thread.currentThread(); ctx.txid = KeyGen.next(); ctx.startTime = System.currentTimeMillis(); ctx.startCpu = SysJMX.getCurrentThreadCPU(); ctx.threadId = TraceContextManager.start(ctx.thread, ctx); ctx.bytes = SysJMX.getCurrentThreadAllocBytes(); - ctx.profile_thread_cputime = conf.profile_thread_cputime; + ctx.profile_thread_cputime = conf.profile_thread_cputime_enabled; http.start(ctx, req, res); if (ctx.serviceName == null) @@ -203,14 +203,14 @@ public static void endHttpService(Object stat, Throwable thr) { if (ctx != null && ctx.error == 0) { Configure conf = Configure.getInstance(); String emsg = thr.toString(); - if (conf.profile_fullstack_service_error) { + if (conf.profile_fullstack_service_error_enabled) { StringBuffer sb = new StringBuffer(); sb.append(emsg).append("\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); while (thr != null) { sb.append("\nCause...\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); } emsg = sb.toString(); @@ -224,7 +224,7 @@ public static void endHttpService(Object stat, Throwable thr) { } TraceContext ctx = stat0.ctx; - if(conf.enduser_perf_endpoint_hash == ctx.serviceHash){ + if(conf.getEndUserPerfEndpointHash() == ctx.serviceHash){ TraceContextManager.end(ctx.threadId); return; } @@ -245,7 +245,7 @@ public static void endHttpService(Object stat, Throwable thr) { XLogPack pack = new XLogPack(); // pack.endTime = System.currentTimeMillis(); pack.elapsed = (int) (System.currentTimeMillis() - ctx.startTime); - boolean sendOk = pack.elapsed >= conf.xlog_time_limit; + boolean sendOk = pack.elapsed >= conf.xlog_lower_bound_time_ms; ctx.profile.close(sendOk); ctx.serviceHash = DataProxy.sendServiceName(ctx.serviceName); pack.service = ctx.serviceHash; @@ -265,19 +265,19 @@ public static void endHttpService(Object stat, Throwable thr) { } else if (thr != null) { if (thr == REJECT) { Logger.println("A145", ctx.serviceName); - String emsg = conf.reject_text; + String emsg = conf.control_reject_text; pack.error = DataProxy.sendError(emsg); ServiceSummary.getInstance().process(thr, pack.error, ctx.serviceHash, ctx.txid, 0, 0); } else { String emsg = thr.toString(); - if (conf.profile_fullstack_service_error) { + if (conf.profile_fullstack_service_error_enabled) { StringBuffer sb = new StringBuffer(); sb.append(emsg).append("\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); while (thr != null) { sb.append("\nCause...\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); } emsg = sb.toString(); @@ -345,7 +345,7 @@ public static Object startService(String name, String className, String methodNa return null; } Configure conf = Configure.getInstance(); - ctx = new TraceContext(conf.enable_profile_summary); + ctx = new TraceContext(conf.profile_summary_mode_enabled); String service_name = name; ctx.thread = Thread.currentThread(); ctx.serviceHash = HashUtil.hash(service_name); @@ -355,7 +355,7 @@ public static Object startService(String name, String className, String methodNa ctx.txid = KeyGen.next(); ctx.threadId = TraceContextManager.start(ctx.thread, ctx); ctx.bytes = SysJMX.getCurrentThreadAllocBytes(); - ctx.profile_thread_cputime = conf.profile_thread_cputime; + ctx.profile_thread_cputime = conf.profile_thread_cputime_enabled; ctx.xType = xType; PluginAppServiceTrace.start(ctx, new HookArgs(className, methodName, methodDesc, _this, arg)); if (ctx.xType == XLogTypes.BACK_THREAD) { @@ -406,7 +406,7 @@ public static void endService(Object stat, Object returnValue, Throwable thr) { pack.cpu = (int) (SysJMX.getCurrentThreadCPU() - ctx.startCpu); // pack.endTime = System.currentTimeMillis(); pack.elapsed = (int) (System.currentTimeMillis() - ctx.startTime); - boolean sendOk = pack.elapsed >= Configure.getInstance().xlog_time_limit; + boolean sendOk = pack.elapsed >= Configure.getInstance().xlog_lower_bound_time_ms; ctx.profile.close(sendOk); DataProxy.sendServiceName(ctx.serviceHash, ctx.serviceName); pack.service = ctx.serviceHash; @@ -450,14 +450,14 @@ private static int errorCheck(TraceContext ctx, Throwable thr) { } else if (thr != null) { Configure conf = Configure.getInstance(); String emsg = thr.toString(); - if (conf.profile_fullstack_service_error) { + if (conf.profile_fullstack_service_error_enabled) { StringBuffer sb = new StringBuffer(); sb.append(emsg).append("\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); while (thr != null) { sb.append("\nCause...\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); } emsg = sb.toString(); @@ -476,7 +476,7 @@ public static void capArgs(String className, String methodName, String methodDes return; // MessageStep step = new MessageStep(); // step.start_time = (int) (System.currentTimeMillis() - ctx.startTime); - // if (ctx.profile_thread_cputime) { + // if (ctx.profile_thread_cputime_enabled) { // step.start_cpu = (int) (SysJMX.getCurrentThreadCPU() - ctx.startCpu); // } // step.message = toString("CAP-ARG", className, methodName, methodDesc, @@ -543,7 +543,7 @@ public static void capThis(String className, String methodDesc, Object this0) { return; // MessageStep step = new MessageStep(); // step.start_time = (int) (System.currentTimeMillis() - ctx.startTime); - // if (ctx.profile_thread_cputime) { + // if (ctx.profile_thread_cputime_enabled) { // step.start_cpu = (int) (SysJMX.getCurrentThreadCPU() - ctx.startCpu); // } // step.message = toStringTHIS("CAP-THIS", className, methodDesc, @@ -559,13 +559,13 @@ public static void capReturn(String className, String methodName, String methodD } private static Configure conf = Configure.getInstance(); public static Object startMethod(int hash, String classMethod) { - if (conf.trace_method_enabled == false) + if (conf.profile_method_enabled == false) return null; TraceContext ctx = TraceContextManager.getLocalContext(); if (ctx == null) { - if (conf.enable_auto_service_trace) { + if (conf._trace_auto_service_enabled) { Object stat = startService(classMethod, null, null, null, null, null, XLogTypes.APP_SERVICE); - if (conf.enable_auto_service_backstack) { + if (conf._trace_auto_service_backstack_enabled) { String stack = ThreadUtil.getStackTrace(Thread.currentThread().getStackTrace(), 2); AutoServiceStartAnalyzer.put(classMethod, stack); MessageStep m = new MessageStep(); diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java b/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java index ae3a94e80..f9cd4560a 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceSQL.java @@ -31,7 +31,6 @@ import scouter.jdbc.DetectConnection; import scouter.jdbc.WrConnection; import scouter.lang.AlertLevel; -import scouter.lang.TextTypes; import scouter.lang.step.HashedMessageStep; import scouter.lang.step.MessageStep; import scouter.lang.step.MethodStep; @@ -39,7 +38,6 @@ import scouter.lang.step.SqlXType; import scouter.util.EscapeLiteralSQL; import scouter.util.HashUtil; -import scouter.util.Hexa32; import scouter.util.IntKeyLinkedMap; import scouter.util.IntLinkedSet; import scouter.util.StringUtil; @@ -131,13 +129,13 @@ public static Object start(Object o) { public static Object start(Object o, String sql) { TraceContext ctx = TraceContextManager.getLocalContext(); if (ctx == null) { - if (conf.debug_background_sql) { + if (conf.log_background_sql) { Logger.println("background: " + sql); } return null; } // to debug - if (conf.debug_sql_call && ctx.debug_sql_call == false) { + if (conf._profile_fullstack_sql_connection_enabled && ctx.debug_sql_call == false) { ctx.debug_sql_call = true; StringBuffer sb = new StringBuffer(); if (o instanceof Statement) { @@ -154,7 +152,7 @@ public static Object start(Object o, String sql) { ctx.profile.add(new MessageStep((int) (System.currentTimeMillis() - ctx.startTime), sb.toString())); } // Looking for the position of calling SQL COMMIT - if (conf.profile_fullstack_sql_commit) { + if (conf.profile_fullstack_sql_commit_enabled) { if ("commit".equalsIgnoreCase(sql)) { ctx.profile.add(new MessageStep((int) (System.currentTimeMillis() - ctx.startTime), ThreadUtil.getThreadStack())); @@ -187,7 +185,7 @@ public ParsedSql(String sql, String param) { private static IntLinkedSet noLiteralSql = new IntLinkedSet().setMax(10000); private static IntKeyLinkedMap checkedSql = new IntKeyLinkedMap().setMax(1001); private static String escapeLiteral(String sql, SqlStep2 step) { - if (conf.profile_sql_escape == false) + if (conf.profile_sql_escape_enabled == false) return sql; int sqlHash = sql.hashCode(); if (noLiteralSql.contains(sqlHash)) { @@ -216,7 +214,7 @@ private static String escapeLiteral(String sql, SqlStep2 step) { "CONNECTION_OPEN_FAIL"); public static void end(Object stat, Throwable thr) { if (stat == null) { - if (conf.debug_background_sql && thr != null) { + if (conf.log_background_sql && thr != null) { Logger.println("BG-SQL:" + thr); } return; @@ -230,14 +228,14 @@ public static void end(Object stat, Throwable thr) { } if (thr != null) { String msg = thr.toString(); - if (conf.profile_fullstack_sql_error) { + if (conf.profile_fullstack_sql_error_enabled) { StringBuffer sb = new StringBuffer(); sb.append(msg).append("\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); while (thr != null) { sb.append("\nCause...\n"); - ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_lines); + ThreadUtil.getStackTrace(sb, thr, conf.profile_fullstack_max_lines); thr = thr.getCause(); } msg = sb.toString(); @@ -248,8 +246,8 @@ public static void end(Object stat, Throwable thr) { } ps.error = hash; ServiceSummary.getInstance().process(thr, hash, tctx.serviceHash, tctx.txid, ps.hash, 0); - } else if (ps.elapsed > conf.sql_time_max) { - String msg = "warning slow sql, over " + conf.sql_time_max + " ms"; + } else if (ps.elapsed > conf.xlog_error_sql_time_max_ms) { + String msg = "warning slow sql, over " + conf.xlog_error_sql_time_max_ms + " ms"; int hash = DataProxy.sendError(msg); if (tctx.error == 0) { tctx.error = hash; @@ -299,8 +297,8 @@ private static void fetch(TraceContext c) { p.value = c.rs_count; p.time = (int) time; c.profile.add(p); - if (c.rs_count > conf.jdbc_fetch_max) { - String msg = "warning too many resultset, over #" + conf.jdbc_fetch_max; + if (c.rs_count > conf.xlog_error_jdbc_fetch_max) { + String msg = "warning too many resultset, over #" + conf.xlog_error_jdbc_fetch_max; int hash = DataProxy.sendError(msg); if (c.error == 0) { c.error = hash; @@ -378,13 +376,13 @@ public static void clear(Object o, SqlParameter args) { public static Object start(Object o, SqlParameter args) { TraceContext ctx = TraceContextManager.getLocalContext(); if (ctx == null) { - if (conf.debug_background_sql && args != null) { + if (conf.log_background_sql && args != null) { Logger.println("background: " + args.getSql()); } return null; } // to debug - if (conf.debug_sql_call && ctx.debug_sql_call == false) { + if (conf._profile_fullstack_sql_connection_enabled && ctx.debug_sql_call == false) { ctx.debug_sql_call = true; StringBuffer sb = new StringBuffer(); if (o instanceof Statement) { @@ -401,7 +399,7 @@ public static Object start(Object o, SqlParameter args) { ctx.profile.add(new MessageStep((int) (System.currentTimeMillis() - ctx.startTime), sb.toString())); } // Looking for the position of calling SQL COMMIT - if (conf.profile_fullstack_sql_commit) { + if (conf.profile_fullstack_sql_commit_enabled) { if ("commit".equalsIgnoreCase(args.getSql())) { ctx.profile.add(new MessageStep((int) (System.currentTimeMillis() - ctx.startTime), ThreadUtil.getThreadStack())); @@ -444,7 +442,7 @@ public static void prepare(Object o, SqlParameter args, String sql) { public static Connection driverConnect(Connection conn, String url) { if (conn == null) return conn; - if (conf.enable_dbc_wrapper == false) + if (conf.trace_db2_enabled == false) return conn; if (conn instanceof WrConnection) return conn; @@ -481,7 +479,7 @@ public static Object dbcOpenStart(int hash, String msg, Object pool) { TraceContext ctx = TraceContextManager.getLocalContext(); if (ctx == null) return null; - if (conf.enable_trace_connection_open == false) + if (conf.profile_connection_open_enabled == false) return null; MethodStep p = new MethodStep(); p.start_time = (int) (System.currentTimeMillis() - ctx.startTime); @@ -494,7 +492,7 @@ public static Object dbcOpenStart(int hash, String msg, Object pool) { } p.hash = hash; ctx.profile.push(p); - if (conf.debug_connection_open_fullstack) { + if (conf.profile_connection_open_fullstack_enabled) { String stack = ThreadUtil.getStackTrace(Thread.currentThread().getStackTrace(), 2); MessageStep ms = new MessageStep(stack); ms.start_time = (int) (System.currentTimeMillis() - ctx.startTime); @@ -561,7 +559,7 @@ public static java.sql.Connection dbcOpenEnd(java.sql.Connection conn, Object st step.cputime = (int) (SysJMX.getCurrentThreadCPU() - tctx.startCpu) - step.start_cpu; } tctx.profile.pop(step); - if (conf.debug_connection_autocommit) { + if (conf.profile_connection_autocommit_status_enabled) { HashedMessageStep ms = new HashedMessageStep(); try { ms.hash = DataProxy.sendHashedMessage("AutoCommit : " + conn.getAutoCommit()); @@ -609,7 +607,7 @@ public static void dbcOpenEnd(Object stat, Throwable thr) { * sqlMap name */ public static void sqlMap(String methodName, String sqlname) { - if (Configure.getInstance().profile_framework_sqlmap == false) + if (Configure.getInstance().profile_sqlmap_name_enabled == false) return; TraceContext ctx = TraceContextManager.getLocalContext(); if (ctx == null) diff --git a/scouter.agent.java/src/scouter/agent/trace/api/ForHttpClient40.java b/scouter.agent.java/src/scouter/agent/trace/api/ForHttpClient40.java index 90ee94de0..2c259ee92 100644 --- a/scouter.agent.java/src/scouter/agent/trace/api/ForHttpClient40.java +++ b/scouter.agent.java/src/scouter/agent/trace/api/ForHttpClient40.java @@ -22,7 +22,6 @@ import scouter.agent.proxy.IHttpClient; import scouter.agent.trace.HookArgs; import scouter.agent.trace.TraceContext; -import scouter.agent.trace.TraceContextManager; import scouter.lang.step.ApiCallStep; import scouter.util.Hexa32; import scouter.util.IntKeyLinkedMap; @@ -67,14 +66,14 @@ private IHttpClient getProxy(HookArgs hookPoint) { } private void transfer(IHttpClient httpclient, TraceContext ctx, Object host, Object req, long calleeTxid) { Configure conf = Configure.getInstance(); - if (conf.enable_trace_e2e) { + if (conf.trace_interservice_enabled) { try { if (ctx.gxid == 0) { ctx.gxid = ctx.txid; } - httpclient.addHeader(req, conf.gxid, Hexa32.toString32(ctx.gxid)); - httpclient.addHeader(req, conf.caller_txid, Hexa32.toString32(ctx.txid)); - httpclient.addHeader(req, conf.this_txid, Hexa32.toString32(calleeTxid)); + httpclient.addHeader(req, conf.trace_interservice_gxid_header_key, Hexa32.toString32(ctx.gxid)); + httpclient.addHeader(req, conf.trace_interservice_caller_header_key, Hexa32.toString32(ctx.txid)); + httpclient.addHeader(req, conf.trace_interservice_callee_header_key, Hexa32.toString32(calleeTxid)); PluginHttpCallTrace.call(ctx, req); } catch (Throwable e) { Logger.println("A001", e); diff --git a/scouter.agent.java/src/scouter/agent/trace/api/ForHttpClient43.java b/scouter.agent.java/src/scouter/agent/trace/api/ForHttpClient43.java index 50004903b..59db3a789 100644 --- a/scouter.agent.java/src/scouter/agent/trace/api/ForHttpClient43.java +++ b/scouter.agent.java/src/scouter/agent/trace/api/ForHttpClient43.java @@ -22,7 +22,6 @@ import scouter.agent.proxy.IHttpClient; import scouter.agent.trace.HookArgs; import scouter.agent.trace.TraceContext; -import scouter.agent.trace.TraceContextManager; import scouter.lang.step.ApiCallStep; import scouter.util.Hexa32; import scouter.util.IntKeyLinkedMap; @@ -66,14 +65,14 @@ private IHttpClient getProxy(HookArgs hookPoint) { private boolean ok = true; private void transfer(IHttpClient httpclient, TraceContext ctx, Object host, Object req, long calleeTxid) { Configure conf = Configure.getInstance(); - if (conf.enable_trace_e2e) { + if (conf.trace_interservice_enabled) { try { if (ctx.gxid == 0) { ctx.gxid = ctx.txid; } - httpclient.addHeader(req, conf.gxid, Hexa32.toString32(ctx.gxid)); - httpclient.addHeader(req, conf.caller_txid, Hexa32.toString32(ctx.txid)); - httpclient.addHeader(req, conf.this_txid, Hexa32.toString32(calleeTxid)); + httpclient.addHeader(req, conf.trace_interservice_gxid_header_key, Hexa32.toString32(ctx.gxid)); + httpclient.addHeader(req, conf.trace_interservice_caller_header_key, Hexa32.toString32(ctx.txid)); + httpclient.addHeader(req, conf.trace_interservice_callee_header_key, Hexa32.toString32(calleeTxid)); PluginHttpCallTrace.call(ctx, req); } catch (Exception e) { Logger.println("A178", e); diff --git a/scouter.agent.java/src/scouter/agent/trace/api/ForHttpURLConnection.java b/scouter.agent.java/src/scouter/agent/trace/api/ForHttpURLConnection.java index cdc2ac7d9..4e471f822 100644 --- a/scouter.agent.java/src/scouter/agent/trace/api/ForHttpURLConnection.java +++ b/scouter.agent.java/src/scouter/agent/trace/api/ForHttpURLConnection.java @@ -87,15 +87,15 @@ public ApiCallStep process(TraceContext ctx, HookArgs hookPoint) { private void transfer(TraceContext ctx, HttpURLConnection urlCon, long calleeTxid) { Configure conf = Configure.getInstance(); - if (conf.enable_trace_e2e) { + if (conf.trace_interservice_enabled) { if (ctx.gxid == 0) { ctx.gxid = ctx.txid; } try { - urlCon.setRequestProperty(conf.gxid, Hexa32.toString32(ctx.gxid)); - urlCon.setRequestProperty(conf.this_txid, Hexa32.toString32(calleeTxid)); - urlCon.setRequestProperty(conf.caller_txid, Hexa32.toString32(ctx.txid)); + urlCon.setRequestProperty(conf.trace_interservice_gxid_header_key, Hexa32.toString32(ctx.gxid)); + urlCon.setRequestProperty(conf.trace_interservice_callee_header_key, Hexa32.toString32(calleeTxid)); + urlCon.setRequestProperty(conf.trace_interservice_caller_header_key, Hexa32.toString32(ctx.txid)); PluginHttpCallTrace.call(ctx, urlCon); } catch (Throwable t) { diff --git a/scouter.agent.java/src/scouter/agent/trace/api/ForNettyHttpRequest.java b/scouter.agent.java/src/scouter/agent/trace/api/ForNettyHttpRequest.java index 3cb302913..db59d62cd 100644 --- a/scouter.agent.java/src/scouter/agent/trace/api/ForNettyHttpRequest.java +++ b/scouter.agent.java/src/scouter/agent/trace/api/ForNettyHttpRequest.java @@ -73,17 +73,17 @@ private IHttpClient getProxy(HookArgs hookPoint) { private void transfer(IHttpClient httpclient, TraceContext ctx, Object req, long calleeTxid) { Configure conf = Configure.getInstance(); - if (conf.enable_trace_e2e) { + if (conf.trace_interservice_enabled) { try { if (ctx.gxid == 0) { ctx.gxid = ctx.txid; } - httpclient.addHeader(req, conf.gxid, Hexa32.toString32(ctx.gxid)); - httpclient.addHeader(req, conf.caller_txid, Hexa32.toString32(ctx.txid)); - httpclient.addHeader(req, conf.this_txid, Hexa32.toString32(calleeTxid)); + httpclient.addHeader(req, conf.trace_interservice_gxid_header_key, Hexa32.toString32(ctx.gxid)); + httpclient.addHeader(req, conf.trace_interservice_caller_header_key, Hexa32.toString32(ctx.txid)); + httpclient.addHeader(req, conf.trace_interservice_callee_header_key, Hexa32.toString32(calleeTxid)); httpclient.addHeader(req, "scouter_caller_url", ctx.serviceName); - httpclient.addHeader(req, "scouter_caller_name", conf.objName); + httpclient.addHeader(req, "scouter_caller_name", conf.getObjName()); httpclient.addHeader(req, "scouter_thread_id", Long.toString(ctx.threadId)); PluginHttpCallTrace.call(ctx, httpclient, req); diff --git a/scouter.agent.java/src/scouter/agent/trace/api/ForRibbonLB.java b/scouter.agent.java/src/scouter/agent/trace/api/ForRibbonLB.java index b00ba7713..b7ab46b93 100644 --- a/scouter.agent.java/src/scouter/agent/trace/api/ForRibbonLB.java +++ b/scouter.agent.java/src/scouter/agent/trace/api/ForRibbonLB.java @@ -73,17 +73,17 @@ private IHttpClient getProxy(HookArgs hookPoint) { private void transfer(IHttpClient httpclient, TraceContext ctx, Object req, long calleeTxid) { Configure conf = Configure.getInstance(); - if (conf.enable_trace_e2e) { + if (conf.trace_interservice_enabled) { try { if (ctx.gxid == 0) { ctx.gxid = ctx.txid; } - httpclient.addHeader(req, conf.gxid, Hexa32.toString32(ctx.gxid)); - httpclient.addHeader(req, conf.caller_txid, Hexa32.toString32(ctx.txid)); - httpclient.addHeader(req, conf.this_txid, Hexa32.toString32(calleeTxid)); + httpclient.addHeader(req, conf.trace_interservice_gxid_header_key, Hexa32.toString32(ctx.gxid)); + httpclient.addHeader(req, conf.trace_interservice_caller_header_key, Hexa32.toString32(ctx.txid)); + httpclient.addHeader(req, conf.trace_interservice_callee_header_key, Hexa32.toString32(calleeTxid)); httpclient.addHeader(req, "scouter_caller_url", ctx.serviceName); - httpclient.addHeader(req, "scouter_caller_name", conf.objName); + httpclient.addHeader(req, "scouter_caller_name", conf.getObjName()); httpclient.addHeader(req, "scouter_thread_id", Long.toString(ctx.threadId)); PluginHttpCallTrace.call(ctx, httpclient, req); diff --git a/scouter.agent.java/src/scouter/agent/util/DumpUtil.java b/scouter.agent.java/src/scouter/agent/util/DumpUtil.java index cb9407828..ffd871b9e 100644 --- a/scouter.agent.java/src/scouter/agent/util/DumpUtil.java +++ b/scouter.agent.java/src/scouter/agent/util/DumpUtil.java @@ -58,7 +58,7 @@ protected DumpUtil() { public static File getDumpFile(String prefix) { String name = prefix + "." + DateUtil.ymdhms(System.currentTimeMillis()) + ".dump"; - return new File(Configure.getInstance().dump_dir, name); + return new File(Configure.getInstance().mgr_dump_dir, name); } public static Pack triggerHeapHisto() { @@ -199,7 +199,7 @@ public void run() { ThreadUtil.wait(this); } - switch (conf.auto_dump_level) { + switch (conf.autodump_level) { case 1: DumpUtil.triggerThreadDump(); break; @@ -220,11 +220,11 @@ public void run() { private static long last_auto_dump = 0; public static void autoDump() { - if (conf.enable_auto_dump == false) + if (conf.autodump_enabled == false) return; long now = System.currentTimeMillis(); - if (now < last_auto_dump + conf.auto_dump_interval) + if (now < last_auto_dump + conf.autodump_interval_ms) return; last_auto_dump = now; diff --git a/scouter.agent.java/src/scouter/jdbc/DetectConnection.java b/scouter.agent.java/src/scouter/jdbc/DetectConnection.java index 35e2ef1a5..6f58a5093 100644 --- a/scouter.agent.java/src/scouter/jdbc/DetectConnection.java +++ b/scouter.agent.java/src/scouter/jdbc/DetectConnection.java @@ -28,9 +28,7 @@ import scouter.agent.trace.TraceContextManager; import scouter.agent.util.LeakableObject; import scouter.lang.step.MethodStep; -import scouter.util.HashUtil; import scouter.util.SysJMX; -import scouter.util.ThreadUtil; public class DetectConnection implements java.sql.Connection { private static CONNECTION_NOT_CLOSE error = new CONNECTION_NOT_CLOSE("connection leak detected"); @@ -48,7 +46,7 @@ public DetectConnection(java.sql.Connection inner) { service=ctx.serviceHash; txid =ctx.txid; } - if (conf.enable_leaktrace_fullstack) { + if (conf.summary_connection_leak_fullstack_enabled) { this.object = new LeakableObject(new CONNECTION_NOT_CLOSE(), inner.toString(), service, txid, true); } else { this.object = new LeakableObject(error, inner.toString(),service,txid, false); diff --git a/scouter.agent.java/src/scouter/test/Service24H.java b/scouter.agent.java/src/scouter/test/Service24H.java index f313c02d5..a2160c887 100644 --- a/scouter.agent.java/src/scouter/test/Service24H.java +++ b/scouter.agent.java/src/scouter/test/Service24H.java @@ -15,8 +15,8 @@ * limitations under the License. */ -package scouter.test; - +package scouter.test; + import java.util.Random; import java.util.Stack; @@ -37,78 +37,78 @@ import scouter.util.ShellArg; import scouter.util.SysJMX; import scouter.util.ThreadUtil; - -public class Service24H { - public static void main(String[] args) { - - ShellArg sh = new ShellArg(args); - String server = sh.get("-h", "127.0.0.1"); + +public class Service24H { + public static void main(String[] args) { + + ShellArg sh = new ShellArg(args); + String server = sh.get("-h", "127.0.0.1"); String port = sh.get("-p", "6100"); int tps =CastUtil.cint(sh.get("-tps","5000")); String type = sh.get("-type", "tomcat"); String name = sh.get("-name", "java"+SysJMX.getProcessPID()); - System.setProperty("scouter_type", type); - System.setProperty("scouter_name", name); + System.setProperty("obj_type", type); + System.setProperty("obj_name", name); System.setProperty("server.addr", server); - System.setProperty("server.port", port); - - - System.out.println("Scouter Test Simulation!!"); - System.out.println(" server = " + server + ":" +port); - System.out.println(" tcp = " + tps); - - LazyAgentBoot.boot(); + System.setProperty("server.port", port); + + + System.out.println("Scouter Test Simulation!!"); + System.out.println(" server = " + server + ":" +port); + System.out.println(" tcp = " + tps); + + LazyAgentBoot.boot(); TcpRequestMgr.getInstance(); - - double interval = 1000.0/tps; + + double interval = 1000.0/tps; long now = System.currentTimeMillis(); - - Random r = new Random(); - - long txcount = 0 ; - double tm = 0; - long last_unit = 0; - while (true) { + + Random r = new Random(); + + long txcount = 0 ; + double tm = 0; + long last_unit = 0; + while (true) { txcount++; String serviceName = "service" + (next(r, 1000)); int service_hash = HashUtil.hash(serviceName); long txid = KeyGen.next(); - profile(txid,service_hash); - long endtime = getEndTime(); - - - int elapsed =next(r, 10000); - int cpu = next(r, 10000); - int sqlCount = next(r, 100); - int sqlTime = next(r, 1000); - String remoteAddr = IPUtil.toString(DataOutputX.toBytes(next(r,255))); - String error = null; + profile(txid,service_hash); + long endtime = getEndTime(); + + + int elapsed =next(r, 10000); + int cpu = next(r, 10000); + int sqlCount = next(r, 100); + int sqlTime = next(r, 1000); + String remoteAddr = IPUtil.toString(DataOutputX.toBytes(next(r,255))); + String error = null; long visitor = KeyGen.next(); - + XLogPack pack = TraceMain.txperf(endtime, txid, service_hash,serviceName, elapsed, cpu, sqlCount, sqlTime, remoteAddr, error, visitor); TraceMain.metering(pack); - - long unit=endtime/5000; - if(last_unit!=unit){ - last_unit = unit; - System.out.println(DateUtil.timestamp(endtime) + " exe-tx=" + txcount+ " " + Configure.getInstance().objName); - } - tm = tm+interval; - if(tm>1){ - ThreadUtil.sleep((int)tm); - tm = tm - ((int)tm); + + long unit=endtime/5000; + if(last_unit!=unit){ + last_unit = unit; + System.out.println(DateUtil.timestamp(endtime) + " exe-tx=" + txcount+ " " + Configure.getInstance().getObjName()); + } + tm = tm+interval; + if(tm>1){ + ThreadUtil.sleep((int)tm); + tm = tm - ((int)tm); } long x = System.currentTimeMillis(); if(x-now >3000000) - break; + break; } - ThreadUtil.sleep(100000); - } + ThreadUtil.sleep(100000); + } static int rate[]={2,2,3,3,4, 5,6,7,8,9, @@ -116,7 +116,7 @@ public static void main(String[] args) { 7,6,5,4,3, 3,2,1,1}; static Stack stack = new Stack(); - static Random r = new Random(); + static Random r = new Random(); static long time= DateUtil.yyyymmdd(DateUtil.yyyymmdd()); private static long getEndTime() { if(stack.size()==0){ @@ -145,7 +145,7 @@ private static void profile(long txid, int serviceHash) { TraceContextManager.end(key); } - private static int next(Random r, int max) { - return Math.abs(r.nextInt() % max); - } + private static int next(Random r, int max) { + return Math.abs(r.nextInt() % max); + } } \ No newline at end of file diff --git a/scouter.agent.java/src/scouter/test/ShardMain.java b/scouter.agent.java/src/scouter/test/ShardMain.java index 9dc6f6856..facf56a45 100644 --- a/scouter.agent.java/src/scouter/test/ShardMain.java +++ b/scouter.agent.java/src/scouter/test/ShardMain.java @@ -77,7 +77,7 @@ public static void main(String[] args) { if (last_unit != unit) { last_unit = unit; System.out.println(DateUtil.timestamp(endtime) + " exe-tx=" + txcount + " " - + Configure.getInstance().objName); + + Configure.getInstance().getObjName()); } tm = tm + interval; if (tm > 1) { diff --git a/scouter.agent.java/src/scouter/test/TpsRush.java b/scouter.agent.java/src/scouter/test/TpsRush.java index 6e6845d1c..413cadc20 100644 --- a/scouter.agent.java/src/scouter/test/TpsRush.java +++ b/scouter.agent.java/src/scouter/test/TpsRush.java @@ -15,8 +15,8 @@ * limitations under the License. */ -package scouter.test; - +package scouter.test; + import java.util.Random; import scouter.AnyTrace; @@ -36,80 +36,80 @@ import scouter.util.ShellArg; import scouter.util.SysJMX; import scouter.util.ThreadUtil; - -public class TpsRush { - public static void main(String[] args) { - - ShellArg sh = new ShellArg(args); - String server = sh.get("-h", "127.0.0.1"); + +public class TpsRush { + public static void main(String[] args) { + + ShellArg sh = new ShellArg(args); + String server = sh.get("-h", "127.0.0.1"); String port = sh.get("-p", "6100"); int tps =CastUtil.cint(sh.get("-tps","1000")); String type = sh.get("-type", "java"); String name = sh.get("-name", "java"+SysJMX.getProcessPID()); - System.setProperty("scouter_type", type); - System.setProperty("scouter_name", name); + System.setProperty("obj_type", type); + System.setProperty("obj_name", name); System.setProperty("server.addr", server); - System.setProperty("server.port", port); - - - System.out.println("Scouter Test Simulation!!"); - System.out.println(" server = " + server + ":" +port); - System.out.println(" tcp = " + tps); - - LazyAgentBoot.boot(); - //RequestAgent.getInstance(); + System.setProperty("server.port", port); + + + System.out.println("Scouter Test Simulation!!"); + System.out.println(" server = " + server + ":" +port); + System.out.println(" tcp = " + tps); + + LazyAgentBoot.boot(); + //RequestAgent.getInstance(); TcpRequestMgr.getInstance(); - - double interval = 1000.0/tps; + + double interval = 1000.0/tps; long now = System.currentTimeMillis(); - - Random r = new Random(); - - long txcount = 0 ; - double tm = 0; - long last_unit = 0; - while (true) { + + Random r = new Random(); + + long txcount = 0 ; + double tm = 0; + long last_unit = 0; + while (true) { txcount++; String serviceName = "fdafafdafdafdafdfdsafaafda" + (next(r, 100000)); int service_hash = HashUtil.hash(serviceName); long txid = KeyGen.next(); - profile(txid,service_hash); - long endtime = System.currentTimeMillis(); - - - int elapsed =next(r, 10000); - int cpu = next(r, 10000); - int sqlCount = next(r, 100); - int sqlTime = next(r, 1000); - String remoteAddr = IPUtil.toString(DataOutputX.toBytes(next(r,255))); - String error = null; + profile(txid,service_hash); + long endtime = System.currentTimeMillis(); + + + int elapsed =next(r, 10000); + int cpu = next(r, 10000); + int sqlCount = next(r, 100); + int sqlTime = next(r, 1000); + String remoteAddr = IPUtil.toString(DataOutputX.toBytes(next(r,255))); + String error = null; long visitor = KeyGen.next(); - + XLogPack pack = TraceMain.txperf(endtime, txid, service_hash,serviceName, elapsed, cpu, sqlCount, sqlTime, remoteAddr, error, visitor); TraceMain.metering(pack); - - long unit=endtime/5000; - if(last_unit!=unit){ - last_unit = unit; - System.out.println(DateUtil.timestamp(endtime) + " exe-tx=" + txcount+ " " + Configure.getInstance().objName); - } - tm = tm+interval; - if(tm>1){ - ThreadUtil.sleep((int)tm); - tm = tm - ((int)tm); + + long unit=endtime/5000; + if(last_unit!=unit){ + last_unit = unit; + System.out.println(DateUtil.timestamp(endtime) + " exe-tx=" + txcount+ " " + Configure.getInstance().getObjName()); + } + tm = tm+interval; + if(tm>1){ + ThreadUtil.sleep((int)tm); + tm = tm - ((int)tm); } long x = System.currentTimeMillis(); if(x-now >1000000) - break; + break; } - ThreadUtil.sleep(100000); - } - + ThreadUtil.sleep(100000); + } + private static void profile(long txid, int serviceHash) { TraceContext ctx = new TraceContext(false); ctx.txid=txid; @@ -125,7 +125,7 @@ private static void profile(long txid, int serviceHash) { TraceContextManager.end(key); } - private static int next(Random r, int max) { - return Math.abs(r.nextInt() % max); - } + private static int next(Random r, int max) { + return Math.abs(r.nextInt() % max); + } } \ No newline at end of file diff --git a/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java b/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java index bc26a7adb..441c1c00a 100644 --- a/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java +++ b/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java @@ -45,12 +45,12 @@ public class HttpTrace implements IHttpTrace { public HttpTrace() { Configure conf = Configure.getInstance(); - this.remote_by_header = StringUtil.isEmpty(conf.http_remote_ip_header_key) == false; - this.http_remote_ip_header_key = conf.http_remote_ip_header_key; + this.remote_by_header = StringUtil.isEmpty(conf.trace_http_client_ip_header_key) == false; + this.http_remote_ip_header_key = conf.trace_http_client_ip_header_key; ConfObserver.add(HttpTrace.class.getName(), new Runnable() { public void run() { - String x = Configure.getInstance().http_remote_ip_header_key; + String x = Configure.getInstance().trace_http_client_ip_header_key; if (CompareUtil.equals(x, http_remote_ip_header_key) == false) { remote_by_header = StringUtil.isEmpty(x) == false; http_remote_ip_header_key = x; @@ -83,7 +83,7 @@ public void start(TraceContext ctx, Object req, Object res) { ctx.serviceHash = HashUtil.hash(ctx.serviceName); // - if(ctx.serviceHash == conf.enduser_perf_endpoint_hash){ + if(ctx.serviceHash == conf.getEndUserPerfEndpointHash()){ ctx.isStaticContents=true; enduser(request); return; @@ -99,12 +99,12 @@ public void start(TraceContext ctx, Object req, Object res) { ctx.remoteIp = getRemoteAddr(request); try { - switch (conf.mode_userid) { + switch (conf.trace_user_mode) { case 2: ctx.userid = UseridUtil.getUserid(request, response); break; case 1: - ctx.userid = UseridUtil.getUseridCustom(request, response, conf.userid_jsessionid); + ctx.userid = UseridUtil.getUseridCustom(request, response, conf.trace_user_session_key); if (ctx.userid == 0 && ctx.remoteIp != null) { ctx.userid = HashUtil.hash(ctx.remoteIp); } @@ -129,18 +129,18 @@ public void start(TraceContext ctx, Object req, Object res) { ctx.userAgentString = userAgent; } dump(ctx.profile, request, ctx); - if (conf.enable_trace_e2e) { + if (conf.trace_interservice_enabled) { try { - String gxid = request.getHeader(conf.gxid); + String gxid = request.getHeader(conf.trace_interservice_gxid_header_key); if (gxid != null) { ctx.gxid = Hexa32.toLong32(gxid); } - String txid = request.getHeader(conf.this_txid); + String txid = request.getHeader(conf.trace_interservice_callee_header_key); if (txid != null) { ctx.txid = Hexa32.toLong32(txid); ctx.is_child_tx = true; } - String caller = request.getHeader(conf.caller_txid); + String caller = request.getHeader(conf.trace_interservice_caller_header_key); if (caller != null) { ctx.caller = Hexa32.toLong32(caller); ctx.is_child_tx = true; @@ -149,25 +149,25 @@ public void start(TraceContext ctx, Object req, Object res) { } } - if (conf.enable_response_gxid && !ctx.isStaticContents) { + if (conf.trace_response_gxid_enabled && !ctx.isStaticContents) { try { if (ctx.gxid == 0) ctx.gxid = ctx.txid; String resGxId = Hexa32.toString32(ctx.gxid) + ":" + ctx.startTime; - response.setHeader(conf.gxid, resGxId); + response.setHeader(conf.trace_interservice_gxid_header_key, resGxId); - Cookie c = new Cookie(conf.gxid, resGxId); + Cookie c = new Cookie(conf.trace_interservice_gxid_header_key, resGxId); response.addCookie(c); } catch (Throwable t) { } } - if (conf.enable_trace_web) { + if (conf.trace_webserver_enabled) { try { - ctx.web_name = request.getHeader(conf.key_web_name); - String web_time = request.getHeader(conf.key_web_time); + ctx.web_name = request.getHeader(conf.trace_webserver_name_header_key); + String web_time = request.getHeader(conf.trace_webserver_time_header_key); if (web_time != null) { int x = web_time.indexOf("t="); if (x >= 0) { @@ -229,14 +229,14 @@ public void end(TraceContext ctx, Object req, Object res) { private static void dump(IProfileCollector p, HttpServletRequest request, TraceContext ctx) { Configure conf = Configure.getInstance(); - if (conf.http_debug_querystring) { + if (conf.profile_http_querystring_enabled) { String msg = request.getMethod() + " ?" + StringUtil.trimToEmpty(request.getQueryString()); MessageStep step = new MessageStep(msg); step.start_time = (int) (System.currentTimeMillis() - ctx.startTime); p.add(step); } - if (conf.http_debug_header) { - if (conf.http_debug_header_url == null || ctx.serviceName.indexOf(conf.http_debug_header_url) >= 0) { + if (conf.profile_http_header_enabled) { + if (conf.profile_http_header_url_prefix == null || ctx.serviceName.indexOf(conf.profile_http_header_url_prefix) >= 0) { Enumeration en = request.getHeaderNames(); if (en != null) { int start_time = (int) (System.currentTimeMillis() - ctx.startTime); @@ -256,8 +256,8 @@ private static void dump(IProfileCollector p, HttpServletRequest request, TraceC } } } - if (conf.http_debug_parameter) { - if (conf.http_debug_parameter_url == null || ctx.serviceName.indexOf(conf.http_debug_parameter_url) >= 0) { + if (conf.profile_http_parameter_enabled) { + if (conf.profile_http_parameter_url_prefix == null || ctx.serviceName.indexOf(conf.profile_http_parameter_url_prefix) >= 0) { String ctype = request.getContentType(); if (ctype != null && ctype.indexOf("multipart") >= 0) return; From f9cb83e5ef49d65028010ad3e8563c1e5bca2064 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Sun, 6 Dec 2015 21:43:15 +0900 Subject: [PATCH 27/42] ***** collector - rename configure keys ***** --- .../src/scouter/server/Configure.java | 276 +++++++++--------- .../src/scouter/server/Logger.scala | 48 +-- scouter.server/src/scouter/server/Main.java | 2 +- .../scouter/server/core/AgentManager.scala | 2 +- .../scouter/server/core/AlertSummary.scala | 46 +-- .../scouter/server/core/Auto5MSampling.scala | 38 +-- .../server/core/AutoDeleteScheduler.java | 24 +- .../src/scouter/server/core/ProfileCore.scala | 44 +-- .../src/scouter/server/core/SqlTables.scala | 2 +- .../src/scouter/server/core/XLogCore.scala | 5 +- .../src/scouter/server/db/DBCtr.scala | 32 +- .../src/scouter/server/db/XLogProfileWR.scala | 2 +- .../scouter/server/db/io/zip/GZipStore.java | 2 +- .../scouter/server/db/io/zip/IOChannel.java | 22 +- .../server/db/xlog/XLogDataReader.scala | 38 +-- .../server/db/xlog/XLogDataWriter.scala | 54 ++-- .../db/xlog/XLogProfileDataReader.scala | 38 +-- .../db/xlog/XLogProfileDataWriter.scala | 42 +-- .../scouter/server/geoip/GISDataUtil.scala | 8 +- .../netio/data/MultiPacketProcessor.scala | 38 +-- .../server/netio/data/NetDataProcessor.scala | 24 +- .../server/netio/data/net/DataUdpServer.scala | 44 +-- .../netio/service/ServiceHandlingProxy.java | 2 +- .../netio/service/handle/LoginService.scala | 50 ++-- .../netio/service/handle/XLogService.scala | 4 +- .../netio/service/net/TcpAgentManager.scala | 2 +- .../netio/service/net/TcpAgentWorker.scala | 10 +- .../server/netio/service/net/TcpServer.scala | 21 +- .../netio/service/net/TcpServiceWorker.scala | 31 +- .../src/scouter/server/plugin/IXLog.java | 2 +- .../scouter/server/tagcnt/core/CountEnv.scala | 4 +- 31 files changed, 485 insertions(+), 472 deletions(-) diff --git a/scouter.server/src/scouter/server/Configure.java b/scouter.server/src/scouter/server/Configure.java index 8db98dc7f..6bfbd7b52 100644 --- a/scouter.server/src/scouter/server/Configure.java +++ b/scouter.server/src/scouter/server/Configure.java @@ -56,6 +56,91 @@ public final static synchronized Configure getInstance() { return instance; } + + //SERVER + public String server_id = SysJMX.getHostName(); + + //Log + public boolean log_tcp_action_enabled = false; + public boolean log_udp_multipacket = false; + public boolean log_expired_multipacket = true; + public boolean log_udp_packet = false; + public boolean log_udp_counter = false; + public boolean log_udp_xlog = false; + public boolean log_udp_profile = false; + public boolean log_udp_text = false; + public boolean log_udp_alert = false; + public boolean log_udp_object = false; + public boolean log_udp_status = false; + public boolean log_udp_stack = false; + public boolean log_udp_summary = false; + public boolean log_service_handler_list = false; + public boolean log_rotation_enabled = true; + public int log_keep_days = 31; + + //Network + public String net_udp_listen_ip = "0.0.0.0"; + public int net_udp_listen_port = NetConstants.SERVER_UDP_PORT; + public String net_tcp_listen_ip = "0.0.0.0"; + public int net_tcp_listen_port = NetConstants.SERVER_TCP_PORT; + public int net_tcp_client_so_timeout_ms = 8000; + public int net_tcp_agent_so_timeout_ms = 60000; + public int net_tcp_agent_keepalive_interval_ms = 5000; + public int net_tcp_get_agent_connection_wait_ms = 1000; + public int net_udp_packet_buffer_size = 65535; + public int net_udp_so_rcvbuf_size = 1024 * 1024 * 4; + public int _net_udp_worker_thread_count = 3; + public int net_tcp_service_pool_size = 100; + + //Dir + public String db_dir = "./database"; + public String log_dir = "./logs"; + public String plugin_dir = "./plug-in"; + + //Object + public int object_deadtime_ms = 8000; + + //Compress + public boolean compress_xlog_enabled = false; + public boolean compress_profile_enabled = false; + public int _compress_write_buffer_block_count = 3; + public int _compress_read_cache_block_count = 3; + public long _compress_read_cache_expired_ms = DateUtil.MILLIS_PER_MINUTE; + public int _compress_dailycount_header_cache_size = 3; + public int _compress_write_thread = 2; + + //Auto + public boolean _auto_5m_sampling = true; + + //Manage + public boolean mgr_purge_enabled = true; + public boolean mgr_purge_only_xlog_enabled = false; + public int mgr_purge_disk_usage_pct = 80; + public int mgr_purge_keep_days = 0; + public StringSet mgr_log_ignore_ids = new StringSet(); + + //XLog + public int xlog_queue_size = 10000; + public int xlog_realtime_lower_bound_ms = 0; + public int xlog_pasttime_lower_bound_ms = 0; + public int xlog_profile_save_lower_bound_ms = 0; + + //Profile + public int profile_queue_size = 1000; + + //GeoIP + public boolean geoip_enabled = true; + public String geoip_data_city_file = "./GeoLiteCity.dat"; + + //SQL + public boolean sql_table_parsing_enabled = true; + + //TagCount + public boolean tagcnt_enabled = false; + + //Summary + public boolean summary_alert_enabled = true; + private Configure() { reload(false); } @@ -124,151 +209,82 @@ public synchronized boolean reload(boolean force) { return true; } - public int xlog_queue_size = 100000; - public int xlog_profile_queue_size = 1000; - public boolean debug_net = false; - - public String udp_host = "0.0.0.0"; - public int udp_port = NetConstants.SERVER_UDP_PORT; - public int tcp_port = NetConstants.SERVER_TCP_PORT; - public int tcp_client_so_timeout = 8000; - public int tcp_agent_so_timeout = 60000; - public int tcp_agent_keepalive = 5000; - public int tcp_agent_max_wait = 1000; - - public String hostname = SysJMX.getHostName(); - public String db_root = "./database"; - public String log_dir = "./logs"; - public String plugin_dir = "./plug-in"; - - public int agent_deadtime = 8000; - - public boolean gzip_xlog = false; - public boolean gzip_profile = false; - public int gzip_writing_block = 3; - public int gzip_read_cache_block = 3; - public long gzip_read_cache_time = DateUtil.MILLIS_PER_MINUTE; - public int gzip_unitcount_header_cache = 5; - public int udp_buffer = 65535; - public int udp_so_rcvbuf = 1024 * 1024 * 4; - public boolean debug_udp_multipacket; - public boolean debug_expired_multipacket = true; - public int gzip_writing_block_thread = 2; - - - public boolean debug_udp_packet = false; - public boolean debug_udp_counter = false; - public boolean debug_udp_xlog = false; - public boolean debug_udp_profile = false; - public boolean debug_udp_text = false; - public boolean debug_udp_alert = false; - public boolean debug_udp_object = false; - public boolean debug_udp_status = false; - public boolean debug_udp_stack = false; - public boolean debug_udp_summary = false; - public boolean debug_request; - - public boolean auto_5m_sampling = true; - - public boolean log_rotation = true; - public int log_keep_dates = 365; - - public int xlog_realtime_limit = 0; - public int xlog_pasttime_limit = 0; - - public boolean auto_delete_data = true; - public boolean auto_delete_only_xlog = false; - public int auto_delete_max_percent = 80; - public int auto_delete_retain_days = 0; - public int num_of_net_processor = 4; - - public String geoip_data_city = "./GeoLiteCity.dat"; - public boolean enable_geoip = true; - - public int xlog_profile_save_time_limit = 0; - public boolean enable_sql_parsing = true; - - public StringSet log_ignore = new StringSet(); - public boolean tagcnt_enabled = false; - - public int tcp_server_pool_size = 100; - public boolean enable_alert_summary=true; - - public static boolean WORKABLE = true; + public static boolean WORKABLE = true; private void apply() { - this.xlog_queue_size = getInt("xlog_queue_size", 100000); - this.xlog_profile_queue_size = getInt("xlog_profile_queue_size", 1000); - this.debug_net = getBoolean("debug_net", false); - - this.udp_host = getValue("udp_host", "0.0.0.0"); - this.udp_port = getInt("udp_port", NetConstants.SERVER_UDP_PORT); - this.tcp_port = getInt("tcp_port", NetConstants.SERVER_TCP_PORT); - this.tcp_client_so_timeout = getInt("tcp_client_so_timeout", 8000); - this.tcp_agent_so_timeout = getInt("tcp_agent_so_timeout", 60000); - this.tcp_agent_keepalive = getInt("tcp_agent_keepalive", 5000); - this.tcp_agent_max_wait = getInt("tcp_agent_max_wait", 1000); - - this.hostname = getValue("hostname", SysJMX.getHostName()); - this.db_root = getValue("db_root", "./database"); + this.xlog_queue_size = getInt("xlog_queue_size", 10000); + this.profile_queue_size = getInt("profile_queue_size", 1000); + this.log_tcp_action_enabled = getBoolean("log_tcp_action_enabled", false); + + this.net_udp_listen_ip = getValue("net_udp_listen_ip", "0.0.0.0"); + this.net_udp_listen_port = getInt("net_udp_listen_port", NetConstants.SERVER_UDP_PORT); + this.net_tcp_listen_ip = getValue("net_tcp_listen_ip", "0.0.0.0"); + this.net_tcp_listen_port = getInt("net_tcp_listen_port", NetConstants.SERVER_TCP_PORT); + this.net_tcp_client_so_timeout_ms = getInt("net_tcp_client_so_timeout_ms", 8000); + this.net_tcp_agent_so_timeout_ms = getInt("net_tcp_agent_so_timeout_ms", 60000); + this.net_tcp_agent_keepalive_interval_ms = getInt("net_tcp_agent_keepalive_interval_ms", 5000); + this.net_tcp_get_agent_connection_wait_ms = getInt("net_tcp_get_agent_connection_wait_ms", 1000); + + this.server_id = getValue("server_id", SysJMX.getHostName()); + this.db_dir = getValue("db_dir", "./database"); this.log_dir = getValue("log_dir", "./logs"); this.plugin_dir = getValue("plugin_dir", "./plug-in"); - this.agent_deadtime = getInt("agent_deadtime", 8000); + this.object_deadtime_ms = getInt("object_deadtime_ms", 8000); - this.gzip_xlog = getBoolean("gzip_xlog", false); - this.gzip_profile = getBoolean("gzip_profile", false); - this.gzip_writing_block = getInt("gzip_writing_block", 3); - this.gzip_unitcount_header_cache = getInt("gzip_unitcount_header_cache", 5); - this.gzip_read_cache_block = getInt("gzip_read_cache_block", 3); - this.gzip_read_cache_time = getLong("gzip_read_cache_time", DateUtil.MILLIS_PER_MINUTE); - this.gzip_writing_block_thread = getInt("gzip_writing_block_thread", 2); + this.compress_xlog_enabled = getBoolean("compress_xlog_enabled", false); + this.compress_profile_enabled = getBoolean("compress_profile_enabled", false); + this._compress_write_buffer_block_count = getInt("_compress_write_buffer_block_count", 3); + this._compress_dailycount_header_cache_size = getInt("_compress_dailycount_header_cache_size", 3); + this._compress_read_cache_block_count = getInt("_compress_read_cache_block_count", 3); + this._compress_read_cache_expired_ms = getLong("_compress_read_cache_expired_ms", DateUtil.MILLIS_PER_MINUTE); + this._compress_write_thread = getInt("_compress_write_thread", 2); - this.udp_buffer = getInt("udp_buffer", 65535); + this.net_udp_packet_buffer_size = getInt("net_udp_packet_buffer_size", 65535); int default_so_rcvbuf = 1024 * 1024 * 4; if (SystemUtil.IS_AIX || SystemUtil.IS_HP_UX) { default_so_rcvbuf = 0; } - this.udp_so_rcvbuf = getInt("dataudp_so_rcvbuf", default_so_rcvbuf); - this.debug_expired_multipacket = getBoolean("debug_expired_multipacket", true); - this.debug_udp_multipacket = getBoolean("debug_udp_multipacket", false); - this.debug_udp_packet = getBoolean("debug_udp_packet", false); - this.debug_udp_counter = getBoolean("debug_udp_counter", false); - this.debug_udp_xlog = getBoolean("debug_udp_xlog", false); - this.debug_udp_profile = getBoolean("debug_udp_profile", false); - this.debug_udp_text = getBoolean("debug_udp_text", false); - this.debug_udp_alert = getBoolean("debug_udp_alert", false); - this.debug_udp_object = getBoolean("debug_udp_object", false); - this.debug_udp_status = getBoolean("debug_udp_status", false); - this.debug_udp_stack = getBoolean("debug_udp_stack", false); - this.debug_udp_summary = getBoolean("debug_udp_summary", false); - this.debug_request = getBoolean("debug_request", false); - - this.auto_5m_sampling = getBoolean("auto_5m_sampling", true); - - this.log_rotation = getBoolean("log_rotation", true); - this.log_keep_dates = getInt("log_keep_dates", 365); - - this.xlog_realtime_limit = getInt("xlog_realtime_limit", 0); - this.xlog_pasttime_limit = getInt("xlog_pasttime_limit", 0); - this.auto_delete_data = getBoolean("auto_delete_data", true); - this.auto_delete_only_xlog = getBoolean("auto_delete_only_xlog", false); - this.auto_delete_max_percent = getInt("auto_delete_max_percent", 80); - this.auto_delete_retain_days = getInt("auto_delete_retain_days", 0); - this.num_of_net_processor = getInt("num_of_net_processor", 4); - this.geoip_data_city = getValue("geoip_data_city", "./GeoLiteCity.dat"); - this.enable_geoip = getBoolean("enable_geoip", true); - - this.xlog_profile_save_time_limit = getInt("xlog_profile_save_time_limit", 0); - this.enable_sql_parsing = getBoolean("enable_parse_sql", true); - - this.log_ignore = getStringSet("log_ignore", ","); + this.net_udp_so_rcvbuf_size = getInt("net_udp_so_rcvbuf_size", default_so_rcvbuf); + this.log_expired_multipacket = getBoolean("log_expired_multipacket", true); + this.log_udp_multipacket = getBoolean("log_udp_multipacket", false); + this.log_udp_packet = getBoolean("log_udp_packet", false); + this.log_udp_counter = getBoolean("log_udp_counter", false); + this.log_udp_xlog = getBoolean("log_udp_xlog", false); + this.log_udp_profile = getBoolean("log_udp_profile", false); + this.log_udp_text = getBoolean("log_udp_text", false); + this.log_udp_alert = getBoolean("log_udp_alert", false); + this.log_udp_object = getBoolean("log_udp_object", false); + this.log_udp_status = getBoolean("log_udp_status", false); + this.log_udp_stack = getBoolean("log_udp_stack", false); + this.log_udp_summary = getBoolean("log_udp_summary", false); + this.log_service_handler_list = getBoolean("log_service_handler_list", false); + + this._auto_5m_sampling = getBoolean("_auto_5m_sampling", true); + + this.log_rotation_enabled = getBoolean("log_rotation_enabled", true); + this.log_keep_days = getInt("log_keep_days", 31); + + this.xlog_realtime_lower_bound_ms = getInt("xlog_realtime_lower_bound_ms", 0); + this.xlog_pasttime_lower_bound_ms = getInt("xlog_pasttime_lower_bound_ms", 0); + this.mgr_purge_enabled = getBoolean("mgr_purge_enabled", true); + this.mgr_purge_only_xlog_enabled = getBoolean("mgr_purge_only_xlog_enabled", false); + this.mgr_purge_disk_usage_pct = getInt("mgr_purge_disk_usage_pct", 80); + this.mgr_purge_keep_days = getInt("mgr_purge_keep_days", 0); + this._net_udp_worker_thread_count = getInt("_net_udp_worker_thread_count", 3); + this.geoip_data_city_file = getValue("geoip_data_city_file", "./GeoLiteCity.dat"); + this.geoip_enabled = getBoolean("geoip_enabled", true); + + this.xlog_profile_save_lower_bound_ms = getInt("xlog_profile_save_lower_bound_ms", 0); + this.sql_table_parsing_enabled = getBoolean("sql_table_parsing_enabled", true); + + this.mgr_log_ignore_ids = getStringSet("mgr_log_ignore_ids", ","); this.tagcnt_enabled = getBoolean("tagcnt_enabled", false); - this.tcp_server_pool_size = getInt("tcp_server_pool_size", 100); - this.enable_alert_summary= getBoolean("enable_alert_summary", true); + this.net_tcp_service_pool_size = getInt("net_tcp_service_pool_size", 100); + this.summary_alert_enabled = getBoolean("summary_alert_enabled", true); ConfObserver.exec(); } diff --git a/scouter.server/src/scouter/server/Logger.scala b/scouter.server/src/scouter/server/Logger.scala index 63d0b7118..cbf77e3d5 100644 --- a/scouter.server/src/scouter/server/Logger.scala +++ b/scouter.server/src/scouter/server/Logger.scala @@ -1,18 +1,18 @@ -/* - * Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package scouter.server; @@ -71,7 +71,7 @@ object Logger { } private def checkOk(id: String, sec: Int): Boolean = { - if (Configure.getInstance().log_ignore.hasKey(id)) + if (Configure.getInstance().mgr_log_ignore_ids.hasKey(id)) return false; if (sec > 0) { val last = lastLog.get(id); @@ -131,11 +131,11 @@ object Logger { ConfObserver.put("Logger", new Runnable() { override def run() { - if (CompareUtil.equals(lastDir, conf.log_dir) == false || lastFileRotation != conf.log_rotation) { + if (CompareUtil.equals(lastDir, conf.log_dir) == false || lastFileRotation != conf.log_rotation_enabled) { FileUtil.close(pw) pw = null lastDir = conf.log_dir; - lastFileRotation = conf.log_rotation; + lastFileRotation = conf.log_rotation_enabled; } } }); @@ -145,10 +145,10 @@ object Logger { if (pw == null) { lastDataUnit = DateUtil.getDateUnit(); lastDir = conf.log_dir; - lastFileRotation = conf.log_rotation; + lastFileRotation = conf.log_rotation_enabled; new File(lastDir).mkdirs(); - if (conf.log_rotation) { + if (conf.log_rotation_enabled) { val fw = new FileWriter(new File(conf.log_dir, "server-" + DateUtil.yyyymmdd() + ".log"), true); pw = new PrintWriter(fw); } else { @@ -160,9 +160,9 @@ object Logger { } protected def clearOldLog() { - if (conf.log_rotation == false) + if (conf.log_rotation_enabled == false) return ; - if (conf.log_keep_dates <= 0) + if (conf.log_keep_days <= 0) return ; val nowUnit = DateUtil.getDateUnit(); val dir = new File(conf.log_dir); @@ -189,7 +189,7 @@ object Logger { try { val d = DateUtil.yyyymmdd(date); val fileUnit = DateUtil.getDateUnit(d); - if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_dates) { + if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_days) { files(i).delete(); } } catch { @@ -200,4 +200,4 @@ object Logger { } -} +} diff --git a/scouter.server/src/scouter/server/Main.java b/scouter.server/src/scouter/server/Main.java index 0abe2957c..a61388a89 100644 --- a/scouter.server/src/scouter/server/Main.java +++ b/scouter.server/src/scouter/server/Main.java @@ -78,7 +78,7 @@ public void run() { // System.out.println("This product includes GeoLite data created by MaxMind, available from"); // System.out.println("http://www.maxmind.com"); // System.out.println("download: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"); - // System.out.println("add configure: geoip_data_city=/GeoLiteCity.dat"); + // System.out.println("add configure: geoip_data_city_file=/GeoLiteCity.dat"); while (true) { if (exit.exists() == false) { ShutdownManager.shutdown(); diff --git a/scouter.server/src/scouter/server/core/AgentManager.scala b/scouter.server/src/scouter/server/core/AgentManager.scala index c7dcf81da..8ac8b9188 100644 --- a/scouter.server/src/scouter/server/core/AgentManager.scala +++ b/scouter.server/src/scouter/server/core/AgentManager.scala @@ -60,7 +60,7 @@ object AgentManager { } ThreadScala.startDaemon("scouter.server.core.AgentManager", { CoreRun.running }, 1000) { val now = System.currentTimeMillis(); - val deadtime = Configure.getInstance().agent_deadtime; + val deadtime = Configure.getInstance().object_deadtime_ms; val en = objMap.objects(); var primaryObjCount = 0; while (en.hasMoreElements()) { diff --git a/scouter.server/src/scouter/server/core/AlertSummary.scala b/scouter.server/src/scouter/server/core/AlertSummary.scala index 9a35c7877..d15909e00 100644 --- a/scouter.server/src/scouter/server/core/AlertSummary.scala +++ b/scouter.server/src/scouter/server/core/AlertSummary.scala @@ -1,18 +1,18 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.server.core; @@ -30,7 +30,7 @@ import scouter.server.Configure object AlertSummary { val conf =Configure.getInstance() val queue = new RequestQueue[AlertPack](CoreRun.MAX_QUE_SIZE); - var master = new HashMap[Int, HashMap[String, (Byte, Int)]]() + var master = new HashMap[Int, HashMap[String, (Byte, Int)]]() var typeMap = new HashMap[Int, String]() ThreadScala.startFixedRate(DateUtil.MILLIS_PER_FIVE_MINUTE) { doFlush() } @@ -41,7 +41,7 @@ object AlertSummary { var t1 = master.get(p.objHash); if (t1 == null) { t1 = new HashMap[String, (Byte, Int)](); - master.put(p.objHash, t1); + master.put(p.objHash, t1); typeMap.put(p.objHash, p.objType); } var d1 = t1.get(p.title); @@ -53,8 +53,8 @@ object AlertSummary { } } - def add(p: AlertPack): Unit = { - if(conf.enable_alert_summary==false) + def add(p: AlertPack): Unit = { + if(conf.summary_alert_enabled==false) return; val ok = queue.put(p) if (ok == false) { @@ -62,7 +62,7 @@ object AlertSummary { } } - def doFlush(): Unit = { + def doFlush(): Unit = { if (master.size == 0) return ; val table = master; @@ -74,7 +74,7 @@ object AlertSummary { val sp = new SummaryPack(); sp.time = stime; - sp.objHash = ent.getKey(); + sp.objHash = ent.getKey(); sp.objType = typeMap.get(sp.objHash); sp.stype = SummaryEnum.ALERT; @@ -90,9 +90,9 @@ object AlertSummary { levelLv.add(ent2.getValue()._1); countLv.add(ent2.getValue()._2); inx += 1; - } + } SummaryCore.add(sp); } } -} +} diff --git a/scouter.server/src/scouter/server/core/Auto5MSampling.scala b/scouter.server/src/scouter/server/core/Auto5MSampling.scala index e14363dc6..3b0825b9c 100644 --- a/scouter.server/src/scouter/server/core/Auto5MSampling.scala +++ b/scouter.server/src/scouter/server/core/Auto5MSampling.scala @@ -1,20 +1,20 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package scouter.server.core; @@ -38,7 +38,7 @@ import scouter.server.util.ThreadScala object Auto5MSampling { ThreadScala.startFixedRate(DateUtil.MILLIS_PER_FIVE_MINUTE) { - if (Configure.getInstance().auto_5m_sampling == true) { + if (Configure.getInstance()._auto_5m_sampling == true) { val work = map; map = new HashMap[CounterKey, Value](); @@ -47,7 +47,7 @@ object Auto5MSampling { val key = itr.next(); val key5m = new CounterKey(key.objHash, key.counter, FIVE_MIN_CODE); if (map5m.contains(key5m) == false) { - // System.out.println("AUTO 5M " +key); + // System.out.println("AUTO 5M " +key); val value = work.get(key); val now = System.currentTimeMillis(); diff --git a/scouter.server/src/scouter/server/core/AutoDeleteScheduler.java b/scouter.server/src/scouter/server/core/AutoDeleteScheduler.java index e1741bd49..24360edb2 100644 --- a/scouter.server/src/scouter/server/core/AutoDeleteScheduler.java +++ b/scouter.server/src/scouter/server/core/AutoDeleteScheduler.java @@ -46,10 +46,10 @@ private AutoDeleteScheduler() { dbDir = new File(DBCtr.getRootPath()); ConfObserver.put(AutoDeleteScheduler.class.getName(), new Runnable() { public void run() { - if (conf.auto_delete_data != brun - || conf.auto_delete_max_percent != maxPercent - || conf.auto_delete_retain_days != retainDays - || conf.auto_delete_only_xlog != delOnlyXLog) { + if (conf.mgr_purge_enabled != brun + || conf.mgr_purge_disk_usage_pct != maxPercent + || conf.mgr_purge_keep_days != retainDays + || conf.mgr_purge_only_xlog_enabled != delOnlyXLog) { applyConf(); lastCheckDate = null; deletedDays.clear(); @@ -59,18 +59,18 @@ public void run() { } private void applyConf() { - brun = conf.auto_delete_data; - maxPercent = conf.auto_delete_max_percent; - retainDays = conf.auto_delete_retain_days; - delOnlyXLog = conf.auto_delete_only_xlog; + brun = conf.mgr_purge_enabled; + maxPercent = conf.mgr_purge_disk_usage_pct; + retainDays = conf.mgr_purge_keep_days; + delOnlyXLog = conf.mgr_purge_only_xlog_enabled; } public void run() { while(CoreRun.running()) { - if (conf.auto_delete_data) { + if (conf.mgr_purge_enabled) { String today = DateUtil.yyyymmdd(); if (SystemUtil.IS_JAVA_1_5 == false) { - int maxPercent = conf.auto_delete_max_percent; + int maxPercent = conf.mgr_purge_disk_usage_pct; if (maxPercent > 0) { long totalSpace = dbDir.getTotalSpace(); long usuableSpace = dbDir.getUsableSpace(); @@ -87,7 +87,7 @@ public void run() { } } } - int retainDays = conf.auto_delete_retain_days; + int retainDays = conf.mgr_purge_keep_days; if (retainDays > 0) { if (today.equals(lastCheckDate) == false) { lastCheckDate = today; @@ -113,7 +113,7 @@ public void run() { private void deleteData(String yyyymmdd) { try { File f = null; - if (conf.auto_delete_only_xlog) { + if (conf.mgr_purge_only_xlog_enabled) { f = new File(dbDir, yyyymmdd + XLogWR.dir()); } else { f = new File(dbDir, yyyymmdd); diff --git a/scouter.server/src/scouter/server/core/ProfileCore.scala b/scouter.server/src/scouter/server/core/ProfileCore.scala index 4291c933c..3d330712b 100644 --- a/scouter.server/src/scouter/server/core/ProfileCore.scala +++ b/scouter.server/src/scouter/server/core/ProfileCore.scala @@ -1,19 +1,19 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * */ package scouter.server.core; @@ -30,15 +30,15 @@ import scouter.util.RequestQueue object ProfileCore { - val queue = new RequestQueue[XLogProfilePack](1000); - val conf = Configure.getInstance(); + val queue = new RequestQueue[XLogProfilePack](conf.profile_queue_size); + ThreadScala.startDaemon("scouter.server.core.ProfileCore", { CoreRun.running }) { - val m = queue.get(); + val m = queue.get(); ServerStat.put("profile.core.queue",queue.size()); - if (BytesUtil.getLength(m.profile) > 0) { + if (BytesUtil.getLength(m.profile) > 0) { PlugInManager.profile(m) - if (conf.xlog_profile_save_time_limit <= m.elapsed) { + if (conf.xlog_profile_save_lower_bound_ms <= m.elapsed) { XLogProfileWR.add(m.time, m.txid, m.profile) } } @@ -53,4 +53,4 @@ object ProfileCore { } } -} +} diff --git a/scouter.server/src/scouter/server/core/SqlTables.scala b/scouter.server/src/scouter/server/core/SqlTables.scala index 3abd2d47b..3faedf55c 100644 --- a/scouter.server/src/scouter/server/core/SqlTables.scala +++ b/scouter.server/src/scouter/server/core/SqlTables.scala @@ -58,7 +58,7 @@ object SqlTables { * 어느정도 서버에 부담을 줄지 알수 없다. 따라서 이문제를 해결하기 위해 parse 여부를 옵션 처리한다. */ def add(date: String, sqlHash: Int, sqlText: String) { - if (Configure.getInstance().enable_sql_parsing == false) + if (Configure.getInstance().sql_table_parsing_enabled == false) return ; val data = new Data(date, sqlHash, sqlText); var ok = queue1.put(data); diff --git a/scouter.server/src/scouter/server/core/XLogCore.scala b/scouter.server/src/scouter/server/core/XLogCore.scala index 50d38742f..4c83d7f34 100644 --- a/scouter.server/src/scouter/server/core/XLogCore.scala +++ b/scouter.server/src/scouter/server/core/XLogCore.scala @@ -36,13 +36,12 @@ import scouter.util.RequestQueue object XLogCore { - val queue = new RequestQueue[XLogPack](CoreRun.MAX_QUE_SIZE); - val conf = Configure.getInstance(); + val queue = new RequestQueue[XLogPack](conf.xlog_queue_size); def calc(m: XLogPack) = { XLogGroupUtil.process(m); - if (conf.enable_geoip) { + if (conf.geoip_enabled) { GeoIpUtil.setNationAndCity(m); } XLogGroupPerf.add(m); diff --git a/scouter.server/src/scouter/server/db/DBCtr.scala b/scouter.server/src/scouter/server/db/DBCtr.scala index ab0d67156..ab78d9be7 100644 --- a/scouter.server/src/scouter/server/db/DBCtr.scala +++ b/scouter.server/src/scouter/server/db/DBCtr.scala @@ -1,18 +1,18 @@ -/* - * Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package scouter.server.db; @@ -27,7 +27,7 @@ object DBCtr { val MAX_DIV = 20; val LARGE_MAX_QUE_SIZE = 100000; - def getRootPath() = Configure.getInstance().db_root + def getRootPath() = Configure.getInstance().db_dir var running = true; ShutdownManager.add(new IShutdown() { diff --git a/scouter.server/src/scouter/server/db/XLogProfileWR.scala b/scouter.server/src/scouter/server/db/XLogProfileWR.scala index 64d5f52ef..616cea40a 100644 --- a/scouter.server/src/scouter/server/db/XLogProfileWR.scala +++ b/scouter.server/src/scouter/server/db/XLogProfileWR.scala @@ -34,7 +34,7 @@ import scouter.server.util.OftenAction import scouter.server.core.ServerStat import scouter.server.Configure object XLogProfileWR extends IClose { - val queue = new RequestQueue[Data](Configure.getInstance().xlog_profile_queue_size); + val queue = new RequestQueue[Data](Configure.getInstance().profile_queue_size); class ResultSet(keys: List[Long], var reader: XLogProfileDataReader) { var max: Int = if (keys == null) 0 else keys.size() var x: Int = 0; diff --git a/scouter.server/src/scouter/server/db/io/zip/GZipStore.java b/scouter.server/src/scouter/server/db/io/zip/GZipStore.java index ad10d14ea..e42517b34 100644 --- a/scouter.server/src/scouter/server/db/io/zip/GZipStore.java +++ b/scouter.server/src/scouter/server/db/io/zip/GZipStore.java @@ -97,7 +97,7 @@ public synchronized long write(String date, byte[] data, long next) throws IOExc if (bk == null) { bk = IOChannel.getInstance().getLastWriteBlock(date); if (bk != null) { - while (writingBlockTable.size() >= conf.gzip_writing_block) { + while (writingBlockTable.size() >= conf._compress_write_buffer_block_count) { Block bb = writingBlockTable.removeFirst(); IOChannel.getInstance().store(bb); } diff --git a/scouter.server/src/scouter/server/db/io/zip/IOChannel.java b/scouter.server/src/scouter/server/db/io/zip/IOChannel.java index 572c84d92..6218d6b70 100644 --- a/scouter.server/src/scouter/server/db/io/zip/IOChannel.java +++ b/scouter.server/src/scouter/server/db/io/zip/IOChannel.java @@ -40,7 +40,7 @@ public final static synchronized IOChannel getInstance() { public IOChannel() { ConfObserver.put(IOChannel.class.getName(), new Runnable() { public void run() { - readCache.setMaxRow(conf.gzip_read_cache_block); + readCache.setMaxRow(conf._compress_read_cache_block_count); } }); } @@ -60,7 +60,7 @@ public Block getLastWriteBlock(String date) throws IOException { return bk; } private void check() { - while (headers.size() >= conf.gzip_unitcount_header_cache - 1) { + while (headers.size() >= conf._compress_dailycount_header_cache_size - 1) { try { headers.removeFirst().close(); } catch (Exception e) { @@ -92,7 +92,7 @@ public synchronized void store(Block bk) { Block old = getReadBlock(bk.date, bk.blockNum); if (old != null) { bk = bk.merge(old); - readCache.put(new BKey(bk.date, bk.blockNum), bk, conf.gzip_read_cache_time); + readCache.put(new BKey(bk.date, bk.blockNum), bk, conf._compress_read_cache_expired_ms); } mgtime = (int) w2.getTime(); } @@ -113,15 +113,15 @@ public synchronized void store(Block bk) { } } private static ExecutorService exec = Executors - .newFixedThreadPool(Configure.getInstance().gzip_writing_block_thread); - static int old_block_thread = Configure.getInstance().gzip_writing_block_thread; + .newFixedThreadPool(Configure.getInstance()._compress_write_thread); + static int old_block_thread = Configure.getInstance()._compress_write_thread; static { - ConfObserver.put("gzip_writing_block_thread", new Runnable() { + ConfObserver.put("_compress_write_thread", new Runnable() { public void run() { - if (Configure.getInstance().gzip_writing_block_thread != old_block_thread) { + if (Configure.getInstance()._compress_write_thread != old_block_thread) { ExecutorService oldExec = exec; - exec = Executors.newFixedThreadPool(Configure.getInstance().gzip_writing_block_thread); - old_block_thread = Configure.getInstance().gzip_writing_block_thread; + exec = Executors.newFixedThreadPool(Configure.getInstance()._compress_write_thread); + old_block_thread = Configure.getInstance()._compress_write_thread; oldExec.shutdown(); } } @@ -143,7 +143,7 @@ private File getFile(String date, int blockNum) { String filename = (GZipCtr.createPath(date) + "/xlog." + blockNum); return new File(filename); } - private CacheTable readCache = new CacheTable().setMaxRow(conf.gzip_read_cache_block); + private CacheTable readCache = new CacheTable().setMaxRow(conf._compress_read_cache_block_count); public Block getReadBlock(String date, int blockNum) { Block b = readCache.get(new BKey(date, blockNum)); if (b != null) @@ -156,7 +156,7 @@ public Block getReadBlock(String date, int blockNum) { gz = CompressUtil.unZip(gz); Block bk = new Block(date, gz, 0, gz.length, GZipCtr.BLOCK_MAX_SIZE); bk.blockNum = blockNum; - readCache.put(new BKey(date, blockNum), bk, conf.gzip_read_cache_time); + readCache.put(new BKey(date, blockNum), bk, conf._compress_read_cache_expired_ms); return bk; } catch (Throwable e) { e.printStackTrace(); diff --git a/scouter.server/src/scouter/server/db/xlog/XLogDataReader.scala b/scouter.server/src/scouter/server/db/xlog/XLogDataReader.scala index 1487f876e..965fd54b2 100644 --- a/scouter.server/src/scouter/server/db/xlog/XLogDataReader.scala +++ b/scouter.server/src/scouter/server/db/xlog/XLogDataReader.scala @@ -1,20 +1,20 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package scouter.server.db.xlog; @@ -49,12 +49,12 @@ class XLogDataReader(date: String, file: String) extends IClose { var refrence = 0; val conf = Configure.getInstance() var pointFile: RandomAccessFile = null - var gzip = conf.gzip_xlog + var gzip = conf.compress_xlog_enabled val confFile = new File(file + ".service.conf"); if (confFile.exists()) { var properties = FileUtil.readProperties(confFile); - this.gzip = "true".equalsIgnoreCase(properties.getProperty("gzip_xlog", "" + conf.gzip_xlog).trim()); + this.gzip = "true".equalsIgnoreCase(properties.getProperty("compress_xlog_enabled", "" + conf.compress_xlog_enabled).trim()); } val xlogFile = new File(file + ".service"); diff --git a/scouter.server/src/scouter/server/db/xlog/XLogDataWriter.scala b/scouter.server/src/scouter/server/db/xlog/XLogDataWriter.scala index 80ca98cce..c0da628bb 100644 --- a/scouter.server/src/scouter/server/db/xlog/XLogDataWriter.scala +++ b/scouter.server/src/scouter/server/db/xlog/XLogDataWriter.scala @@ -1,20 +1,20 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package scouter.server.db.xlog; @@ -50,24 +50,24 @@ class XLogDataWriter(date: String, file: String) extends IClose { var refrence = 0; val conf = Configure.getInstance() - var gzip = conf.gzip_xlog + var gzip = conf.compress_xlog_enabled var f = new File(file + ".service.conf"); if (f.exists()) { val properties = FileUtil.readProperties(f); - gzip = "true".equalsIgnoreCase(properties.getProperty("gzip_xlog", ""+conf.gzip_xlog).trim()); + gzip = "true".equalsIgnoreCase(properties.getProperty("compress_xlog_enabled", ""+conf.compress_xlog_enabled).trim()); } else { - gzip = conf.gzip_xlog; + gzip = conf.compress_xlog_enabled; val properties = new Properties(); - properties.put("gzip_xlog", "" + conf.gzip_xlog); + properties.put("compress_xlog_enabled", "" + conf.compress_xlog_enabled); FileUtil.writeProperties(f, properties); } - - var out:RealDataFile = null - if(gzip==false){ - out=new RealDataFile(file + ".service"); - } - + + var out:RealDataFile = null + if(gzip==false){ + out=new RealDataFile(file + ".service"); + } + def write(bytes: Array[Byte]): Long = { if (gzip) { diff --git a/scouter.server/src/scouter/server/db/xlog/XLogProfileDataReader.scala b/scouter.server/src/scouter/server/db/xlog/XLogProfileDataReader.scala index 48df29b76..2b7c4321b 100644 --- a/scouter.server/src/scouter/server/db/xlog/XLogProfileDataReader.scala +++ b/scouter.server/src/scouter/server/db/xlog/XLogProfileDataReader.scala @@ -1,20 +1,20 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package scouter.server.db.xlog; @@ -52,12 +52,12 @@ class XLogProfileDataReader(date: String, file: String) extends IClose { val conf = Configure.getInstance(); private var profileFile: RandomAccessFile = null - private var gzip = conf.gzip_profile + private var gzip = conf.compress_profile_enabled val confFile = new File(file + ".profile.conf"); if (confFile.exists()) { val properties = FileUtil.readProperties(confFile); - this.gzip = "true".equalsIgnoreCase(properties.getProperty("gzip_profile", ""+conf.gzip_profile).trim()); + this.gzip = "true".equalsIgnoreCase(properties.getProperty("compress_profile_enabled", ""+conf.compress_profile_enabled).trim()); } val profile = new File(file + ".profile"); diff --git a/scouter.server/src/scouter/server/db/xlog/XLogProfileDataWriter.scala b/scouter.server/src/scouter/server/db/xlog/XLogProfileDataWriter.scala index dd5cb98c2..61b3ed630 100644 --- a/scouter.server/src/scouter/server/db/xlog/XLogProfileDataWriter.scala +++ b/scouter.server/src/scouter/server/db/xlog/XLogProfileDataWriter.scala @@ -1,20 +1,20 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package scouter.server.db.xlog; @@ -51,16 +51,16 @@ class XLogProfileDataWriter(date: String, file: String) extends IClose { var refrence = 0; val conf = Configure.getInstance(); - var gzip = conf.gzip_profile + var gzip = conf.compress_profile_enabled val f = new File(file + ".profile.conf"); if (f.exists()) { val properties = FileUtil.readProperties(f); - gzip = "true".equalsIgnoreCase(properties.getProperty("gzip_profile", "" + conf.gzip_profile).trim()); + gzip = "true".equalsIgnoreCase(properties.getProperty("compress_profile_enabled", "" + conf.compress_profile_enabled).trim()); } else { - gzip = conf.gzip_profile; + gzip = conf.compress_profile_enabled; val properties = new Properties(); - properties.put("gzip_profile", "" + conf.gzip_profile); + properties.put("compress_profile_enabled", "" + conf.compress_profile_enabled); FileUtil.writeProperties(f, properties); } var out: RealDataFile = null; diff --git a/scouter.server/src/scouter/server/geoip/GISDataUtil.scala b/scouter.server/src/scouter/server/geoip/GISDataUtil.scala index fad2cc4d7..39f9d7d16 100644 --- a/scouter.server/src/scouter/server/geoip/GISDataUtil.scala +++ b/scouter.server/src/scouter/server/geoip/GISDataUtil.scala @@ -17,10 +17,10 @@ object GISDataUtil { var lookupService: LookupService = null - var path = conf.geoip_data_city; + var path = conf.geoip_data_city_file; ConfObserver.put("GISDataUtil") { - if (CompareUtil.equals(path, conf.geoip_data_city) == false) { - path = conf.geoip_data_city; + if (CompareUtil.equals(path, conf.geoip_data_city_file) == false) { + path = conf.geoip_data_city_file; load(); } } @@ -28,7 +28,7 @@ object GISDataUtil { def load() { try { - val fGeoIpDB = new File(conf.geoip_data_city); + val fGeoIpDB = new File(conf.geoip_data_city_file); if (fGeoIpDB.exists() == false) { Logger.println("S145", "GeoIP db file is not readable : " + fGeoIpDB.getCanonicalPath()); } else { diff --git a/scouter.server/src/scouter/server/netio/data/MultiPacketProcessor.scala b/scouter.server/src/scouter/server/netio/data/MultiPacketProcessor.scala index 89280dcc9..8daf7600e 100644 --- a/scouter.server/src/scouter/server/netio/data/MultiPacketProcessor.scala +++ b/scouter.server/src/scouter/server/netio/data/MultiPacketProcessor.scala @@ -1,20 +1,20 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package scouter.server.netio.data; @@ -73,10 +73,10 @@ object MultiPacketProcessor { val p = buffer.get(key); if (p.isExpired) { buffer.remove(key); - if (Configure.getInstance().debug_expired_multipacket) { + if (Configure.getInstance().log_expired_multipacket) { Logger.println("S150", 10, p.toString); } } } } -} +} diff --git a/scouter.server/src/scouter/server/netio/data/NetDataProcessor.scala b/scouter.server/src/scouter/server/netio/data/NetDataProcessor.scala index dc1cd476f..bba655e6e 100644 --- a/scouter.server/src/scouter/server/netio/data/NetDataProcessor.scala +++ b/scouter.server/src/scouter/server/netio/data/NetDataProcessor.scala @@ -54,7 +54,7 @@ object NetDataProcessor { val data = _data } var working = true - val num = Configure.getInstance().num_of_net_processor + val num = Configure.getInstance()._net_udp_worker_thread_count for (x <- 0 to num - 1) { ThreadScala.startDaemon("scouter.server.netio.data.NetDataProcessor") { while (working) { @@ -105,7 +105,7 @@ object NetDataProcessor { if (done != null) { val p = new DataInputX(done).readPack() process(p, addr) - if (conf.debug_udp_multipacket) { + if (conf.log_udp_multipacket) { val objName = TextCache.get(TextTypes.OBJECT, objHash) val sb = new StringBuffer() sb.append("recv ").append(p.getClass().getName()) @@ -137,33 +137,33 @@ object NetDataProcessor { def process(p: Pack, addr: InetAddress) { if (p == null) return - if (conf.debug_udp_packet) { + if (conf.log_udp_packet) { System.out.println(p) } p.getPackType() match { case PackEnum.PERF_COUNTER => PerfCountCore.add(p.asInstanceOf[PerfCounterPack]) - if (conf.debug_udp_counter) { + if (conf.log_udp_counter) { System.out.println("DEBUG UDP COUNTER: " + p) } case PackEnum.XLOG => XLogCore.add(p.asInstanceOf[XLogPack]) - if (conf.debug_udp_xlog) { + if (conf.log_udp_xlog) { System.out.println("DEBUG UDP XLOG: " + p) } case PackEnum.XLOG_PROFILE => ProfileCore.add(p.asInstanceOf[XLogProfilePack]) - if (conf.debug_udp_profile) { + if (conf.log_udp_profile) { System.out.println("DEBUG UDP PROFILE: " + p) } case PackEnum.TEXT => TextCore.add(p.asInstanceOf[TextPack]) - if (conf.debug_udp_text) { + if (conf.log_udp_text) { System.out.println("DEBUG UDP TEXT: " + p) } case PackEnum.ALERT => AlertCore.add(p.asInstanceOf[AlertPack]) - if (conf.debug_udp_alert) { + if (conf.log_udp_alert) { System.out.println("DEBUG UDP ALERT: " + p) } case PackEnum.OBJECT => @@ -172,22 +172,22 @@ object NetDataProcessor { h.address = addr.getHostAddress() } AgentManager.active(h) - if (conf.debug_udp_object) { + if (conf.log_udp_object) { System.out.println("DEBUG UDP OBJECT: " + p) } case PackEnum.PERF_STATUS => StatusCore.add(p.asInstanceOf[StatusPack]) - if (conf.debug_udp_status) { + if (conf.log_udp_status) { System.out.println("DEBUG UDP STATUS: " + p) } case PackEnum.STACK => StackAnalyzerCore.add(p.asInstanceOf[StackPack]) - if (conf.debug_udp_stack) { + if (conf.log_udp_stack) { System.out.println("DEBUG UDP STACK: " + p) } case PackEnum.SUMMARY => SummaryCore.add(p.asInstanceOf[SummaryPack]) - if (conf.debug_udp_summary) { + if (conf.log_udp_summary) { System.out.println("DEBUG UDP SUMMARY: " + p) } case _ => diff --git a/scouter.server/src/scouter/server/netio/data/net/DataUdpServer.scala b/scouter.server/src/scouter/server/netio/data/net/DataUdpServer.scala index ba059f57f..8c62a26ee 100644 --- a/scouter.server/src/scouter/server/netio/data/net/DataUdpServer.scala +++ b/scouter.server/src/scouter/server/netio/data/net/DataUdpServer.scala @@ -1,19 +1,19 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * */ package scouter.server.netio.data.net; @@ -34,7 +34,7 @@ object DataUdpServer { var udpsocket: DatagramSocket = null; ThreadScala.startDaemon("scouter.server.netio.data.net.DataUdpServer") { while (true) { - open(conf.udp_host, conf.udp_port); + open(conf.net_udp_listen_ip, conf.net_udp_listen_port); recv(); FileUtil.close(udpsocket) } @@ -42,7 +42,7 @@ object DataUdpServer { def recv() { try { - val BUFFER_SIZE = conf.udp_buffer; + val BUFFER_SIZE = conf.net_udp_packet_buffer_size; val rbuf = new Array[Byte](BUFFER_SIZE) val p = new DatagramPacket(rbuf, BUFFER_SIZE); @@ -63,13 +63,13 @@ object DataUdpServer { Logger.println("udp listen " + host + ":" + port); Logger.println("\tudp_host=" + host); Logger.println("\tudp_port=" + port); - Logger.println("\tudp_buffer=" + conf.udp_buffer); - Logger.println("\tudp_so_rcvbuf=" + conf.udp_so_rcvbuf); + Logger.println("\tudp_buffer=" + conf.net_udp_packet_buffer_size); + Logger.println("\tudp_so_rcvbuf=" + conf.net_udp_so_rcvbuf_size); while (true) { try { udpsocket = new DatagramSocket(port, InetAddress.getByName(host)); - val buf = conf.udp_so_rcvbuf; + val buf = conf.net_udp_so_rcvbuf_size; if (buf > 0) { udpsocket.setReceiveBufferSize(buf); } @@ -81,4 +81,4 @@ object DataUdpServer { ThreadUtil.sleep(3000); } } -} +} diff --git a/scouter.server/src/scouter/server/netio/service/ServiceHandlingProxy.java b/scouter.server/src/scouter/server/netio/service/ServiceHandlingProxy.java index 260bae6d0..a66877a0e 100644 --- a/scouter.server/src/scouter/server/netio/service/ServiceHandlingProxy.java +++ b/scouter.server/src/scouter/server/netio/service/ServiceHandlingProxy.java @@ -78,7 +78,7 @@ public static void load() { if (olds != null) { Logger.println("Warning duplicated Handler key=" + key + " old=" + olds + " new=" + news); } else { - if (Configure.getInstance().debug_request) { + if (Configure.getInstance().log_service_handler_list) { Logger.println("ServiceHandler " + key + "=>" + news); } } diff --git a/scouter.server/src/scouter/server/netio/service/handle/LoginService.scala b/scouter.server/src/scouter/server/netio/service/handle/LoginService.scala index 89c2b1103..e96925938 100644 --- a/scouter.server/src/scouter/server/netio/service/handle/LoginService.scala +++ b/scouter.server/src/scouter/server/netio/service/handle/LoginService.scala @@ -1,20 +1,20 @@ -/* -* Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ +/* +* Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ package scouter.server.netio.service.handle; @@ -45,7 +45,7 @@ class LoginService { val id = m.getText("id"); val passwd = m.getText("pass"); val ip = m.getText("ip"); - val name = m.getText("hostname"); + val name = m.getText("server_id"); val clientVer = m.getText("version"); val session = LoginManager.login(id, passwd, ip); m.put("session", session); @@ -56,7 +56,7 @@ class LoginService { user.hostname = name; user.version = clientVer; m.put("time", System.currentTimeMillis()); - m.put("hostname", getHostName()); + m.put("server_id", getHostName()); m.put("type", user.group); m.put("version", Version.getServerFullVersion()); val acc = AccountManager.getAccount(id); @@ -67,11 +67,11 @@ class LoginService { val mv = AccountManager.getGroupPolicy(user.group); if (mv != null) { m.put("policy", mv); - } - val menuMv = new MapValue(); - m.put("menu", menuMv); - menuMv.put("tag_count", new BooleanValue(Configure.getInstance().tagcnt_enabled)); - menuMv.put("alert_summary", new BooleanValue(Configure.getInstance().enable_alert_summary)); + } + val menuMv = new MapValue(); + m.put("menu", menuMv); + menuMv.put("tag_count", new BooleanValue(Configure.getInstance().tagcnt_enabled)); + menuMv.put("alert_summary", new BooleanValue(Configure.getInstance().summary_alert_enabled)); } dout.writeByte(TcpFlag.HasNEXT); @@ -116,6 +116,6 @@ class LoginService { } def getHostName(): String = { - Configure.getInstance().hostname; + Configure.getInstance().server_id; } } \ No newline at end of file diff --git a/scouter.server/src/scouter/server/netio/service/handle/XLogService.scala b/scouter.server/src/scouter/server/netio/service/handle/XLogService.scala index 8e99cb5eb..f2a291317 100644 --- a/scouter.server/src/scouter/server/netio/service/handle/XLogService.scala +++ b/scouter.server/src/scouter/server/netio/service/handle/XLogService.scala @@ -99,7 +99,7 @@ class XLogService { val index = param.getInt("index"); val loop = param.getLong("loop"); var limit = param.getInt("limit"); - limit = Math.max(Configure.getInstance().xlog_realtime_limit, limit); + limit = Math.max(Configure.getInstance().xlog_realtime_lower_bound_ms, limit); val objHashLv = param.getList("objHash"); if (objHashLv == null || objHashLv.size() < 1) { return ; @@ -133,7 +133,7 @@ class XLogService { val stime = param.getLong("stime"); val etime = param.getLong("etime"); val limitTime = param.getInt("limit"); - val limit = Math.max(Configure.getInstance().xlog_pasttime_limit, limitTime); + val limit = Math.max(Configure.getInstance().xlog_pasttime_lower_bound_ms, limitTime); val max = param.getInt("max"); val rev = param.getBoolean("reverse"); val objHashLv = param.getList("objHash"); diff --git a/scouter.server/src/scouter/server/netio/service/net/TcpAgentManager.scala b/scouter.server/src/scouter/server/netio/service/net/TcpAgentManager.scala index c78c581bf..f5eec6798 100644 --- a/scouter.server/src/scouter/server/netio/service/net/TcpAgentManager.scala +++ b/scouter.server/src/scouter/server/netio/service/net/TcpAgentManager.scala @@ -68,6 +68,6 @@ object TcpAgentManager { } def get(objHash: Int): TcpAgentWorker = { var sessions = agentTable.get(objHash) - return if (sessions != null) sessions.get(conf.tcp_agent_max_wait) else null + return if (sessions != null) sessions.get(conf.net_tcp_get_agent_connection_wait_ms) else null } } diff --git a/scouter.server/src/scouter/server/netio/service/net/TcpAgentWorker.scala b/scouter.server/src/scouter/server/netio/service/net/TcpAgentWorker.scala index b329f0bf3..a4888ed2b 100644 --- a/scouter.server/src/scouter/server/netio/service/net/TcpAgentWorker.scala +++ b/scouter.server/src/scouter/server/netio/service/net/TcpAgentWorker.scala @@ -8,14 +8,14 @@ import scouter.lang.pack.MapPack import scouter.net.TcpFlag import scouter.util.FileUtil import scouter.net.TcpFlag -import scouter.server.Configure +import scouter.server.{Logger, Configure} import scouter.util.DateUtil import scouter.net.NetCafe class TcpAgentWorker(socket: Socket, in: DataInputX, out: DataOutputX, protocol:Int) { val remoteAddr = socket.getRemoteSocketAddress() - socket.setSoTimeout(Configure.getInstance().tcp_agent_so_timeout) + socket.setSoTimeout(Configure.getInstance().net_tcp_agent_so_timeout_ms) var lastWriteTime = System.currentTimeMillis() def write(cmd: String, p: Pack) { @@ -80,7 +80,7 @@ class TcpAgentWorker(socket: Socket, in: DataInputX, out: DataOutputX, protocol: val conf = Configure.getInstance() - def isExpired() = { System.currentTimeMillis() - lastWriteTime >= conf.tcp_agent_keepalive } + def isExpired() = { System.currentTimeMillis() - lastWriteTime >= conf.net_tcp_agent_keepalive_interval_ms } def sendKeepAlive(waitTime: Int) { if (socket.isClosed()) return @@ -107,8 +107,8 @@ class TcpAgentWorker(socket: Socket, in: DataInputX, out: DataOutputX, protocol: FileUtil.close(in) FileUtil.close(out) FileUtil.close(socket) - if (conf.debug_net) { - println("Agent : " + remoteAddr + " close"); + if (conf.log_tcp_action_enabled) { + Logger.println("Agent : " + remoteAddr + " close"); } } } \ No newline at end of file diff --git a/scouter.server/src/scouter/server/netio/service/net/TcpServer.scala b/scouter.server/src/scouter/server/netio/service/net/TcpServer.scala index cc42da8ca..42d007b85 100644 --- a/scouter.server/src/scouter/server/netio/service/net/TcpServer.scala +++ b/scouter.server/src/scouter/server/netio/service/net/TcpServer.scala @@ -16,8 +16,7 @@ * */ package scouter.server.netio.service.net; -import java.net.ServerSocket -import java.net.Socket +import java.net.{InetAddress, ServerSocket, Socket} import scouter.server.ConfObserver import scouter.server.Configure import scouter.server.Logger @@ -26,22 +25,22 @@ import scouter.util.FileUtil import scouter.util.ThreadUtil object TcpServer { val conf = Configure.getInstance(); - val threadPool = ThreadUtil.createExecutor("ServiceServer", conf.tcp_server_pool_size, 10000, true); + val threadPool = ThreadUtil.createExecutor("ServiceServer", conf.net_tcp_service_pool_size, 10000, true); ConfObserver.put("TcpServer") { - if (conf.tcp_server_pool_size != threadPool.getCorePoolSize()) { - threadPool.setCorePoolSize(conf.tcp_server_pool_size); + if (conf.net_tcp_service_pool_size != threadPool.getCorePoolSize()) { + threadPool.setCorePoolSize(conf.net_tcp_service_pool_size); } } ThreadScala.startDaemon("scouter.server.netio.service.net.TcpServer") { - Logger.println("\ttcp_port=" + conf.tcp_port); - Logger.println("\tcp_agent_so_timeout=" + conf.tcp_agent_so_timeout); - Logger.println("\tcp_client_so_timeout=" + conf.tcp_client_so_timeout); + Logger.println("\ttcp_port=" + conf.net_tcp_listen_port); + Logger.println("\tcp_agent_so_timeout=" + conf.net_tcp_agent_so_timeout_ms); + Logger.println("\tcp_client_so_timeout=" + conf.net_tcp_client_so_timeout_ms); var server: ServerSocket = null; try { - server = new ServerSocket( conf.tcp_port); + server = new ServerSocket(conf.net_tcp_listen_port, 50, InetAddress.getByName(conf.net_tcp_listen_ip)); while (true) { val client = server.accept(); - client.setSoTimeout(conf.tcp_client_so_timeout); + client.setSoTimeout(conf.net_tcp_client_so_timeout_ms); client.setReuseAddress(true); try { threadPool.execute(new ServiceWorker(client)); @@ -50,7 +49,7 @@ object TcpServer { } } } catch { - case e: Throwable => Logger.println("S167", 1, "tcp port=" + conf.tcp_port, e); + case e: Throwable => Logger.println("S167", 1, "tcp port=" + conf.net_tcp_listen_port, e); } finally { FileUtil.close(server); } diff --git a/scouter.server/src/scouter/server/netio/service/net/TcpServiceWorker.scala b/scouter.server/src/scouter/server/netio/service/net/TcpServiceWorker.scala index 4da7f667e..5fdda9667 100644 --- a/scouter.server/src/scouter/server/netio/service/net/TcpServiceWorker.scala +++ b/scouter.server/src/scouter/server/netio/service/net/TcpServiceWorker.scala @@ -28,12 +28,11 @@ import scouter.io.DataOutputX import scouter.net.NetCafe import scouter.net.RequestCmd import scouter.net.TcpFlag -import scouter.server.LoginManager +import scouter.server.{Logger, LoginManager, Configure} import scouter.server.logs.RequestLogger import scouter.server.netio.service.ServiceHandlingProxy import scouter.util.FileUtil import scouter.util.Hexa32 -import scouter.server.Configure object ServiceWorker { var workers = 0; @@ -72,17 +71,17 @@ class ServiceWorker(_socket: Socket) extends Runnable { case NetCafe.TCP_AGENT | NetCafe.TCP_AGENT_V2 => val objHash = in.readInt() val num = TcpAgentManager.add(objHash, new TcpAgentWorker(socket, in, out, cafe)) - if (conf.debug_net) { - println("Agent : " + remoteAddr + " open [" + Hexa32.toString32(objHash) + "] #" + num); + if (conf.log_tcp_action_enabled) { + Logger.println("Agent : " + remoteAddr + " open [" + Hexa32.toString32(objHash) + "] #" + num); } return case NetCafe.TCP_CLIENT => - if (conf.debug_net) { - println("Client : " + remoteAddr + " open #" + (ServiceWorker.getActiveCount() + 1)); + if (conf.log_tcp_action_enabled) { + Logger.println("Client : " + remoteAddr + " open #" + (ServiceWorker.getActiveCount() + 1)); } case _ => - if (conf.debug_net) { - println("Unknown : " + remoteAddr + " drop"); + if (conf.log_tcp_action_enabled) { + Logger.println("Unknown : " + remoteAddr + " drop"); } FileUtil.close(in); FileUtil.close(out); @@ -117,22 +116,22 @@ class ServiceWorker(_socket: Socket) extends Runnable { } } catch { case ne: NullPointerException => - if (conf.debug_net) { - println("Client : " + remoteAddr + " closed"); + if (conf.log_tcp_action_enabled) { + Logger.println("Client : " + remoteAddr + " closed"); ne.printStackTrace(); } case e: EOFException => - if (conf.debug_net) { - println("Client : " + remoteAddr + " closed"); + if (conf.log_tcp_action_enabled) { + Logger.println("Client : " + remoteAddr + " closed"); } case se: SocketTimeoutException => - if (conf.debug_net) { - println("Client : " + remoteAddr + " closed"); + if (conf.log_tcp_action_enabled) { + Logger.println("Client : " + remoteAddr + " closed"); se.printStackTrace(); } case e: Exception => - if (conf.debug_net) { - println("Client : " + remoteAddr + " closed " + e + " workers=" + ServiceWorker.getActiveCount()); + if (conf.log_tcp_action_enabled) { + Logger.println("Client : " + remoteAddr + " closed " + e + " workers=" + ServiceWorker.getActiveCount()); } case t: Throwable => t.printStackTrace(); } finally { diff --git a/scouter.server/src/scouter/server/plugin/IXLog.java b/scouter.server/src/scouter/server/plugin/IXLog.java index 076cb5494..573385eed 100644 --- a/scouter.server/src/scouter/server/plugin/IXLog.java +++ b/scouter.server/src/scouter/server/plugin/IXLog.java @@ -40,7 +40,7 @@ public void setAutoGroup(XLogPack p) { } public void setLocation(XLogPack p) { - if (Configure.getInstance().enable_geoip) { + if (Configure.getInstance().geoip_enabled) { GeoIpUtil.setNationAndCity(p); } } diff --git a/scouter.server/src/scouter/server/tagcnt/core/CountEnv.scala b/scouter.server/src/scouter/server/tagcnt/core/CountEnv.scala index fc5ff9b63..dd3760635 100644 --- a/scouter.server/src/scouter/server/tagcnt/core/CountEnv.scala +++ b/scouter.server/src/scouter/server/tagcnt/core/CountEnv.scala @@ -37,7 +37,7 @@ object CountEnv { def getDBPath(logDate: String): String = { val sb = new StringBuffer(); - sb.append(Configure.getInstance().db_root); + sb.append(Configure.getInstance().db_dir); sb.append("/").append(logDate); sb.append("/").append("tagcnt"); return sb.toString(); @@ -45,7 +45,7 @@ object CountEnv { def getDBPath(logDate: String, objType: String): String = { val sb = new StringBuffer(); - sb.append(Configure.getInstance().db_root); + sb.append(Configure.getInstance().db_dir); sb.append("/").append(logDate); sb.append("/").append("tagcnt"); sb.append("/").append(objType); From b7385ae36d503f02dbc18560082fcd07cf61a384 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Sun, 6 Dec 2015 22:04:59 +0900 Subject: [PATCH 28/42] ***** host agent - rename configure keys ***** --- .../src/scouter/agent/Configure.java | 158 +++++++++--------- .../src/scouter/agent/Logger.java | 26 +-- .../scouter/agent/counter/CounterBasket.java | 50 +++--- .../counter/CounterExecutingManager.java | 2 +- .../agent/counter/task/AgentHeartBeat.java | 7 +- .../scouter/agent/counter/task/HostPerf.java | 16 +- .../scouter/agent/counter/task/ProcPerf.java | 6 +- .../scouter/agent/netio/data/DataProxy.java | 8 +- .../agent/netio/data/net/DataUdpAgent.java | 14 +- .../agent/netio/data/net/TcpRequestMgr.java | 4 +- .../agent/netio/data/net/TcpWorker.java | 15 +- .../src/scouter/agent/Configure.java | 9 +- .../src/scouter/server/Configure.java | 2 +- 13 files changed, 148 insertions(+), 169 deletions(-) diff --git a/scouter.agent.host/src/scouter/agent/Configure.java b/scouter.agent.host/src/scouter/agent/Configure.java index 33dab849a..9c5c3a87a 100644 --- a/scouter.agent.host/src/scouter/agent/Configure.java +++ b/scouter.agent.host/src/scouter/agent/Configure.java @@ -17,16 +17,6 @@ package scouter.agent; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; - import scouter.Version; import scouter.agent.netio.data.DataProxy; import scouter.lang.conf.ConfObserver; @@ -35,20 +25,16 @@ import scouter.lang.value.ListValue; import scouter.lang.value.MapValue; import scouter.net.NetConstants; -import scouter.util.DateUtil; -import scouter.util.FileUtil; -import scouter.util.HashUtil; -import scouter.util.StringEnumer; -import scouter.util.StringKeyLinkedMap; -import scouter.util.StringSet; -import scouter.util.StringUtil; -import scouter.util.SysJMX; -import scouter.util.SystemUtil; -import scouter.util.ThreadUtil; +import scouter.util.*; + +import java.io.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; public class Configure extends Thread { - public static boolean JDBC_REDEFINED = false; private static Configure instance = null; public final static String CONF_DIR = "./conf/"; @@ -62,53 +48,59 @@ public final static synchronized Configure getInstance() { return instance; } - public String local_udp_addr = null; - public int local_udp_port; - - public String server_addr = "127.0.0.1"; - public int server_udp_port = NetConstants.SERVER_UDP_PORT; - public int server_tcp_port = NetConstants.SERVER_TCP_PORT; - public int server_tcp_session_count = 1; - public int server_tcp_so_timeout = 60000; - public int server_tcp_connection_timeout = 3000; - - public String scouter_type = ""; - public String scouter_name = ""; - - public int objHash; - public String objName; - - public int udp_packet_max = 60000; - public StringSet log_ignore = new StringSet(); - public int max_concurrent_server_request = 10; - - public boolean enable_counter_task = true; - public boolean debug_udp_object = false; - - public boolean log_rotation = true; - public String logs_dir = "./logs"; - public int log_keep_dates = 365; - - public String object_registry = "/tmp/scouter"; - + //Network + public String net_local_udp_ip = null; + public int net_local_udp_port; + public String net_collector_ip = "127.0.0.1"; + public int net_collector_udp_port = NetConstants.SERVER_UDP_PORT; + public int net_collector_tcp_port = NetConstants.SERVER_TCP_PORT; + public int net_collector_tcp_session_count = 1; + public int net_collector_tcp_so_timeout_ms = 60000; + public int net_collector_tcp_connection_timeout_ms = 3000; + public int net_udp_packet_max_bytes = 60000; + + //Object + public String obj_type = ""; + public String obj_name = ""; + + //Manager + public StringSet mgr_log_ignore_ids = new StringSet(); + + //Counter + public boolean counter_enabled = true; + public String counter_object_registry_path = "/tmp/scouter"; + + //Log + public boolean log_udp_object = false; + public boolean log_rotation_enalbed = true; + public String log_dir = "./logs"; + public int log_keep_days = 365; + + //Disk public boolean disk_alert_enabled = true; public int disk_warning_pct = 70; public int disk_fatal_pct = 90; - public StringSet disk_ignore = new StringSet(); + public StringSet disk_ignore_names = new StringSet(); + //Cpu public boolean cpu_alert_enabled = true; - public long cpu_check_period = 300000; - public long cpu_alert_interval = 30000; + public long cpu_check_period_ms = 300000; + public long cpu_alert_interval_ms = 30000; public int cpu_warning_pct = 70; public int cpu_fatal_pct = 90; public int cpu_warning_history = 3; public int cpu_fatal_history = 3; + //Memory public boolean mem_alert_enabled = true; - public long mem_alert_interval = 30000; + public long mem_alert_interval_ms = 30000; public int mem_warning_pct = 80; public int mem_fatal_pct = 90; + //internal variables + private int objHash; + private String objName; + private Configure() { Properties p = new Properties(); Map args = new HashMap(); @@ -189,44 +181,43 @@ public synchronized boolean reload(boolean force) { private void apply() { - this.udp_packet_max = getInt("udp_packet_max", getInt("udp.packet.max", 60000)); - this.log_ignore = getStringSet("log_ignore", ","); + this.net_udp_packet_max_bytes = getInt("net_udp_packet_max_bytes", getInt("udp.packet.max", 60000)); + this.mgr_log_ignore_ids = getStringSet("mgr_log_ignore_ids", ","); - this.local_udp_addr = getValue("local_udp_addr"); - this.local_udp_port = getInt("local_udp_port", 0); + this.net_local_udp_ip = getValue("net_local_udp_ip"); + this.net_local_udp_port = getInt("net_local_udp_port", 0); - this.server_addr = getValue("server_addr", getValue("server.addr", "127.0.0.1")); - this.server_udp_port = getInt("server_udp_port", getInt("server.port", NetConstants.SERVER_UDP_PORT)); - this.server_tcp_port = getInt("server_tcp_port", getInt("server.port", NetConstants.SERVER_TCP_PORT)); - this.server_tcp_session_count = getInt("server_tcp_session_count", 1, 1); - this.server_tcp_connection_timeout = getInt("server_tcp_connection_timeout", 3000); - this.server_tcp_so_timeout = getInt("server_tcp_so_timeout", 60000); + this.net_collector_ip = getValue("net_collector_ip", getValue("server.addr", "127.0.0.1")); + this.net_collector_udp_port = getInt("net_collector_udp_port", getInt("server.port", NetConstants.SERVER_UDP_PORT)); + this.net_collector_tcp_port = getInt("net_collector_tcp_port", getInt("server.port", NetConstants.SERVER_TCP_PORT)); + this.net_collector_tcp_session_count = getInt("net_collector_tcp_session_count", 1, 1); + this.net_collector_tcp_connection_timeout_ms = getInt("net_collector_tcp_connection_timeout_ms", 3000); + this.net_collector_tcp_so_timeout_ms = getInt("net_collector_tcp_so_timeout_ms", 60000); - this.max_concurrent_server_request = getInt("max_concurrent_server_request", 10); - this.enable_counter_task = getBoolean("enable_counter_task", true); - this.debug_udp_object = getBoolean("debug_udp_object", false); + this.counter_enabled = getBoolean("counter_enabled", true); + this.log_udp_object = getBoolean("log_udp_object", false); - this.logs_dir = getValue("logs_dir", "./logs"); - this.log_rotation = getBoolean("log_rotation", true); - this.log_keep_dates = getInt("log_keep_dates", 365); + this.log_dir = getValue("log_dir", "./logs"); + this.log_rotation_enalbed = getBoolean("log_rotation_enalbed", true); + this.log_keep_days = getInt("log_keep_days", 365); - this.object_registry = getValue("object_registry", "/tmp/scouter"); + this.counter_object_registry_path = getValue("counter_object_registry_path", "/tmp/scouter"); this.disk_alert_enabled = getBoolean("disk_alert_enablee", true); this.disk_warning_pct = getInt("disk_warning_pct", 70); this.disk_fatal_pct = getInt("disk_fatal_pct", 90); - this.disk_ignore = getStringSet("disk_ignore", ","); + this.disk_ignore_names = getStringSet("disk_ignore_names", ","); this.cpu_alert_enabled = getBoolean("cpu_alert_enabled", true); - this.cpu_check_period = getLong("cpu_check_period", 300000); - this.cpu_alert_interval = getLong("cpu_alert_interval", 30000); + this.cpu_check_period_ms = getLong("cpu_check_period_ms", 300000); + this.cpu_alert_interval_ms = getLong("cpu_alert_interval_ms", 30000); this.cpu_warning_pct = getInt("cpu_warning_pct", 70); this.cpu_fatal_pct = getInt("cpu_fatal_pct", 90); this.cpu_warning_history = getInt("cpu_warning_history", 3); this.cpu_fatal_history = getInt("cpu_fatal_history", 3); this.mem_alert_enabled = getBoolean("mem_alert_enabled", true); - this.mem_alert_interval = getLong("mem_alert_interval", 30000); + this.mem_alert_interval_ms = getLong("mem_alert_interval_ms", 30000); this.mem_warning_pct = getInt("mem_warning_pct", 80); this.mem_fatal_pct = getInt("mem_fatal_pct", 90); @@ -261,10 +252,10 @@ public synchronized void resetObjInfo() { } else if (SystemUtil.IS_HP_UX) { detected = CounterConstants.HPUX; } - this.scouter_type = getValue("scouter_type", detected); - this.scouter_name = getValue("scouter_name", SysJMX.getHostName()); + this.obj_type = getValue("obj_type", detected); + this.obj_name = getValue("obj_name", SysJMX.getHostName()); - this.objName = "/" + this.scouter_name; + this.objName = "/" + this.obj_name; this.objHash = HashUtil.hash(objName); } @@ -318,6 +309,14 @@ public boolean getBoolean(String key, boolean def) { return def; } + public int getObjHash() { + return this.objHash; + } + + public String getObjName() { + return this.objName; + } + public String loadText() { File file = getPropertyFile(); InputStream fin = null; @@ -354,9 +353,6 @@ public void printConfig() { static { ignoreSet.add("property"); - ignoreSet.add("objHash"); - ignoreSet.add("objName"); - ignoreSet.add("objType"); } public MapValue getKeyValueInfo() { diff --git a/scouter.agent.host/src/scouter/agent/Logger.java b/scouter.agent.host/src/scouter/agent/Logger.java index 1c6f32934..9dcde081e 100644 --- a/scouter.agent.host/src/scouter/agent/Logger.java +++ b/scouter.agent.host/src/scouter/agent/Logger.java @@ -78,7 +78,7 @@ public static String getCallStack(Throwable t) { } private static boolean checkOk(String id, int sec) { - if (Configure.getInstance().log_ignore.hasKey(id)) + if (Configure.getInstance().mgr_log_ignore_ids.hasKey(id)) return false; if (sec > 0) { long last = lastLog.get(id); @@ -138,10 +138,10 @@ public void run() { static { ConfObserver.add(Logger.class.getName(), new Runnable() { public void run() { - if (CompareUtil.equals(lastDir, conf.logs_dir) == false || lastFileRotation != conf.log_rotation) { + if (CompareUtil.equals(lastDir, conf.log_dir) == false || lastFileRotation != conf.log_rotation_enalbed) { pw = (PrintWriter) FileUtil.close(pw); - lastDir = conf.logs_dir; - lastFileRotation = conf.log_rotation; + lastDir = conf.log_dir; + lastFileRotation = conf.log_rotation_enalbed; } } }); @@ -153,27 +153,27 @@ public void run() { private static synchronized void openFile() throws IOException { if (pw == null) { lastDataUnit = DateUtil.getDateUnit(); - lastDir = conf.logs_dir; - lastFileRotation = conf.log_rotation; + lastDir = conf.log_dir; + lastFileRotation = conf.log_rotation_enalbed; new File(lastDir).mkdirs(); - if (conf.log_rotation) { - FileWriter fw = new FileWriter(new File(conf.logs_dir, "agent-" + DateUtil.yyyymmdd() + ".log"), true); + if (conf.log_rotation_enalbed) { + FileWriter fw = new FileWriter(new File(conf.log_dir, "agent-" + DateUtil.yyyymmdd() + ".log"), true); pw = new PrintWriter(fw); } else { - pw = new PrintWriter(new File(conf.logs_dir, "agent.log")); + pw = new PrintWriter(new File(conf.log_dir, "agent.log")); } lastDataUnit = DateUtil.getDateUnit(); } } protected static void clearOldLog() { - if (conf.log_rotation == false) + if (conf.log_rotation_enalbed == false) return; - if (conf.log_keep_dates <= 0) + if (conf.log_keep_days <= 0) return; long nowUnit = DateUtil.getDateUnit(); - File dir = new File(conf.logs_dir); + File dir = new File(conf.log_dir); File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) @@ -191,7 +191,7 @@ protected static void clearOldLog() { try { long d = DateUtil.yyyymmdd(date); long fileUnit = DateUtil.getDateUnit(d); - if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_dates) { + if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_days) { files[i].delete(); } } catch (Exception e) { diff --git a/scouter.agent.host/src/scouter/agent/counter/CounterBasket.java b/scouter.agent.host/src/scouter/agent/counter/CounterBasket.java index 0275d82b6..831c921b3 100644 --- a/scouter.agent.host/src/scouter/agent/counter/CounterBasket.java +++ b/scouter.agent.host/src/scouter/agent/counter/CounterBasket.java @@ -1,29 +1,29 @@ -/* - * Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package scouter.agent.counter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import scouter.agent.Configure; -import scouter.lang.TimeTypeEnum; -import scouter.lang.pack.PerfCounterPack; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import scouter.agent.Configure; +import scouter.lang.TimeTypeEnum; +import scouter.lang.pack.PerfCounterPack; public class CounterBasket { private class Key { @@ -66,7 +66,7 @@ public PerfCounterPack getPack(String objName, byte timeType) { } public PerfCounterPack getPack(byte timeType) { - return getPack(Configure.getInstance().objName, timeType); + return getPack(Configure.getInstance().getObjName(), timeType); } public PerfCounterPack[] getList() { diff --git a/scouter.agent.host/src/scouter/agent/counter/CounterExecutingManager.java b/scouter.agent.host/src/scouter/agent/counter/CounterExecutingManager.java index 29a0f2e56..976843422 100644 --- a/scouter.agent.host/src/scouter/agent/counter/CounterExecutingManager.java +++ b/scouter.agent.host/src/scouter/agent/counter/CounterExecutingManager.java @@ -45,7 +45,7 @@ public final static synchronized CounterExecutingManager getInstance() { public void run() { while (true) { ThreadUtil.sleep(1000); - if (conf.enable_counter_task == false) { + if (conf.counter_enabled == false) { continue; } long now = System.currentTimeMillis(); diff --git a/scouter.agent.host/src/scouter/agent/counter/task/AgentHeartBeat.java b/scouter.agent.host/src/scouter/agent/counter/task/AgentHeartBeat.java index aa8060b9d..da1e04003 100644 --- a/scouter.agent.host/src/scouter/agent/counter/task/AgentHeartBeat.java +++ b/scouter.agent.host/src/scouter/agent/counter/task/AgentHeartBeat.java @@ -21,7 +21,6 @@ import scouter.Version; import scouter.agent.Configure; -import scouter.agent.Logger; import scouter.agent.counter.CounterBasket; import scouter.agent.counter.anotation.Counter; import scouter.agent.netio.data.DataProxy; @@ -61,9 +60,9 @@ public void alive(CounterBasket pw) { private ObjectPack getMainObject() { Configure conf = Configure.getInstance(); ObjectPack p = new ObjectPack(); - p.objType = conf.scouter_type; - p.objHash = conf.objHash; - p.objName = conf.objName; + p.objType = conf.obj_type; + p.objHash = conf.getObjHash(); + p.objName = conf.getObjName(); p.version = Version.getAgentFullVersion(); p.address = TcpWorker.localAddr; diff --git a/scouter.agent.host/src/scouter/agent/counter/task/HostPerf.java b/scouter.agent.host/src/scouter/agent/counter/task/HostPerf.java index 6c7540906..c022b151c 100644 --- a/scouter.agent.host/src/scouter/agent/counter/task/HostPerf.java +++ b/scouter.agent.host/src/scouter/agent/counter/task/HostPerf.java @@ -67,7 +67,7 @@ void domain(CounterBasket pw) throws SigarException { long uswap = sw.getUsed(); float swaprate = uswap * 100.0f / tswap; - PerfCounterPack p = pw.getPack(conf.objName, TimeTypeEnum.REALTIME); + PerfCounterPack p = pw.getPack(conf.getObjName(), TimeTypeEnum.REALTIME); p.put(CounterConstants.HOST_CPU, new FloatValue(cpu)); p.put(CounterConstants.HOST_SYSCPU, new FloatValue(sysCpu)); p.put(CounterConstants.HOST_USERCPU, new FloatValue(userCpu)); @@ -88,7 +88,7 @@ void domain(CounterBasket pw) throws SigarException { p.put(CounterConstants.HOST_TCPSTAT_TIM, new DecimalValue(tcpstat_time)); p.put(CounterConstants.HOST_TCPSTAT_EST, new DecimalValue(tcpstat_est)); - p = pw.getPack(conf.objName, TimeTypeEnum.FIVE_MIN); + p = pw.getPack(conf.getObjName(), TimeTypeEnum.FIVE_MIN); p.put(CounterConstants.HOST_CPU, new FloatValue(cpu)); p.put(CounterConstants.HOST_MEM, new FloatValue(memrate)); p.put(CounterConstants.HOST_MEM_TOTAL, new DecimalValue(tmem / 1024 / 1024)); @@ -121,7 +121,7 @@ private void alertMem(Mem m) { long now = System.currentTimeMillis(); if (memrate >= conf.mem_fatal_pct) { - if (now >= mem_last_fatal + conf.mem_alert_interval) { + if (now >= mem_last_fatal + conf.mem_alert_interval_ms) { DataProxy.sendAlert(AlertLevel.FATAL, "FATAL_MEMORY_HIGH", "fatal mem usage free=" + prt(fmem) + " rate=" + memrate + "%", null); mem_last_fatal = now; @@ -129,7 +129,7 @@ private void alertMem(Mem m) { return; } if (memrate >= conf.mem_warning_pct) { - if (now >= mem_last_warning + conf.mem_alert_interval) { + if (now >= mem_last_warning + conf.mem_alert_interval_ms) { DataProxy.sendAlert(AlertLevel.WARN, "WARNING_MEMORY_HIGH", "warning mem usage free=" + prt(fmem) + " rate=" + memrate + "%", null); mem_last_warning = now; @@ -154,7 +154,7 @@ private void alertCpu(float nextCpu) { long now = System.currentTimeMillis(); int w = 0, f = 0; - long stime = System.currentTimeMillis() - conf.cpu_check_period; + long stime = System.currentTimeMillis() - conf.cpu_check_period_ms; LongEnumer en = oldCpu.keys(); while (en.hasMoreElements()) { long tm = en.nextLong(); @@ -172,7 +172,7 @@ private void alertCpu(float nextCpu) { if (nextCpu >= conf.cpu_fatal_pct) { if (f >= conf.cpu_fatal_history) { - if (now >= cpu_last_fatal + conf.cpu_alert_interval) { + if (now >= cpu_last_fatal + conf.cpu_alert_interval_ms) { DataProxy.sendAlert(AlertLevel.FATAL, "FATAL_CPU_HIGH", "cpu high " + nextCpu + "%", null); cpu_last_fatal = now; } @@ -181,7 +181,7 @@ private void alertCpu(float nextCpu) { } if (nextCpu >= conf.cpu_warning_pct) { if (f + w >= conf.cpu_warning_history) { - if (now >= cpu_last_warning + conf.cpu_alert_interval) { + if (now >= cpu_last_warning + conf.cpu_alert_interval_ms) { DataProxy.sendAlert(AlertLevel.WARN, "WARNING_CPU_HIGH", "cpu high " + nextCpu + "%", null); cpu_last_warning = now; } @@ -238,7 +238,7 @@ public void disk(CounterBasket pw) { } } String dir = fs.getDirName(); - if (conf.disk_ignore.hasKey(dir)) + if (conf.disk_ignore_names.hasKey(dir)) continue; usage = sigar.getFileSystemUsage(dir); diff --git a/scouter.agent.host/src/scouter/agent/counter/task/ProcPerf.java b/scouter.agent.host/src/scouter/agent/counter/task/ProcPerf.java index 65c1011c3..c54c3fe01 100644 --- a/scouter.agent.host/src/scouter/agent/counter/task/ProcPerf.java +++ b/scouter.agent.host/src/scouter/agent/counter/task/ProcPerf.java @@ -2,7 +2,6 @@ import java.io.File; -import org.hyperic.sigar.CpuPerc; import org.hyperic.sigar.ProcCpu; import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; @@ -20,9 +19,6 @@ import scouter.lang.value.FloatValue; import scouter.util.CastUtil; import scouter.util.FileUtil; -import scouter.util.FormatUtil; -import scouter.util.IntKeyLinkedMap; -import scouter.util.SysJMX; public class ProcPerf { @@ -33,7 +29,7 @@ public class ProcPerf { private static File regRoot = null; public static void ready() { - String objReg = Configure.getInstance().object_registry; + String objReg = Configure.getInstance().counter_object_registry_path; File objRegFile = new File(objReg); if (objRegFile.canRead() == false) { objRegFile.mkdirs(); diff --git a/scouter.agent.host/src/scouter/agent/netio/data/DataProxy.java b/scouter.agent.host/src/scouter/agent/netio/data/DataProxy.java index 8f3b3ae1b..8c05329bf 100644 --- a/scouter.agent.host/src/scouter/agent/netio/data/DataProxy.java +++ b/scouter.agent.host/src/scouter/agent/netio/data/DataProxy.java @@ -41,8 +41,8 @@ public class DataProxy { public static void sendAlert(byte level, String title, String message, MapValue tags) { AlertPack p = new AlertPack(); - p.objType = conf.scouter_type; - p.objHash = conf.objHash; + p.objType = conf.obj_type; + p.objHash = conf.getObjHash(); p.level = level; p.title = title; p.message = message; @@ -99,7 +99,7 @@ public static void sendCounter(PerfCounterPack[] p) { int bytes = 0; for (int k = 0; k < p.length; k++) { byte[] b = new DataOutputX().writePack(p[k]).toByteArray(); - if (bytes + b.length >= conf.udp_packet_max) { + if (bytes + b.length >= conf.net_udp_packet_max_bytes) { sendDirect(buff); // buff.size가 0일수도 있다. bytes = 0;// bytes 값 초기화.. buff.clear(); @@ -117,7 +117,7 @@ public static void sendHeartBeat(ObjectPack p) { udpCollect.write(new DataOutputX().writePack(p).toByteArray()); } catch (Exception e) { } - if (conf.debug_udp_object) { + if (conf.log_udp_object) { Logger.info(p.toString()); } } diff --git a/scouter.agent.host/src/scouter/agent/netio/data/net/DataUdpAgent.java b/scouter.agent.host/src/scouter/agent/netio/data/net/DataUdpAgent.java index c0b7fb4c3..2f8a5fc51 100644 --- a/scouter.agent.host/src/scouter/agent/netio/data/net/DataUdpAgent.java +++ b/scouter.agent.host/src/scouter/agent/netio/data/net/DataUdpAgent.java @@ -59,8 +59,8 @@ public void run() { private void setTarget() { Configure conf = Configure.getInstance(); - String host = conf.server_addr; - int port = conf.server_udp_port; + String host = conf.net_collector_ip; + int port = conf.net_collector_udp_port; try { server_host = InetAddress.getByName(host); server_port = port; @@ -81,8 +81,8 @@ protected void close(DatagramSocket d) { private void openDatagramSocket() { try { Configure conf = Configure.getInstance(); - String host = conf.local_udp_addr; - int port = conf.local_udp_port; + String host = conf.net_local_udp_ip; + int port = conf.net_local_udp_port; if (datagram == null || CompareUtil.equals(host, local_udp_addr) == false || local_udp_port != port) { close(datagram); local_udp_addr = host; @@ -114,8 +114,8 @@ public boolean write(byte[] p) { if (server_host == null) return false; - if (p.length > conf.udp_packet_max) { - return writeMTU(p, conf.udp_packet_max); + if (p.length > conf.net_udp_packet_max_bytes) { + return writeMTU(p, conf.net_udp_packet_max_bytes); } DataOutputX out = new DataOutputX(); @@ -162,7 +162,7 @@ private boolean writeMTU(byte[] data, int packetSize) { private void writeMTU(long pkid, int total, int num, int packetSize, byte[] data) throws IOException { DataOutputX out = new DataOutputX(); out.write(NetCafe.CAFE_MTU); - out.writeInt(conf.objHash); + out.writeInt(conf.getObjHash()); out.writeLong(pkid); out.writeShort(total); out.writeShort(num); diff --git a/scouter.agent.host/src/scouter/agent/netio/data/net/TcpRequestMgr.java b/scouter.agent.host/src/scouter/agent/netio/data/net/TcpRequestMgr.java index 91ccb150f..459a11f9d 100644 --- a/scouter.agent.host/src/scouter/agent/netio/data/net/TcpRequestMgr.java +++ b/scouter.agent.host/src/scouter/agent/netio/data/net/TcpRequestMgr.java @@ -1,8 +1,6 @@ package scouter.agent.netio.data.net; import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import scouter.agent.Configure; import scouter.util.ThreadUtil; @@ -27,7 +25,7 @@ public static synchronized TcpRequestMgr getInstance() { public void run() { while (true) { - int sessionCount = Configure.getInstance().server_tcp_session_count; + int sessionCount = Configure.getInstance().net_collector_tcp_session_count; ThreadUtil.sleep(1000); try { for (int i = 0; i < sessionCount && TcpWorker.LIVE.size() < sessionCount; i++) { diff --git a/scouter.agent.host/src/scouter/agent/netio/data/net/TcpWorker.java b/scouter.agent.host/src/scouter/agent/netio/data/net/TcpWorker.java index ccd53be91..72d52681e 100644 --- a/scouter.agent.host/src/scouter/agent/netio/data/net/TcpWorker.java +++ b/scouter.agent.host/src/scouter/agent/netio/data/net/TcpWorker.java @@ -5,9 +5,6 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.concurrent.atomic.AtomicInteger; import scouter.agent.Configure; import scouter.agent.netio.request.ReqestHandlingProxy; @@ -23,7 +20,7 @@ public class TcpWorker implements Runnable { public static IntKeyLinkedMap LIVE = new IntKeyLinkedMap(); public static String localAddr = null; - public int objHash = Configure.getInstance().objHash; + public int objHash = Configure.getInstance().getObjHash(); public void run() { if (socket == null) @@ -44,10 +41,10 @@ public void close(){ public boolean prepare() { Configure conf = Configure.getInstance(); - String host = conf.server_addr; - int port = conf.server_tcp_port; - int so_timeout = conf.server_tcp_so_timeout; - int connection_timeout = conf.server_tcp_connection_timeout; + String host = conf.net_collector_ip; + int port = conf.net_collector_tcp_port; + int so_timeout = conf.net_collector_tcp_so_timeout_ms; + int connection_timeout = conf.net_collector_tcp_connection_timeout_ms; socket = new Socket(); try { @@ -74,7 +71,7 @@ private void process(Socket socket) throws IOException { out.writeInt(objHash); out.flush(); - while (objHash == Configure.getInstance().objHash) { + while (objHash == Configure.getInstance().getObjHash()) { String cmd = in.readText(); Pack parameter = (Pack) in.readPack(); Pack res = ReqestHandlingProxy.process(cmd, parameter, in, out); diff --git a/scouter.agent.java/src/scouter/agent/Configure.java b/scouter.agent.java/src/scouter/agent/Configure.java index 5382e3ef0..46305802e 100644 --- a/scouter.agent.java/src/scouter/agent/Configure.java +++ b/scouter.agent.java/src/scouter/agent/Configure.java @@ -109,7 +109,7 @@ public final static synchronized Configure getInstance() { public String trace_webserver_time_header_key = "X-Forwarded-Time"; public int _trace_fullstack_socket_open_port = 0; - //Manage + //Manager public File mgr_plugin_dir = new File("./_scouter_"); public File mgr_dump_dir = new File("."); public File mgr_agent_lib_dir = new File("./_scouter_"); @@ -649,13 +649,6 @@ public void printConfig() { private static HashSet ignoreSet = new HashSet(); static { ignoreSet.add("property"); - ignoreSet.add("objHash"); - ignoreSet.add("objHostHash"); - ignoreSet.add("objHostName"); - ignoreSet.add("objName"); - ignoreSet.add("objType"); - ignoreSet.add("log_ignore_set"); - ignoreSet.add("enduser_perf_endpoint_hash"); } public MapValue getKeyValueInfo() { StringKeyLinkedMap defMap = ConfigValueUtil.getConfigDefault(new Configure(true)); diff --git a/scouter.server/src/scouter/server/Configure.java b/scouter.server/src/scouter/server/Configure.java index 6bfbd7b52..6916deffa 100644 --- a/scouter.server/src/scouter/server/Configure.java +++ b/scouter.server/src/scouter/server/Configure.java @@ -112,7 +112,7 @@ public final static synchronized Configure getInstance() { //Auto public boolean _auto_5m_sampling = true; - //Manage + //Manager public boolean mgr_purge_enabled = true; public boolean mgr_purge_only_xlog_enabled = false; public int mgr_purge_disk_usage_pct = 80; From 5bc8dc2ccbea2941e474eeec993ab1102bee935b Mon Sep 17 00:00:00 2001 From: Gunhee Lee Date: Mon, 7 Dec 2015 17:54:46 +0900 Subject: [PATCH 29/42] agent asm buf fix & end user script error gathering --- .../src/scouter/agent/AgentTransformer.java | 277 ++++++++++-------- .../src/scouter/agent/Configure.java | 2 +- .../agent/summary/EndUserErrorData.java | 31 +- .../scouter/agent/summary/EndUserSummary.java | 81 ++--- .../src/scouter/xtra/http/HttpTrace.java | 58 ++-- .../src/scouter/util/StringUtil.java | 18 +- .../script/src/error/scouter-script-error.js | 10 +- 7 files changed, 280 insertions(+), 197 deletions(-) diff --git a/scouter.agent.java/src/scouter/agent/AgentTransformer.java b/scouter.agent.java/src/scouter/agent/AgentTransformer.java index f4a1aef51..7a0e673c5 100644 --- a/scouter.agent.java/src/scouter/agent/AgentTransformer.java +++ b/scouter.agent.java/src/scouter/agent/AgentTransformer.java @@ -16,8 +16,7 @@ */ package scouter.agent; -import scouter.agent.asm.IASM; -import scouter.agent.asm.ScouterClassWriter; +import scouter.agent.asm.*; import scouter.agent.asm.util.AsmUtil; import scouter.agent.util.AsyncRunner; import scouter.lang.conf.ConfObserver; @@ -30,123 +29,161 @@ import java.security.ProtectionDomain; import java.util.ArrayList; import java.util.List; + public class AgentTransformer implements ClassFileTransformer { - public static ThreadLocal hookingCtx = new ThreadLocal(); - private static List asms = new ArrayList(); - // hook 관련 설정이 변경되면 자동으로 변경된다. - private static int hook_signature; - static { - final Configure conf = Configure.getInstance(); - reload(); - hook_signature = conf.getHookSignature(); - ConfObserver.add("AgentTransformer", new Runnable() { - public void run() { - if (conf.getHookSignature() != hook_signature) { - reload(); - } - hook_signature = conf.getHookSignature(); - } - }); - } - public static void reload() { - Configure conf = Configure.getInstance(); - List temp = new ArrayList(); - asms = temp; - } - // ////////////////////////////////////////////////////////////// - // boot class이지만 Hooking되어야하는 클래스를 등록한다. - private static IntSet asynchook = new IntSet(); - static { - asynchook.add("sun/net/www/protocol/http/HttpURLConnection".hashCode()); - asynchook.add("sun/net/www/http/HttpClient".hashCode()); - asynchook.add("java/net/Socket".hashCode()); - asynchook.add("javax/naming/InitialContext".hashCode()); - } - private Configure conf = Configure.getInstance(); - private Logger.FileLog bciOut; - public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, - ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { - try { - hookingCtx.set(loader); - if (className == null) - return null; - if (classBeingRedefined == null) { - if (asynchook.contains(className.hashCode())) { - AsyncRunner.getInstance().add(loader, className, classfileBuffer); - return null; - } - if (loader == null) { - return null; - } - } - if (className.startsWith("scouter/")) { - return null; - } - // - classfileBuffer = DirectPatch.patch(className, classfileBuffer); - ObjTypeDetector.check(className); - final ClassDesc classDesc = new ClassDesc(); - ClassReader cr = new ClassReader(classfileBuffer); - cr.accept(new ClassVisitor(Opcodes.ASM4) { - public void visit(int version, int access, String name, String signature, String superName, - String[] interfaces) { - classDesc.set(version, access, name, signature, superName, interfaces); - } - @Override - public AnnotationVisitor visitAnnotation(String desc, boolean visible) { - classDesc.anotation += desc; - return super.visitAnnotation(desc, visible); - } - }, 0); - if (AsmUtil.isInterface(classDesc.access)) { - return null; - } - classDesc.classBeingRedefined = classBeingRedefined; - ClassWriter cw = getClassWriter(classDesc); - ClassVisitor cv = cw; - List workAsms = asms; - for (int i = 0, max = workAsms.size(); i < max; i++) { - cv = workAsms.get(i).transform(cv, className, classDesc); - if (cv != cw) { - cr = new ClassReader(classfileBuffer); - cr.accept(cv, ClassReader.EXPAND_FRAMES); - classfileBuffer = cw.toByteArray(); - cv = cw = getClassWriter(classDesc); - if (conf.log_asm_enabled) { - if (this.bciOut == null) { - this.bciOut = new Logger.FileLog("./scouter.bci"); - } - this.bciOut.println(className + "\t\t[" + loader + "]"); - } - } - } - return classfileBuffer; - } catch (Throwable t) { - Logger.println("A101", "Transformer Error", t); - t.printStackTrace(); - } finally { - hookingCtx.set(null); - } - return null; - } - private ClassWriter getClassWriter(final ClassDesc classDesc) { - ClassWriter cw; - switch (classDesc.version) { - case Opcodes.V1_1: - case Opcodes.V1_2: - case Opcodes.V1_3: - case Opcodes.V1_4: - case Opcodes.V1_5: - case Opcodes.V1_6: - cw = new ScouterClassWriter(ClassWriter.COMPUTE_MAXS); - break; - default: - cw = new ScouterClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - } - return cw; - } - private void dump(String className, byte[] bytes) { - String fname = "/tmp/" + className.replace('/', '_'); - FileUtil.save(fname, bytes); - } + public static ThreadLocal hookingCtx = new ThreadLocal(); + private static List asms = new ArrayList(); + // hook 관련 설정이 변경되면 자동으로 변경된다. + private static int hook_signature; + + static { + final Configure conf = Configure.getInstance(); + reload(); + hook_signature = conf.getHookSignature(); + ConfObserver.add("AgentTransformer", new Runnable() { + public void run() { + if (conf.getHookSignature() != hook_signature) { + reload(); + } + hook_signature = conf.getHookSignature(); + } + }); + } + + public static void reload() { + Configure conf = Configure.getInstance(); + List temp = new ArrayList(); + temp.add(new HttpServiceASM()); + temp.add(new ServiceASM()); + + temp.add(new JDBCPreparedStatementASM()); + temp.add(new JDBCResultSetASM()); + temp.add(new JDBCStatementASM()); + temp.add(new SqlMapASM()); + temp.add(new UserTxASM()); + + temp.add(new JDBCConnectionOpenASM()); + temp.add(new JDBCDriverASM()); + temp.add(new InitialContextASM()); + + temp.add(new CapArgsASM()); + temp.add(new CapReturnASM()); + temp.add(new CapThisASM()); + + temp.add(new MethodASM()); + temp.add(new ApicallASM()); + temp.add(new ApicallInfoASM()); + temp.add(new SpringReqMapASM()); + + temp.add(new SocketASM()); + + temp.add(new JspServletASM()); + + temp.add(new AddFieldASM()); + + asms = temp; + } + + // ////////////////////////////////////////////////////////////// + // boot class이지만 Hooking되어야하는 클래스를 등록한다. + private static IntSet asynchook = new IntSet(); + + static { + asynchook.add("sun/net/www/protocol/http/HttpURLConnection".hashCode()); + asynchook.add("sun/net/www/http/HttpClient".hashCode()); + asynchook.add("java/net/Socket".hashCode()); + asynchook.add("javax/naming/InitialContext".hashCode()); + } + + private Configure conf = Configure.getInstance(); + private Logger.FileLog bciOut; + + public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, + ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { + try { + hookingCtx.set(loader); + if (className == null) + return null; + if (classBeingRedefined == null) { + if (asynchook.contains(className.hashCode())) { + AsyncRunner.getInstance().add(loader, className, classfileBuffer); + return null; + } + if (loader == null) { + return null; + } + } + if (className.startsWith("scouter/")) { + return null; + } + // + classfileBuffer = DirectPatch.patch(className, classfileBuffer); + ObjTypeDetector.check(className); + final ClassDesc classDesc = new ClassDesc(); + ClassReader cr = new ClassReader(classfileBuffer); + cr.accept(new ClassVisitor(Opcodes.ASM4) { + public void visit(int version, int access, String name, String signature, String superName, + String[] interfaces) { + classDesc.set(version, access, name, signature, superName, interfaces); + } + + @Override + public AnnotationVisitor visitAnnotation(String desc, boolean visible) { + classDesc.anotation += desc; + return super.visitAnnotation(desc, visible); + } + }, 0); + if (AsmUtil.isInterface(classDesc.access)) { + return null; + } + classDesc.classBeingRedefined = classBeingRedefined; + ClassWriter cw = getClassWriter(classDesc); + ClassVisitor cv = cw; + List workAsms = asms; + for (int i = 0, max = workAsms.size(); i < max; i++) { + cv = workAsms.get(i).transform(cv, className, classDesc); + if (cv != cw) { + cr = new ClassReader(classfileBuffer); + cr.accept(cv, ClassReader.EXPAND_FRAMES); + classfileBuffer = cw.toByteArray(); + cv = cw = getClassWriter(classDesc); + if (conf.log_asm_enabled) { + if (this.bciOut == null) { + this.bciOut = new Logger.FileLog("./scouter.bci"); + } + this.bciOut.println(className + "\t\t[" + loader + "]"); + } + } + } + return classfileBuffer; + } catch (Throwable t) { + Logger.println("A101", "Transformer Error", t); + t.printStackTrace(); + } finally { + hookingCtx.set(null); + } + return null; + } + + private ClassWriter getClassWriter(final ClassDesc classDesc) { + ClassWriter cw; + switch (classDesc.version) { + case Opcodes.V1_1: + case Opcodes.V1_2: + case Opcodes.V1_3: + case Opcodes.V1_4: + case Opcodes.V1_5: + case Opcodes.V1_6: + cw = new ScouterClassWriter(ClassWriter.COMPUTE_MAXS); + break; + default: + cw = new ScouterClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + } + return cw; + } + + private void dump(String className, byte[] bytes) { + String fname = "/tmp/" + className.replace('/', '_'); + FileUtil.save(fname, bytes); + } } diff --git a/scouter.agent.java/src/scouter/agent/Configure.java b/scouter.agent.java/src/scouter/agent/Configure.java index 46305802e..826a1489f 100644 --- a/scouter.agent.java/src/scouter/agent/Configure.java +++ b/scouter.agent.java/src/scouter/agent/Configure.java @@ -209,7 +209,7 @@ public final static synchronized Configure getInstance() { public int summary_enduser_error_max_count = 5000; //EndUser - public String enduser_trace_endpoint_url = "_scouter_browser.jsp"; + public String enduser_trace_endpoint_url = "/_scouter_browser.jsp"; //internal variables private int objHash; diff --git a/scouter.agent.java/src/scouter/agent/summary/EndUserErrorData.java b/scouter.agent.java/src/scouter/agent/summary/EndUserErrorData.java index 6f66d0a93..7c24c020d 100644 --- a/scouter.agent.java/src/scouter/agent/summary/EndUserErrorData.java +++ b/scouter.agent.java/src/scouter/agent/summary/EndUserErrorData.java @@ -17,14 +17,31 @@ package scouter.agent.summary; public class EndUserErrorData { - public int stacktrace; + public int count; + + public int host; + public int uri; + public int stacktrace; public int userAgent; - public int count; - // - public int uri; + public int name; public int message; public int file; - public int lineNumber;// :1 - public int columnNumber;// :26 - public int payloadVersion;// :2 + public int lineNumber; + public int columnNumber; + + @Override + public String toString() { + return "EndUserErrorData{" + + "count=" + count + + ", host=" + host + + ", uri=" + uri + + ", stacktrace=" + stacktrace + + ", userAgent=" + userAgent + + ", name=" + name + + ", message=" + message + + ", file=" + file + + ", lineNumber=" + lineNumber + + ", columnNumber=" + columnNumber + + '}'; + } } diff --git a/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java b/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java index 1d8bf207b..008bc495d 100644 --- a/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java +++ b/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java @@ -16,8 +16,6 @@ */ package scouter.agent.summary; -import java.util.Enumeration; - import scouter.agent.Configure; import scouter.lang.SummaryEnum; import scouter.lang.pack.SummaryPack; @@ -25,6 +23,8 @@ import scouter.util.BitUtil; import scouter.util.LongKeyLinkedMap; +import java.util.Enumeration; + public class EndUserSummary { private static EndUserSummary instance = null; @@ -38,59 +38,60 @@ public final static synchronized EndUserSummary getInstance() { private Configure conf = Configure.getInstance(); - public void process(EndUserNavigationData p) { + public void process(EndUserNavigationData data) { if (conf.summary_enabled == false) return; // service summary - long key = BitUtil.composite(p.uri, p.ip); + long key = BitUtil.composite(data.uri, data.ip); EndUserNavigationData d = navTable.get(key); if (d == null) { - navTable.put(key, p); + navTable.put(key, data); return; } - d.count += p.count; - d.unloadEventStart += p.unloadEventStart; - d.unloadEventEnd += p.unloadEventEnd; - d.fetchStart += p.fetchStart; - d.domainLookupStart += p.domainLookupStart; - d.domainLookupEnd += p.domainLookupEnd; - d.connectStart += p.connectStart; - d.connectEnd += p.connectEnd; - d.requestStart += p.requestStart; - d.responseStart += p.responseStart; - d.responseEnd += p.responseEnd; - d.domLoading += p.domLoading; - d.domInteractive += p.domInteractive; - d.domContentLoadedEventStart += p.domContentLoadedEventStart; - d.domContentLoadedEventEnd += p.domContentLoadedEventEnd; - d.domComplete += p.domComplete; - d.loadEventStart += p.loadEventStart; - d.loadEventEnd += p.loadEventEnd; + d.count += data.count; + d.unloadEventStart += data.unloadEventStart; + d.unloadEventEnd += data.unloadEventEnd; + d.fetchStart += data.fetchStart; + d.domainLookupStart += data.domainLookupStart; + d.domainLookupEnd += data.domainLookupEnd; + d.connectStart += data.connectStart; + d.connectEnd += data.connectEnd; + d.requestStart += data.requestStart; + d.responseStart += data.responseStart; + d.responseEnd += data.responseEnd; + d.domLoading += data.domLoading; + d.domInteractive += data.domInteractive; + d.domContentLoadedEventStart += data.domContentLoadedEventStart; + d.domContentLoadedEventEnd += data.domContentLoadedEventEnd; + d.domComplete += data.domComplete; + d.loadEventStart += data.loadEventStart; + d.loadEventEnd += data.loadEventEnd; } - public void process(EndUserErrorData p) { + public void process(EndUserErrorData data) { if (conf.summary_enabled == false) return; - long key = BitUtil.composite(p.stacktrace, p.userAgent); + + long key = BitUtil.composite(data.stacktrace, data.userAgent); EndUserErrorData d = errorTable.get(key); if (d == null) { - errorTable.put(key, p); + errorTable.put(key, data); return; } - d.count += p.count; + d.count += data.count; } - public void process(EndUserAjaxData p) { + public void process(EndUserAjaxData data) { if (conf.summary_enabled == false) return; - long key = BitUtil.composite(p.uri, p.ip); + long key = BitUtil.composite(data.uri, data.ip); EndUserAjaxData d = ajaxTable.get(key); if (d == null) { - ajaxTable.put(key, p); + ajaxTable.put(key, data); return; } - d.count += p.count; - d.duration += p.duration; + d.count += data.count; + d.duration += data.duration; } private LongKeyLinkedMap navTable = new LongKeyLinkedMap() @@ -169,7 +170,7 @@ public SummaryPack getAndClearNavTable() { public SummaryPack getAndClearAjaxTable() { - if (navTable.size() == 0) + if (ajaxTable.size() == 0) return null; LongKeyLinkedMap temp = ajaxTable; @@ -205,7 +206,7 @@ public SummaryPack getAndClearAjaxTable() { } public SummaryPack getAndClearErrorTable() { - if (navTable.size() == 0) + if (errorTable.size() == 0) return null; LongKeyLinkedMap temp = errorTable; @@ -221,29 +222,33 @@ public SummaryPack getAndClearErrorTable() { ListValue userAgent = p.table.newList("userAgent"); ListValue uri = p.table.newList("uri"); + ListValue name = p.table.newList("name"); ListValue message = p.table.newList("message"); ListValue file = p.table.newList("file"); ListValue lineNumber = p.table.newList("lineNumber"); ListValue columnNumber = p.table.newList("columnNumber"); - ListValue payloadVersion = p.table.newList("payloadVersion"); Enumeration en = temp.entries(); for (int i = 0; i < cnt; i++) { + LongKeyLinkedMap.ENTRY ent = en.nextElement(); long key = ent.getKey(); EndUserErrorData data = ent.getValue(); - id.add(key); + + //Logger.println("@ getAndClearErrorTable --> print datas"); + //Logger.println(data); + + id.add(key); count.add(data.count); stacktrace.add(data.stacktrace); userAgent.add(data.userAgent); uri.add(data.uri); + name.add(data.name); message.add(data.message); file.add(data.file); lineNumber.add(data.lineNumber); columnNumber.add(data.columnNumber); - payloadVersion.add(data.payloadVersion); - } return p; } diff --git a/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java b/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java index 441c1c00a..57b26809f 100644 --- a/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java +++ b/scouter.agent.java/src/scouter/xtra/http/HttpTrace.java @@ -17,14 +17,6 @@ package scouter.xtra.http; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Enumeration; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import scouter.agent.Configure; import scouter.agent.counter.meter.MeterUsers; import scouter.agent.netio.data.DataProxy; @@ -32,15 +24,20 @@ import scouter.agent.summary.EndUserAjaxData; import scouter.agent.summary.EndUserErrorData; import scouter.agent.summary.EndUserNavigationData; +import scouter.agent.summary.EndUserSummary; import scouter.agent.trace.IProfileCollector; import scouter.agent.trace.TraceContext; import scouter.agent.trace.TraceMain; import scouter.lang.conf.ConfObserver; import scouter.lang.step.MessageStep; -import scouter.util.CompareUtil; -import scouter.util.HashUtil; -import scouter.util.Hexa32; -import scouter.util.StringUtil; +import scouter.util.*; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Enumeration; public class HttpTrace implements IHttpTrace { public HttpTrace() { @@ -81,11 +78,10 @@ public void start(TraceContext ctx, Object req, Object res) { ctx.serviceName = getRequestURI(request); ctx.serviceHash = HashUtil.hash(ctx.serviceName); - - // - if(ctx.serviceHash == conf.getEndUserPerfEndpointHash()){ + + if(ctx.serviceHash == conf.getEndUserPerfEndpointHash()){ ctx.isStaticContents=true; - enduser(request); + processEndUserData(request); return; } @@ -184,12 +180,36 @@ public void start(TraceContext ctx, Object req, Object res) { } } - private void enduser(HttpServletRequest request) { + private void processEndUserData(HttpServletRequest request) { EndUserNavigationData nav; EndUserErrorData err; EndUserAjaxData ajax; - - + + if("err".equals(request.getParameter("p"))) { + EndUserErrorData data = new EndUserErrorData(); + + data.count = 1; + data.stacktrace = DataProxy.sendError(StringUtil.nullToEmpty(request.getParameter("stacktrace"))); + data.userAgent = DataProxy.sendUserAgent(StringUtil.nullToEmpty(request.getParameter("userAgent"))); + data.host = DataProxy.sendServiceName(StringUtil.nullToEmpty(request.getParameter("host"))); + data.uri = DataProxy.sendServiceName(StringUtil.nullToEmpty(request.getParameter("uri"))); + data.message = DataProxy.sendError(StringUtil.nullToEmpty(request.getParameter("message"))); + data.name = DataProxy.sendError(StringUtil.nullToEmpty(request.getParameter("name"))); + data.file = DataProxy.sendServiceName(StringUtil.nullToEmpty(request.getParameter("file"))); + data.lineNumber = CastUtil.cint(request.getParameter("lineNumber")); + data.columnNumber = CastUtil.cint(request.getParameter("columnNumber")); + + //Logger.println("@ input error data -> print"); + //Logger.println(data); + + EndUserSummary.getInstance().process(data); + + } else if("nav".equals(request.getParameter("p"))) { + + } else if("ax".equals(request.getParameter("p"))) { + + } + //EndUserSummary.getInstance().process(p); } diff --git a/scouter.common/src/scouter/util/StringUtil.java b/scouter.common/src/scouter/util/StringUtil.java index 9363f437d..9e524ca60 100644 --- a/scouter.common/src/scouter/util/StringUtil.java +++ b/scouter.common/src/scouter/util/StringUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015 the original author or authors. * @https://github.com/scouter-project/scouter * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -102,12 +102,20 @@ public static String limiting(String s, int max) { return s; } + public static String trim(String s) { + return s == null ? null : s.trim(); + } + public static String trimEmpty(String s) { return s == null ? "" : s.trim(); } - public static String trim(String s) { - return s == null ? null : s.trim(); + public static String trimToEmpty(String s) { + return trimEmpty(s); + } + + public static String nullToEmpty(String s) { + return s == null ? "" : s; } public static boolean isEmpty(String s) { @@ -156,10 +164,6 @@ public static String[] split(String s, String delim) { return arr.toArray(new String[arr.size()]); } - public static String trimToEmpty(String x) { - return x == null ? "" : x.trim(); - } - public static String removeWhitespace(String str) { if (isEmpty(str)) { return str; diff --git a/scouter.enduser.script/script/src/error/scouter-script-error.js b/scouter.enduser.script/script/src/error/scouter-script-error.js index 5c286692b..4b0fdec2f 100644 --- a/scouter.enduser.script/script/src/error/scouter-script-error.js +++ b/scouter.enduser.script/script/src/error/scouter-script-error.js @@ -118,7 +118,7 @@ THE SOFTWARE.*/ sendToScouter({ name: name || exception.name, message: exception.message || exception.description, - stacktrace: stacktraceFromException(exception) || generateStacktrace(), + stacktrace: stacktraceFromException(exception) || generateStacktrace(exception.message || exception.description), file: exception.fileName || exception.sourceURL, lineNumber: exception.lineNumber || exception.line, columnNumber: exception.columnNumber ? exception.columnNumber + 1 : undefined, @@ -134,7 +134,7 @@ THE SOFTWARE.*/ sendToScouter({ name: name, message: message, - stacktrace: generateStacktrace(), + stacktrace: generateStacktrace(message), // These are defaults so that 'scouter.notify()' calls show up in old IE, // newer browsers get a legit stacktrace from generateStacktrace(). file: window.location.toString(), @@ -479,7 +479,7 @@ THE SOFTWARE.*/ // Generate a browser stacktrace (or approximation) from the current stack. // This is used to add a stacktrace to `Scouter.notify` calls, and to add a // stacktrace approximation where we can't get one from an exception. - function generateStacktrace() { + function generateStacktrace(message) { var generated, stacktrace; var MAX_FAKE_STACK_SIZE = 10; var ANONYMOUS_FUNCTION_PLACEHOLDER = "[anonymous]"; @@ -515,7 +515,7 @@ THE SOFTWARE.*/ // generateStacktrace() + window.onerror, // generateStacktrace() + notify, // generateStacktrace() + notifyException - return generated + stacktrace; + return generated + "" + stacktrace; } // Get the stacktrace string from an exception @@ -630,7 +630,7 @@ THE SOFTWARE.*/ file: url, lineNumber: lineNo, columnNumber: charNo, - stacktrace: (exception && stacktraceFromException(exception)) || generateStacktrace(), + stacktrace: (exception && stacktraceFromException(exception)) || generateStacktrace(message), severity: "error" }, metaData); } From 49d20f9a68af7f0de2cabee3fe8710e2db7100cf Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Mon, 7 Dec 2015 19:20:08 +0900 Subject: [PATCH 30/42] cons view demoed --- .../configuration/views/ConfigureView.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/scouter.client/src/scouter/client/configuration/views/ConfigureView.java b/scouter.client/src/scouter/client/configuration/views/ConfigureView.java index 0b61ef4ee..52210259f 100644 --- a/scouter.client/src/scouter/client/configuration/views/ConfigureView.java +++ b/scouter.client/src/scouter/client/configuration/views/ConfigureView.java @@ -30,6 +30,8 @@ import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.StyledText; @@ -41,6 +43,8 @@ import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.FillLayout; @@ -93,6 +97,8 @@ public class ConfigureView extends ViewPart { CustomLineStyleListener listener; + boolean devMode; + public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); @@ -103,6 +109,20 @@ public void createPartControl(Composite parent) { searchTxt = new Text(listComp, SWT.BORDER); searchTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); searchTxt.setToolTipText("Search Key/Value"); + searchTxt.addMouseListener(new MouseListener() { + int clicked; + public void mouseUp(MouseEvent arg0) { + } + public void mouseDown(MouseEvent arg0) { + clicked++; + if (clicked == 10) { + devMode = true; + viewer.refresh(); + } + } + public void mouseDoubleClick(MouseEvent arg0) { + } + }); searchTxt.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { String searchText = searchTxt.getText(); @@ -133,6 +153,7 @@ public void modifyText(ModifyEvent e) { table.setLinesVisible(true); viewer.setContentProvider(new ArrayContentProvider()); viewer.setComparator(new ColumnLabelSorter(viewer)); + viewer.addFilter(filter); table.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if(e.stateMask == SWT.CTRL || e.stateMask == SWT.COMMAND){ @@ -388,5 +409,16 @@ public void widgetSelected(SelectionEvent e) { }); return viewerColumn; } - + + ViewerFilter filter = new ViewerFilter() { + public boolean select(Viewer viewer, Object parent, Object element) { + if (devMode) return true; + if (element instanceof ConfObject) { + if (((ConfObject)element).key.startsWith("_")) { + return false; + } + } + return true; + } + }; } From 1bc0b1aecaaef650c4e758c1085fcd40a52b4805 Mon Sep 17 00:00:00 2001 From: Gunhee Lee Date: Mon, 7 Dec 2015 20:07:48 +0900 Subject: [PATCH 31/42] add host on script error summary data --- .../scouter/agent/summary/EndUserSummary.java | 4 +- .../service/handle/SummaryEndUserError.scala | 69 ++++++++++--------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java b/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java index 008bc495d..32449b8c3 100644 --- a/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java +++ b/scouter.agent.java/src/scouter/agent/summary/EndUserSummary.java @@ -218,7 +218,8 @@ public SummaryPack getAndClearErrorTable() { int cnt = temp.size(); ListValue id = p.table.newList("id"); ListValue count = p.table.newList("count"); - ListValue stacktrace = p.table.newList("stacktrace"); + ListValue host = p.table.newList("host"); + ListValue stacktrace = p.table.newList("stacktrace"); ListValue userAgent = p.table.newList("userAgent"); ListValue uri = p.table.newList("uri"); @@ -240,6 +241,7 @@ public SummaryPack getAndClearErrorTable() { id.add(key); count.add(data.count); + host.add(data.host); stacktrace.add(data.stacktrace); userAgent.add(data.userAgent); diff --git a/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserError.scala b/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserError.scala index ca0afa993..1845d4e38 100644 --- a/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserError.scala +++ b/scouter.server/src/scouter/server/netio/service/handle/SummaryEndUserError.scala @@ -1,18 +1,18 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.server.netio.service.handle; @@ -33,6 +33,7 @@ class SummaryEndUserError { class Temp1() { var id: Long = 0L; + var host: Int = 0 var stacktrace: Int = 0 var userAgent: Int = 0 var count: Int = 0 @@ -59,22 +60,23 @@ class SummaryEndUserError { if (p.stype == SummaryEnum.ENDUSER_SCRIPT_ERROR && (objType == null || objType == p.objType)) { val id = p.table.getList("id") + var host = p.table.getList("host") var stacktrace = p.table.getList("stacktrace") var userAgent = p.table.getList("userAgent") var count = p.table.getList("count") - // + // var uri = p.table.getList("uri") var message = p.table.getList("message") var file = p.table.getList("file") var lineNumber = p.table.getList("lineNumber") var columnNumber = p.table.getList("columnNumber") - var payloadVersion = p.table.getList("payloadVersion") for (i <- 0 to id.size() - 1) { var tempObj = tempMap.get(id.getInt(i)); if (tempObj == null) { tempObj = new Temp1(); tempObj.id = id.getLong(i); + tempObj.host = stacktrace.getInt(i); tempObj.stacktrace = stacktrace.getInt(i); tempObj.userAgent = userAgent.getInt(i); tempObj.uri = uri.getInt(i) @@ -82,7 +84,6 @@ class SummaryEndUserError { tempObj.file = file.getInt(i) tempObj.lineNumber = lineNumber.getInt(i) tempObj.columnNumber = columnNumber.getInt(i) - tempObj.payloadVersion = payloadVersion.getInt(i) tempMap.put(tempObj.id, tempObj); } @@ -93,23 +94,24 @@ class SummaryEndUserError { SummaryRD.readByTime(SummaryEnum.ENDUSER_SCRIPT_ERROR, date, stime, etime, handler) - val map = new MapPack(); + val map = new MapPack() var id = map.newList("id") - var stacktrace = map.newList("stacktrace"); - var userAgent = map.newList("userAgent"); - var uri = map.newList("uri"); - var message = map.newList("message"); - var file = map.newList("file"); - var lineNumber = map.newList("lineNumber"); - var columnNumber = map.newList("columnNumber"); - var payloadVersion = map.newList("payloadVersion"); - - val itr = tempMap.keys(); + var host = map.newList("host") + var stacktrace = map.newList("stacktrace") + var userAgent = map.newList("userAgent") + var uri = map.newList("uri") + var message = map.newList("message") + var file = map.newList("file") + var lineNumber = map.newList("lineNumber") + var columnNumber = map.newList("columnNumber") + + val itr = tempMap.keys() while (itr.hasMoreElements()) { - val key = itr.nextLong(); - val obj = tempMap.get(key); + val key = itr.nextLong() + val obj = tempMap.get(key) id.add(obj.id) + host.add(obj.host); stacktrace.add(obj.stacktrace) userAgent.add(obj.userAgent) uri.add(obj.uri) @@ -117,11 +119,10 @@ class SummaryEndUserError { file.add(obj.file) lineNumber.add(obj.lineNumber) columnNumber.add(obj.columnNumber) - payloadVersion.add(obj.payloadVersion) } - dout.writeByte(TcpFlag.HasNEXT); - dout.writePack(map); + dout.writeByte(TcpFlag.HasNEXT) + dout.writePack(map) } } \ No newline at end of file From bb9f6c5b95a32562561fdfd2b89dc06d9d008f74 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Tue, 8 Dec 2015 22:25:01 +0900 Subject: [PATCH 32/42] bug fix --- scouter.agent.java/src/scouter/agent/trace/TraceMain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java index aa7bdb992..b1feffe18 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java @@ -570,7 +570,7 @@ public static Object startMethod(int hash, String classMethod) { AutoServiceStartAnalyzer.put(classMethod, stack); MessageStep m = new MessageStep(); m.message = "SERVICE BACKSTACK:\n" + stack; - ((Stat) stat).ctx.profile.add(m); + ((LocalContext) stat).context.profile.add(m); } return new LocalContext(stat); } From cf57f3a818ca341bd475db3c45dac1a5ff261f4f Mon Sep 17 00:00:00 2001 From: SkyWorker Date: Wed, 9 Dec 2015 00:09:46 +0900 Subject: [PATCH 33/42] bugfix --- .../src/scouter/agent/trace/TraceMain.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java index b1feffe18..86c7f66ad 100644 --- a/scouter.agent.java/src/scouter/agent/trace/TraceMain.java +++ b/scouter.agent.java/src/scouter/agent/trace/TraceMain.java @@ -564,15 +564,18 @@ public static Object startMethod(int hash, String classMethod) { TraceContext ctx = TraceContextManager.getLocalContext(); if (ctx == null) { if (conf._trace_auto_service_enabled) { - Object stat = startService(classMethod, null, null, null, null, null, XLogTypes.APP_SERVICE); - if (conf._trace_auto_service_backstack_enabled) { + Object localContext = startService(classMethod, null, null, null, null, null, XLogTypes.APP_SERVICE); + //startService내부에서 에러가 나는 경우(발생하면 안됨) + //Null이 리턴될 수 있음(방어코드) + //@skyworker + if (localContext!=null && conf._trace_auto_service_backstack_enabled) { String stack = ThreadUtil.getStackTrace(Thread.currentThread().getStackTrace(), 2); AutoServiceStartAnalyzer.put(classMethod, stack); MessageStep m = new MessageStep(); m.message = "SERVICE BACKSTACK:\n" + stack; - ((LocalContext) stat).context.profile.add(m); + ((LocalContext) localContext).context.profile.add(m); } - return new LocalContext(stat); + return localContext; } return null; } @@ -585,10 +588,10 @@ public static Object startMethod(int hash, String classMethod) { ctx.profile.push(p); return new LocalContext(ctx, p); } - public static void endMethod(Object stat, Throwable thr) { - if (stat == null) + public static void endMethod(Object localContext, Throwable thr) { + if (localContext == null) return; - LocalContext lctx = (LocalContext) stat; + LocalContext lctx = (LocalContext) localContext; if (lctx.service) { endService(lctx.option, null, thr); return; From 17996f56e2ac91395105e5920e49f4f91b9367ab Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Wed, 9 Dec 2015 18:19:44 +0900 Subject: [PATCH 34/42] add load visitor service --- .../src/scouter/net/RequestCmd.java | 2 + ...er5mService.scala => VisitorService.scala} | 70 ++++++++++++------- 2 files changed, 47 insertions(+), 25 deletions(-) rename scouter.server/src/scouter/server/netio/service/handle/{User5mService.scala => VisitorService.scala} (67%) diff --git a/scouter.common/src/scouter/net/RequestCmd.java b/scouter.common/src/scouter/net/RequestCmd.java index 001b61a9a..b6008a119 100644 --- a/scouter.common/src/scouter/net/RequestCmd.java +++ b/scouter.common/src/scouter/net/RequestCmd.java @@ -239,6 +239,8 @@ public class RequestCmd { // VISITOR public static final String VISITOR_REALTIME = "VISITOR_REALTIME"; public static final String VISITOR_REALTIME_TOTAL = "VISITOR_REALTIME_TOTAL"; + public static final String VISITOR_LOADDATE = "VISITOR_LOADDATE"; + public static final String VISITOR_LOADDATE_TOTAL = "VISITOR_REALTIME_TOTAL"; // SUMMARY public static final String LOAD_SERVICE_SUMMARY = "LOAD_SERVICE_SUMMARY"; diff --git a/scouter.server/src/scouter/server/netio/service/handle/User5mService.scala b/scouter.server/src/scouter/server/netio/service/handle/VisitorService.scala similarity index 67% rename from scouter.server/src/scouter/server/netio/service/handle/User5mService.scala rename to scouter.server/src/scouter/server/netio/service/handle/VisitorService.scala index acfc85c51..37cc940f5 100644 --- a/scouter.server/src/scouter/server/netio/service/handle/User5mService.scala +++ b/scouter.server/src/scouter/server/netio/service/handle/VisitorService.scala @@ -15,34 +15,54 @@ * limitations under the License. * */ - -package scouter.server.netio.service.handle; - -import scouter.io.DataInputX -import scouter.io.DataOutputX -import scouter.lang.value.DecimalValue -import scouter.net.TcpFlag -import scouter.server.db.VisitorDB -import scouter.server.netio.service.anotation.ServiceHandler -import scouter.net.RequestCmd - -class User5mService { - - @ServiceHandler(RequestCmd.VISITOR_REALTIME) - def visitorRealtime(din: DataInputX, dout: DataOutputX, login: Boolean) { - val m = din.readMapPack(); + +package scouter.server.netio.service.handle; + +import scouter.io.DataInputX +import scouter.io.DataOutputX +import scouter.lang.value.DecimalValue +import scouter.net.TcpFlag +import scouter.server.db.VisitorDB +import scouter.server.netio.service.anotation.ServiceHandler +import scouter.net.RequestCmd + +class VisitorService { + + @ServiceHandler(RequestCmd.VISITOR_REALTIME) + def visitorRealtime(din: DataInputX, dout: DataOutputX, login: Boolean) { + val m = din.readMapPack(); val objHash = m.getInt("objHash"); - val value = VisitorDB.getVisitorObject(objHash); - dout.writeByte(TcpFlag.HasNEXT); - dout.writeValue(new DecimalValue(value)); - } - - @ServiceHandler(RequestCmd.VISITOR_REALTIME_TOTAL) - def visitorRealtimeTotal(din: DataInputX, dout: DataOutputX, login: Boolean) { + val value = VisitorDB.getVisitorObject(objHash); + dout.writeByte(TcpFlag.HasNEXT); + dout.writeValue(new DecimalValue(value)); + } + + @ServiceHandler(RequestCmd.VISITOR_REALTIME_TOTAL) + def visitorRealtimeTotal(din: DataInputX, dout: DataOutputX, login: Boolean) { val m = din.readMapPack(); val objType = m.getText("objType"); val value = VisitorDB.getVisitorObjType(objType); dout.writeByte(TcpFlag.HasNEXT); - dout.writeValue(new DecimalValue(value)); - } + dout.writeValue(new DecimalValue(value)); + } + + @ServiceHandler(RequestCmd.VISITOR_LOADDATE) + def visitorLoaddate(din: DataInputX, dout: DataOutputX, login: Boolean) { + val m = din.readMapPack(); + val objHash = m.getInt("objHash"); + val date = m.getText("date"); + val value = VisitorDB.getVisitorObject(date, objHash); + dout.writeByte(TcpFlag.HasNEXT); + dout.writeValue(new DecimalValue(value)); + } + + @ServiceHandler(RequestCmd.VISITOR_LOADDATE_TOTAL) + def visitorLoaddateTotal(din: DataInputX, dout: DataOutputX, login: Boolean) { + val m = din.readMapPack(); + val objType = m.getText("objType"); + val date = m.getText("date"); + val value = VisitorDB.getVisitorObjType(date, objType); + dout.writeByte(TcpFlag.HasNEXT); + dout.writeValue(new DecimalValue(value)); + } } \ No newline at end of file From f7c4ce9a6988bca9dcad817789a2992ab96953c9 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Wed, 9 Dec 2015 18:21:41 +0900 Subject: [PATCH 35/42] client required jre version --- scouter.client/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scouter.client/META-INF/MANIFEST.MF b/scouter.client/META-INF/MANIFEST.MF index 9e92e0776..448ab071a 100644 --- a/scouter.client/META-INF/MANIFEST.MF +++ b/scouter.client/META-INF/MANIFEST.MF @@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.jface.text, org.eclipse.zest.core, org.eclipse.zest.layouts -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Bundle-ClassPath: ., lib/scouter.common.jar, From 51891b1b641833955a980432715020722373e723 Mon Sep 17 00:00:00 2001 From: Gunhee Lee Date: Fri, 11 Dec 2015 14:18:18 +0900 Subject: [PATCH 36/42] typo --- scouter.agent.host/scripts/host.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scouter.agent.host/scripts/host.sh b/scouter.agent.host/scripts/host.sh index 48fb84125..2df4f6b52 100644 --- a/scouter.agent.host/scripts/host.sh +++ b/scouter.agent.host/scripts/host.sh @@ -2,4 +2,4 @@ mkdir logs > /dev/null 2>&1 cp nohup.out ./logs/nohup.$(date '+%Y%m%d%H%M%S').out > /dev/null 2>&1 nohup java -classpath ./scouter.host.jar scouter.boot.Boot ./lib > nohup.out & echo "Scouter host agent launching..." -echo "See the nohup.out." +echo "See the nohup.out." \ No newline at end of file From dac61f76ee94b80d52554169c551e221f9f43b39 Mon Sep 17 00:00:00 2001 From: Gunhee Lee Date: Fri, 11 Dec 2015 14:39:23 +0900 Subject: [PATCH 37/42] refactor scripts --- scouter.agent.host/scripts/host.sh | 6 ++---- scouter.agent.host/scripts/sample1.host.sh | 6 ++++++ scouter.server/scripts/sample1.startup.sh | 1 + scouter.server/scripts/startcon.sh | 1 + scouter.server/scripts/startup.sh | 4 +++- 5 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 scouter.agent.host/scripts/sample1.host.sh diff --git a/scouter.agent.host/scripts/host.sh b/scouter.agent.host/scripts/host.sh index 2df4f6b52..b356d58b2 100644 --- a/scouter.agent.host/scripts/host.sh +++ b/scouter.agent.host/scripts/host.sh @@ -1,5 +1,3 @@ -mkdir logs > /dev/null 2>&1 -cp nohup.out ./logs/nohup.$(date '+%Y%m%d%H%M%S').out > /dev/null 2>&1 +#!/usr/bin/env bash + nohup java -classpath ./scouter.host.jar scouter.boot.Boot ./lib > nohup.out & -echo "Scouter host agent launching..." -echo "See the nohup.out." \ No newline at end of file diff --git a/scouter.agent.host/scripts/sample1.host.sh b/scouter.agent.host/scripts/sample1.host.sh new file mode 100644 index 000000000..f226940b7 --- /dev/null +++ b/scouter.agent.host/scripts/sample1.host.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +mkdir logs > /dev/null 2>&1 +cp nohup.out ./logs/nohup.$(date '+%Y%m%d%H%M%S').out > /dev/null 2>&1 +nohup java -classpath ./scouter.host.jar scouter.boot.Boot ./lib > nohup.out & +echo "Scouter host agent launching..." +echo "See the nohup.out." \ No newline at end of file diff --git a/scouter.server/scripts/sample1.startup.sh b/scouter.server/scripts/sample1.startup.sh index 2fe15e5b3..22e5a5518 100644 --- a/scouter.server/scripts/sample1.startup.sh +++ b/scouter.server/scripts/sample1.startup.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash mkdir logs > /dev/null 2>&1 cp nohup.out ./logs/nohup.$(date '+%Y%m%d%H%M%S').out > /dev/null 2>&1 nohup java -Xmx512m -classpath ./boot.jar scouter.boot.Boot ./lib > nohup.out & diff --git a/scouter.server/scripts/startcon.sh b/scouter.server/scripts/startcon.sh index 0a1df62bd..22632b5c1 100644 --- a/scouter.server/scripts/startcon.sh +++ b/scouter.server/scripts/startcon.sh @@ -1,2 +1,3 @@ +#!/usr/bin/env bash java -Xmx512m -cp boot.jar scouter.boot.Boot ./lib -console diff --git a/scouter.server/scripts/startup.sh b/scouter.server/scripts/startup.sh index bf6870197..bc9d9dd70 100644 --- a/scouter.server/scripts/startup.sh +++ b/scouter.server/scripts/startup.sh @@ -1 +1,3 @@ -java -Xmx512m -classpath ./boot.jar scouter.boot.Boot ./lib \ No newline at end of file +#!/usr/bin/env bash + +nohup java -Xmx512m -classpath ./boot.jar scouter.boot.Boot ./lib > nohup.out & From d60c60618581bfef31e747bcee084e5934d29960 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Fri, 11 Dec 2015 19:58:54 +0900 Subject: [PATCH 38/42] load visitor --- scouter.client/plugin.xml | 16 ++ .../actions/OpenObjectDailyListAction.java | 2 +- .../actions/OpenDailyServiceCountAction.java | 2 +- .../actions/OpenPastCountViewAction.java | 4 +- .../OpenPastDateGroupCountViewAction.java | 2 +- .../actions/OpenPastDateViewAction.java | 4 +- .../OpenPastTimeTranXGroupViewAction.java | 2 +- .../actions/OpenPastTimeViewAction.java | 4 +- .../actions/OpenUniqueTotalVisitorAction.java | 5 +- .../actions/OpenUniqueVisitorAction.java | 5 +- .../actions/OpenVisitorLoadAction.java | 67 ++++++++ .../actions/OpenVisitorTotalLoadAction.java | 67 ++++++++ .../counter/views/CounterPastTimeAllView.java | 2 +- .../views/CounterPastTimeTotalView.java | 2 +- .../view/CounterPastTimeGroupAllView.java | 2 +- .../view/CounterPastTimeGroupTotalView.java | 2 +- .../group/view/XLogLoadTimeGroupView.java | 2 +- .../maria/actions/OpenDbDailyConnView.java | 4 +- .../scouter/client/popup/CalendarDialog.java | 6 +- .../client/popup/ObjectCounterDialog.java | 6 +- .../stack/actions/OpenStackDialogAction.java | 4 +- .../modules/AbstractSummaryComposite.java | 4 +- .../modules/AlertSummaryComposite.java | 2 +- .../modules/ApicallSummaryComposite.java | 2 +- .../modules/UserAgentSummaryComposite.java | 2 +- .../src/scouter/client/tags/TagCountView.java | 4 +- .../client/views/AlertDetailListView.java | 2 +- .../client/views/DigitalCountView.java | 72 +-------- .../client/visitor/views/VisitorLoadView.java | 142 ++++++++++++++++ .../visitor/views/VisitorRealtimeView.java | 153 ++++++++++++++++++ .../xlog/actions/OpenXLogLoadTimeAction.java | 2 +- .../client/xlog/dialog/XLogSearchDialog.java | 2 +- .../client/xlog/views/XLogLoadTimeView.java | 2 +- 33 files changed, 491 insertions(+), 108 deletions(-) create mode 100644 scouter.client/src/scouter/client/counter/actions/OpenVisitorLoadAction.java create mode 100644 scouter.client/src/scouter/client/counter/actions/OpenVisitorTotalLoadAction.java create mode 100644 scouter.client/src/scouter/client/visitor/views/VisitorLoadView.java create mode 100644 scouter.client/src/scouter/client/visitor/views/VisitorRealtimeView.java diff --git a/scouter.client/plugin.xml b/scouter.client/plugin.xml index 18181c22a..36cc31a95 100644 --- a/scouter.client/plugin.xml +++ b/scouter.client/plugin.xml @@ -926,6 +926,22 @@ name="RealTimeMultiCount" restorable="true"> + + + + diff --git a/scouter.client/src/scouter/client/actions/OpenObjectDailyListAction.java b/scouter.client/src/scouter/client/actions/OpenObjectDailyListAction.java index 7b1d5f902..a97edd939 100644 --- a/scouter.client/src/scouter/client/actions/OpenObjectDailyListAction.java +++ b/scouter.client/src/scouter/client/actions/OpenObjectDailyListAction.java @@ -30,7 +30,7 @@ import scouter.client.views.ObjectDailyListView; -public class OpenObjectDailyListAction extends Action implements CalendarDialog.ILoadCounterDialog { +public class OpenObjectDailyListAction extends Action implements CalendarDialog.ILoadCalendarDialog { public final static String ID = OpenObjectDailyListAction.class.getName(); private final IWorkbenchWindow window; diff --git a/scouter.client/src/scouter/client/counter/actions/OpenDailyServiceCountAction.java b/scouter.client/src/scouter/client/counter/actions/OpenDailyServiceCountAction.java index 45df49957..0a7e31b92 100644 --- a/scouter.client/src/scouter/client/counter/actions/OpenDailyServiceCountAction.java +++ b/scouter.client/src/scouter/client/counter/actions/OpenDailyServiceCountAction.java @@ -29,7 +29,7 @@ import scouter.client.util.ImageUtil; import scouter.util.DateUtil; -public class OpenDailyServiceCountAction extends Action implements CalendarDialog.ILoadCounterDialog { +public class OpenDailyServiceCountAction extends Action implements CalendarDialog.ILoadCalendarDialog { public final static String ID = OpenDailyServiceCountAction.class.getName(); private final IWorkbenchWindow window; diff --git a/scouter.client/src/scouter/client/counter/actions/OpenPastCountViewAction.java b/scouter.client/src/scouter/client/counter/actions/OpenPastCountViewAction.java index 33becb39d..db61a9f88 100644 --- a/scouter.client/src/scouter/client/counter/actions/OpenPastCountViewAction.java +++ b/scouter.client/src/scouter/client/counter/actions/OpenPastCountViewAction.java @@ -25,12 +25,12 @@ import scouter.client.counter.views.CounterLoadCountView; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.util.ImageUtil; import scouter.lang.counters.CounterConstants; import scouter.util.Hexa32; -public class OpenPastCountViewAction extends Action implements ILoadCounterDialog { +public class OpenPastCountViewAction extends Action implements ILoadCalendarDialog { public final static String ID = OpenPastCountViewAction.class.getName(); private final IWorkbenchWindow win; diff --git a/scouter.client/src/scouter/client/counter/actions/OpenPastDateGroupCountViewAction.java b/scouter.client/src/scouter/client/counter/actions/OpenPastDateGroupCountViewAction.java index d726646a9..ba44ab351 100644 --- a/scouter.client/src/scouter/client/counter/actions/OpenPastDateGroupCountViewAction.java +++ b/scouter.client/src/scouter/client/counter/actions/OpenPastDateGroupCountViewAction.java @@ -29,7 +29,7 @@ import scouter.client.popup.CalendarDialog; import scouter.client.util.ImageUtil; -public class OpenPastDateGroupCountViewAction extends Action implements CalendarDialog.ILoadCounterDialog{ +public class OpenPastDateGroupCountViewAction extends Action implements CalendarDialog.ILoadCalendarDialog{ public final static String ID = OpenPastDateGroupCountViewAction.class.getName(); private final IWorkbenchWindow window; diff --git a/scouter.client/src/scouter/client/counter/actions/OpenPastDateViewAction.java b/scouter.client/src/scouter/client/counter/actions/OpenPastDateViewAction.java index fb06b2854..6d7ad5d22 100644 --- a/scouter.client/src/scouter/client/counter/actions/OpenPastDateViewAction.java +++ b/scouter.client/src/scouter/client/counter/actions/OpenPastDateViewAction.java @@ -25,10 +25,10 @@ import scouter.client.counter.views.CounterLoadDateView; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.util.ImageUtil; -public class OpenPastDateViewAction extends Action implements ILoadCounterDialog { +public class OpenPastDateViewAction extends Action implements ILoadCalendarDialog { public final static String ID = OpenPastDateViewAction.class.getName(); private final IWorkbenchWindow win; diff --git a/scouter.client/src/scouter/client/counter/actions/OpenPastTimeTranXGroupViewAction.java b/scouter.client/src/scouter/client/counter/actions/OpenPastTimeTranXGroupViewAction.java index dfd8c4a6e..d6b6dbfd6 100644 --- a/scouter.client/src/scouter/client/counter/actions/OpenPastTimeTranXGroupViewAction.java +++ b/scouter.client/src/scouter/client/counter/actions/OpenPastTimeTranXGroupViewAction.java @@ -31,7 +31,7 @@ import scouter.client.util.ConsoleProxy; import scouter.client.util.ImageUtil; -public class OpenPastTimeTranXGroupViewAction extends Action implements CalendarDialog.ILoadCounterDialog { +public class OpenPastTimeTranXGroupViewAction extends Action implements CalendarDialog.ILoadCalendarDialog { public final static String ID = OpenPastTimeTranXGroupViewAction.class.getName(); private final IWorkbenchWindow window; diff --git a/scouter.client/src/scouter/client/counter/actions/OpenPastTimeViewAction.java b/scouter.client/src/scouter/client/counter/actions/OpenPastTimeViewAction.java index cf30d3873..69c6fbb88 100644 --- a/scouter.client/src/scouter/client/counter/actions/OpenPastTimeViewAction.java +++ b/scouter.client/src/scouter/client/counter/actions/OpenPastTimeViewAction.java @@ -25,13 +25,13 @@ import scouter.client.counter.views.CounterLoadTimeView; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.util.ImageUtil; import scouter.client.util.TimeUtil; import scouter.client.util.UIUtil; import scouter.util.DateUtil; -public class OpenPastTimeViewAction extends Action implements ILoadCounterDialog { +public class OpenPastTimeViewAction extends Action implements ILoadCalendarDialog { public final static String ID = OpenPastTimeViewAction.class.getName(); private final IWorkbenchWindow win; diff --git a/scouter.client/src/scouter/client/counter/actions/OpenUniqueTotalVisitorAction.java b/scouter.client/src/scouter/client/counter/actions/OpenUniqueTotalVisitorAction.java index c2507d462..f2b4921ce 100644 --- a/scouter.client/src/scouter/client/counter/actions/OpenUniqueTotalVisitorAction.java +++ b/scouter.client/src/scouter/client/counter/actions/OpenUniqueTotalVisitorAction.java @@ -27,6 +27,7 @@ import scouter.client.server.ServerManager; import scouter.client.util.ImageUtil; import scouter.client.views.DigitalCountView; +import scouter.client.visitor.views.VisitorRealtimeView; import scouter.lang.pack.MapPack; import scouter.net.RequestCmd; @@ -48,8 +49,8 @@ public OpenUniqueTotalVisitorAction(IWorkbenchWindow win, int serverId, String o public void run() { if (win != null) { try { - DigitalCountView view = (DigitalCountView) win.getActivePage().showView( - DigitalCountView.ID, serverId + "&" + objType, IWorkbenchPage.VIEW_ACTIVATE); + VisitorRealtimeView view = (VisitorRealtimeView) win.getActivePage().showView( + VisitorRealtimeView.ID, serverId + "&" + objType, IWorkbenchPage.VIEW_ACTIVATE); if (view != null) { MapPack param = new MapPack(); param.put("objType", this.objType); diff --git a/scouter.client/src/scouter/client/counter/actions/OpenUniqueVisitorAction.java b/scouter.client/src/scouter/client/counter/actions/OpenUniqueVisitorAction.java index 8b9b387d0..8585a878e 100644 --- a/scouter.client/src/scouter/client/counter/actions/OpenUniqueVisitorAction.java +++ b/scouter.client/src/scouter/client/counter/actions/OpenUniqueVisitorAction.java @@ -27,6 +27,7 @@ import scouter.client.model.TextProxy; import scouter.client.util.ImageUtil; import scouter.client.views.DigitalCountView; +import scouter.client.visitor.views.VisitorRealtimeView; import scouter.lang.pack.MapPack; import scouter.net.RequestCmd; @@ -48,8 +49,8 @@ public OpenUniqueVisitorAction(IWorkbenchWindow win, int serverId, int objHash) public void run() { if (win != null) { try { - DigitalCountView view = (DigitalCountView) win.getActivePage().showView( - DigitalCountView.ID, serverId + "&" + objHash, IWorkbenchPage.VIEW_ACTIVATE); + VisitorRealtimeView view = (VisitorRealtimeView) win.getActivePage().showView( + VisitorRealtimeView.ID, serverId + "&" + objHash, IWorkbenchPage.VIEW_ACTIVATE); if (view != null) { MapPack param = new MapPack(); param.put("objHash", this.objHash); diff --git a/scouter.client/src/scouter/client/counter/actions/OpenVisitorLoadAction.java b/scouter.client/src/scouter/client/counter/actions/OpenVisitorLoadAction.java new file mode 100644 index 000000000..c0e1602bf --- /dev/null +++ b/scouter.client/src/scouter/client/counter/actions/OpenVisitorLoadAction.java @@ -0,0 +1,67 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package scouter.client.counter.actions; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; + +import scouter.client.Images; +import scouter.client.model.TextProxy; +import scouter.client.util.ImageUtil; +import scouter.client.visitor.views.VisitorLoadView; +import scouter.lang.pack.MapPack; +import scouter.net.RequestCmd; + +public class OpenVisitorLoadAction extends Action { + public final static String ID = OpenVisitorLoadAction.class.getName(); + + private final IWorkbenchWindow win; + private int objHash; + private int serverId; + private String date; + + public OpenVisitorLoadAction(IWorkbenchWindow win, int serverId, String date, int objHash) { + this.win = win; + this.objHash = objHash; + this.serverId = serverId; + this.date = date; + setText("Load"); + setImageDescriptor(ImageUtil.getImageDescriptor(Images.calendar)); + } + + public void run() { + if (win != null) { + try { + VisitorLoadView view = (VisitorLoadView) win.getActivePage().showView( + VisitorLoadView.ID, serverId + "&" + date + "&" + objHash, IWorkbenchPage.VIEW_ACTIVATE); + if (view != null) { + MapPack param = new MapPack(); + param.put("date", date); + param.put("objHash", this.objHash); + String objName = TextProxy.object.getText(objHash); + view.setInput(date + " - " + objName, RequestCmd.VISITOR_LOADDATE, param); + } + } catch (PartInitException e) { + MessageDialog.openError(win.getShell(), "Error", "Error opening view:" + e.getMessage()); + } + } + } +} diff --git a/scouter.client/src/scouter/client/counter/actions/OpenVisitorTotalLoadAction.java b/scouter.client/src/scouter/client/counter/actions/OpenVisitorTotalLoadAction.java new file mode 100644 index 000000000..3b5d6b620 --- /dev/null +++ b/scouter.client/src/scouter/client/counter/actions/OpenVisitorTotalLoadAction.java @@ -0,0 +1,67 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package scouter.client.counter.actions; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; + +import scouter.client.Images; +import scouter.client.server.ServerManager; +import scouter.client.util.ImageUtil; +import scouter.client.visitor.views.VisitorLoadView; +import scouter.lang.pack.MapPack; +import scouter.net.RequestCmd; + +public class OpenVisitorTotalLoadAction extends Action { + public final static String ID = OpenVisitorTotalLoadAction.class.getName(); + + private final IWorkbenchWindow win; + private String objType; + private int serverId; + private String date; + + public OpenVisitorTotalLoadAction(IWorkbenchWindow win, int serverId, String date, String objType) { + this.win = win; + this.objType = objType; + this.serverId = serverId; + this.date = date; + setText("Load"); + setImageDescriptor(ImageUtil.getImageDescriptor(Images.calendar)); + } + + public void run() { + if (win != null) { + try { + VisitorLoadView view = (VisitorLoadView) win.getActivePage().showView( + VisitorLoadView.ID, serverId + "&" + date + "&" + objType, IWorkbenchPage.VIEW_ACTIVATE); + if (view != null) { + MapPack param = new MapPack(); + param.put("date", date); + param.put("objType", this.objType); + String displayObjType = ServerManager.getInstance().getServer(serverId).getCounterEngine().getDisplayNameObjectType(objType); + view.setInput(date + " - " + displayObjType, RequestCmd.VISITOR_LOADDATE_TOTAL, param); + } + } catch (PartInitException e) { + MessageDialog.openError(win.getShell(), "Error", "Error opening view:" + e.getMessage()); + } + } + } +} diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java index 7da868d51..08419de12 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastTimeAllView.java @@ -94,7 +94,7 @@ import scouter.util.StringUtil; import au.com.bytecode.opencsv.CSVWriter; -public class CounterPastTimeAllView extends ScouterViewPart implements CalendarDialog.ILoadCounterDialog { +public class CounterPastTimeAllView extends ScouterViewPart implements CalendarDialog.ILoadCalendarDialog { public static final String ID = CounterPastTimeAllView.class.getName(); private IMemento memento; diff --git a/scouter.client/src/scouter/client/counter/views/CounterPastTimeTotalView.java b/scouter.client/src/scouter/client/counter/views/CounterPastTimeTotalView.java index 6fbf34cd9..94d4f9a8f 100644 --- a/scouter.client/src/scouter/client/counter/views/CounterPastTimeTotalView.java +++ b/scouter.client/src/scouter/client/counter/views/CounterPastTimeTotalView.java @@ -81,7 +81,7 @@ import scouter.util.CastUtil; import scouter.util.DateUtil; -public class CounterPastTimeTotalView extends ScouterViewPart implements CalendarDialog.ILoadCounterDialog { +public class CounterPastTimeTotalView extends ScouterViewPart implements CalendarDialog.ILoadCalendarDialog { public static final String ID = CounterPastTimeTotalView.class.getName(); private IMemento memento; diff --git a/scouter.client/src/scouter/client/group/view/CounterPastTimeGroupAllView.java b/scouter.client/src/scouter/client/group/view/CounterPastTimeGroupAllView.java index 26b233504..2b3b45fb7 100644 --- a/scouter.client/src/scouter/client/group/view/CounterPastTimeGroupAllView.java +++ b/scouter.client/src/scouter/client/group/view/CounterPastTimeGroupAllView.java @@ -99,7 +99,7 @@ import scouter.util.FormatUtil; import scouter.util.StringUtil; -public class CounterPastTimeGroupAllView extends ScouterViewPart implements CalendarDialog.ILoadCounterDialog, IObjectCheckListener { +public class CounterPastTimeGroupAllView extends ScouterViewPart implements CalendarDialog.ILoadCalendarDialog, IObjectCheckListener { public static final String ID = CounterPastTimeGroupAllView.class.getName(); diff --git a/scouter.client/src/scouter/client/group/view/CounterPastTimeGroupTotalView.java b/scouter.client/src/scouter/client/group/view/CounterPastTimeGroupTotalView.java index 91589bb85..4936265f8 100644 --- a/scouter.client/src/scouter/client/group/view/CounterPastTimeGroupTotalView.java +++ b/scouter.client/src/scouter/client/group/view/CounterPastTimeGroupTotalView.java @@ -86,7 +86,7 @@ import scouter.util.DateUtil; import scouter.util.StringUtil; -public class CounterPastTimeGroupTotalView extends ScouterViewPart implements CalendarDialog.ILoadCounterDialog { +public class CounterPastTimeGroupTotalView extends ScouterViewPart implements CalendarDialog.ILoadCalendarDialog { public static final String ID = CounterPastTimeGroupTotalView.class.getName(); diff --git a/scouter.client/src/scouter/client/group/view/XLogLoadTimeGroupView.java b/scouter.client/src/scouter/client/group/view/XLogLoadTimeGroupView.java index bab23d317..7dc72912d 100644 --- a/scouter.client/src/scouter/client/group/view/XLogLoadTimeGroupView.java +++ b/scouter.client/src/scouter/client/group/view/XLogLoadTimeGroupView.java @@ -76,7 +76,7 @@ import scouter.util.DateUtil; -public class XLogLoadTimeGroupView extends XLogViewCommon implements TimeRangeDialog.ITimeRange, CalendarDialog.ILoadCounterDialog { +public class XLogLoadTimeGroupView extends XLogViewCommon implements TimeRangeDialog.ITimeRange, CalendarDialog.ILoadCalendarDialog { public static final String ID = XLogLoadTimeGroupView.class.getName(); diff --git a/scouter.client/src/scouter/client/maria/actions/OpenDbDailyConnView.java b/scouter.client/src/scouter/client/maria/actions/OpenDbDailyConnView.java index 11a7f0457..030dd1567 100644 --- a/scouter.client/src/scouter/client/maria/actions/OpenDbDailyConnView.java +++ b/scouter.client/src/scouter/client/maria/actions/OpenDbDailyConnView.java @@ -9,7 +9,7 @@ import scouter.client.Images; import scouter.client.maria.views.DbDailyTotalConnView; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.util.ConsoleProxy; import scouter.client.util.ImageUtil; import scouter.util.DateUtil; @@ -31,7 +31,7 @@ public OpenDbDailyConnView(int serverId, String date) { public void run() { try { - CalendarDialog dialog = new CalendarDialog(Display.getDefault(), new ILoadCounterDialog() { + CalendarDialog dialog = new CalendarDialog(Display.getDefault(), new ILoadCalendarDialog() { public void onPressedOk(long startTime, long endTime) { } diff --git a/scouter.client/src/scouter/client/popup/CalendarDialog.java b/scouter.client/src/scouter/client/popup/CalendarDialog.java index 16ee0b558..37f0bafe4 100644 --- a/scouter.client/src/scouter/client/popup/CalendarDialog.java +++ b/scouter.client/src/scouter/client/popup/CalendarDialog.java @@ -43,9 +43,9 @@ public class CalendarDialog { private final Display display; - private final ILoadCounterDialog callback; + private final ILoadCalendarDialog callback; - public CalendarDialog(Display display, ILoadCounterDialog callback) { + public CalendarDialog(Display display, ILoadCalendarDialog callback) { this.display = display; this.callback = callback; } @@ -314,7 +314,7 @@ public void handleEvent(Event event) { dialog.open(); } - public interface ILoadCounterDialog { + public interface ILoadCalendarDialog { void onPressedOk(long startTime, long endTime); void onPressedOk(String date); void onPressedCancel(); diff --git a/scouter.client/src/scouter/client/popup/ObjectCounterDialog.java b/scouter.client/src/scouter/client/popup/ObjectCounterDialog.java index 891585498..7709f4b37 100644 --- a/scouter.client/src/scouter/client/popup/ObjectCounterDialog.java +++ b/scouter.client/src/scouter/client/popup/ObjectCounterDialog.java @@ -47,7 +47,7 @@ import scouter.client.Images; import scouter.client.model.AgentDailyListProxy; import scouter.client.model.TextProxy; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.server.ServerManager; import scouter.client.util.ColorUtil; import scouter.client.util.UIUtil; @@ -120,7 +120,7 @@ public void show() { fromCalBtn.setImage(Images.CTXMENU_RDC); fromCalBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - new CalendarDialog(display, new ILoadCounterDialog() { + new CalendarDialog(display, new ILoadCalendarDialog() { public void onPressedOk(String date) { from = date; fromTxt.setText(date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8)); @@ -155,7 +155,7 @@ public void onPressedCancel() {} toCalBtn.setImage(Images.CTXMENU_RDC); toCalBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - new CalendarDialog(display, new ILoadCounterDialog() { + new CalendarDialog(display, new ILoadCalendarDialog() { public void onPressedOk(String date) { to = date; toTxt.setText(date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8)); diff --git a/scouter.client/src/scouter/client/stack/actions/OpenStackDialogAction.java b/scouter.client/src/scouter/client/stack/actions/OpenStackDialogAction.java index bfc1f642d..f6c794d1a 100644 --- a/scouter.client/src/scouter/client/stack/actions/OpenStackDialogAction.java +++ b/scouter.client/src/scouter/client/stack/actions/OpenStackDialogAction.java @@ -5,7 +5,7 @@ import scouter.client.model.TextProxy; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.stack.dialog.StackListDialog; public class OpenStackDialogAction extends Action { @@ -21,7 +21,7 @@ public OpenStackDialogAction(int serverId, int objHash) { } public void run(){ - new CalendarDialog(Display.getDefault(), new ILoadCounterDialog() { + new CalendarDialog(Display.getDefault(), new ILoadCalendarDialog() { public void onPressedOk(String date) { String objName = TextProxy.object.getText(objHash); new StackListDialog(serverId, objName, date).open(); diff --git a/scouter.client/src/scouter/client/summary/modules/AbstractSummaryComposite.java b/scouter.client/src/scouter/client/summary/modules/AbstractSummaryComposite.java index da441983f..bca809ea2 100644 --- a/scouter.client/src/scouter/client/summary/modules/AbstractSummaryComposite.java +++ b/scouter.client/src/scouter/client/summary/modules/AbstractSummaryComposite.java @@ -41,7 +41,7 @@ import scouter.client.model.AgentModelThread; import scouter.client.model.AgentObject; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.server.Server; import scouter.client.server.ServerManager; import scouter.client.sorter.ColumnLabelSorter; @@ -95,7 +95,7 @@ private void initLayout() { dateLbl.setLayoutData(gd); dateLbl.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { - CalendarDialog dialog = new CalendarDialog(parent.getDisplay(), new ILoadCounterDialog(){ + CalendarDialog dialog = new CalendarDialog(parent.getDisplay(), new ILoadCalendarDialog(){ public void onPressedOk(long startTime, long endTime) {} public void onPressedCancel() {} public void onPressedOk(String date) { diff --git a/scouter.client/src/scouter/client/summary/modules/AlertSummaryComposite.java b/scouter.client/src/scouter/client/summary/modules/AlertSummaryComposite.java index d1a943424..5f89cfd29 100644 --- a/scouter.client/src/scouter/client/summary/modules/AlertSummaryComposite.java +++ b/scouter.client/src/scouter/client/summary/modules/AlertSummaryComposite.java @@ -42,7 +42,7 @@ import scouter.client.Images; import scouter.client.net.TcpProxy; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.sorter.ColumnLabelSorter; import scouter.client.util.ExUtil; import scouter.client.util.TimeUtil; diff --git a/scouter.client/src/scouter/client/summary/modules/ApicallSummaryComposite.java b/scouter.client/src/scouter/client/summary/modules/ApicallSummaryComposite.java index 723eaada6..c5130d281 100644 --- a/scouter.client/src/scouter/client/summary/modules/ApicallSummaryComposite.java +++ b/scouter.client/src/scouter/client/summary/modules/ApicallSummaryComposite.java @@ -43,7 +43,7 @@ import scouter.client.model.TextProxy; import scouter.client.net.TcpProxy; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.sorter.ColumnLabelSorter; import scouter.client.util.ExUtil; import scouter.client.util.TimeUtil; diff --git a/scouter.client/src/scouter/client/summary/modules/UserAgentSummaryComposite.java b/scouter.client/src/scouter/client/summary/modules/UserAgentSummaryComposite.java index 79c98dc9d..00c36e1b2 100644 --- a/scouter.client/src/scouter/client/summary/modules/UserAgentSummaryComposite.java +++ b/scouter.client/src/scouter/client/summary/modules/UserAgentSummaryComposite.java @@ -43,7 +43,7 @@ import scouter.client.model.TextProxy; import scouter.client.net.TcpProxy; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.sorter.ColumnLabelSorter; import scouter.client.util.ExUtil; import scouter.client.util.TimeUtil; diff --git a/scouter.client/src/scouter/client/tags/TagCountView.java b/scouter.client/src/scouter/client/tags/TagCountView.java index c96c17b29..9cb1ed430 100644 --- a/scouter.client/src/scouter/client/tags/TagCountView.java +++ b/scouter.client/src/scouter/client/tags/TagCountView.java @@ -85,7 +85,7 @@ import scouter.client.net.INetReader; import scouter.client.net.TcpProxy; import scouter.client.popup.CalendarDialog; -import scouter.client.popup.CalendarDialog.ILoadCounterDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; import scouter.client.util.ChartUtil; import scouter.client.util.ColorUtil; import scouter.client.util.ExUtil; @@ -199,7 +199,7 @@ public void widgetDefaultSelected(SelectionEvent e) { dateLbl.setLayoutData(new RowData(160, SWT.DEFAULT)); dateLbl.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { - CalendarDialog dialog = new CalendarDialog(getViewSite().getShell().getDisplay(), new ILoadCounterDialog(){ + CalendarDialog dialog = new CalendarDialog(getViewSite().getShell().getDisplay(), new ILoadCalendarDialog(){ public void onPressedOk(long startTime, long endTime) {} public void onPressedCancel() {} public void onPressedOk(String date) { diff --git a/scouter.client/src/scouter/client/views/AlertDetailListView.java b/scouter.client/src/scouter/client/views/AlertDetailListView.java index 5f94787d4..4a9486b93 100644 --- a/scouter.client/src/scouter/client/views/AlertDetailListView.java +++ b/scouter.client/src/scouter/client/views/AlertDetailListView.java @@ -77,7 +77,7 @@ import scouter.util.HashUtil; import scouter.util.StringEnumer; -public class AlertDetailListView extends ViewPart implements CalendarDialog.ILoadCounterDialog { +public class AlertDetailListView extends ViewPart implements CalendarDialog.ILoadCalendarDialog { public static final String ID = AlertDetailListView.class.getName(); diff --git a/scouter.client/src/scouter/client/views/DigitalCountView.java b/scouter.client/src/scouter/client/views/DigitalCountView.java index b499100d3..27bcedea9 100644 --- a/scouter.client/src/scouter/client/views/DigitalCountView.java +++ b/scouter.client/src/scouter/client/views/DigitalCountView.java @@ -28,40 +28,18 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.ViewPart; -import scouter.client.model.RefreshThread; -import scouter.client.net.TcpProxy; import scouter.client.util.ColorUtil; -import scouter.client.util.ExUtil; -import scouter.lang.pack.MapPack; -import scouter.lang.value.Value; -import scouter.util.CastUtil; -import scouter.util.FormatUtil; -public class DigitalCountView extends ViewPart implements RefreshThread.Refreshable { +public class DigitalCountView extends ViewPart { public static final String ID = DigitalCountView.class.getName(); - private Canvas canvas; - protected RefreshThread thread; - private String value = "unavailable"; - private int serverId; - - String title = ""; - String requestCmd; - MapPack param; + protected Canvas canvas; + protected String value = "DigitalCount"; + protected String title = ""; - @Override - public void init(IViewSite site) throws PartInitException { - super.init(site); - String secId = site.getSecondaryId(); - String ids[] = secId.split("&"); - serverId = CastUtil.cint(ids[0]); - } - @Override public void createPartControl(Composite parent) { canvas = new Canvas(parent, SWT.DOUBLE_BUFFERED); @@ -89,16 +67,6 @@ public void controlResized(ControlEvent e) { }); } - public void setInput(String title, String requestCmd, MapPack param){ - this.title = title == null ? "" : title; - this.requestCmd = requestCmd; - this.param = param; - if (thread == null) { - thread = new RefreshThread(this, 2000); - thread.start(); - } - } - private void drawText(Rectangle area, GC gc) { try { int fontSize = area.height / 2; @@ -147,39 +115,7 @@ private void drawText(Rectangle area, GC gc) { } - @Override - public void dispose() { - super.dispose(); - if (thread != null && thread.isAlive()) { - thread.shutdown(); - } - } - - @Override public void setFocus() { } - - public void refresh() { - TcpProxy tcp = TcpProxy.getTcpProxy(serverId); - Value v = null; - try { - v = tcp.getSingleValue(requestCmd, param); - } catch(Exception e){ - e.printStackTrace(); - } finally { - TcpProxy.putTcpProxy(tcp); - } - if (v != null) { - value = FormatUtil.print(CastUtil.clong(v), "#,##0"); - } else { - value = "unavailable"; - } - ExUtil.exec(canvas, new Runnable() { - public void run() { - canvas.redraw(); - } - }); - } - } diff --git a/scouter.client/src/scouter/client/visitor/views/VisitorLoadView.java b/scouter.client/src/scouter/client/visitor/views/VisitorLoadView.java new file mode 100644 index 000000000..539bf461b --- /dev/null +++ b/scouter.client/src/scouter/client/visitor/views/VisitorLoadView.java @@ -0,0 +1,142 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package scouter.client.visitor.views; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.PartInitException; + +import scouter.client.Images; +import scouter.client.counter.actions.OpenVisitorLoadAction; +import scouter.client.counter.actions.OpenVisitorTotalLoadAction; +import scouter.client.net.TcpProxy; +import scouter.client.popup.CalendarDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; +import scouter.client.util.ExUtil; +import scouter.client.util.ImageUtil; +import scouter.client.views.DigitalCountView; +import scouter.lang.pack.MapPack; +import scouter.lang.value.Value; +import scouter.util.CastUtil; +import scouter.util.DateUtil; +import scouter.util.FormatUtil; + +public class VisitorLoadView extends DigitalCountView implements ILoadCalendarDialog { + + public static final String ID = VisitorLoadView.class.getName(); + + private int serverId; + + String requestCmd; + MapPack param; + String date; + + @Override + public void init(IViewSite site) throws PartInitException { + super.init(site); + String secId = site.getSecondaryId(); + String ids[] = secId.split("&"); + serverId = CastUtil.cint(ids[0]); + date = ids[1]; + } + + public void createPartControl(Composite parent) { + super.createPartControl(parent); + IToolBarManager man = getViewSite().getActionBars().getToolBarManager(); + man.add(new Action("Load", ImageUtil.getImageDescriptor(Images.calendar)) { + public void run() { + CalendarDialog dialog = new CalendarDialog(getSite().getShell().getDisplay(), VisitorLoadView.this); + dialog.show(-1, -1, DateUtil.getTime(date, "yyyyMMdd")); + } + }); + Menu contextMenu = new Menu(canvas); + MenuItem loadCalendaer = new MenuItem(contextMenu, SWT.PUSH); + loadCalendaer.setText("&Load"); + loadCalendaer.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + CalendarDialog dialog = new CalendarDialog(getSite().getShell().getDisplay(), VisitorLoadView.this); + dialog.show(); + } + }); + canvas.setMenu(contextMenu); + } + + public void setInput(String title, String requestCmd, MapPack param){ + super.title = title == null ? super.title : title; + this.requestCmd = requestCmd; + this.param = param; + load(); + } + + @Override + public void dispose() { + super.dispose(); + } + + + @Override + public void setFocus() { + } + + public void load() { + ExUtil.asyncRun(new Runnable() { + public void run() { + TcpProxy tcp = TcpProxy.getTcpProxy(serverId); + Value v = null; + try { + v = tcp.getSingleValue(requestCmd, param); + } catch(Exception e){ + e.printStackTrace(); + } finally { + TcpProxy.putTcpProxy(tcp); + } + if (v != null) { + value = FormatUtil.print(CastUtil.clong(v), "#,##0"); + } else { + value = "unavailable"; + } + ExUtil.exec(canvas, new Runnable() { + public void run() { + canvas.redraw(); + } + }); + } + }); + } + + public void onPressedOk(String date) { + if (param.getText("objType") == null) { + new OpenVisitorLoadAction(getSite().getWorkbenchWindow(), serverId, date, param.getInt("objHash")).run(); + } else { + new OpenVisitorTotalLoadAction(getSite().getWorkbenchWindow(), serverId, date, param.getText("objType")).run(); + } + } + + public void onPressedOk(long startTime, long endTime) { + } + + public void onPressedCancel() { + } +} diff --git a/scouter.client/src/scouter/client/visitor/views/VisitorRealtimeView.java b/scouter.client/src/scouter/client/visitor/views/VisitorRealtimeView.java new file mode 100644 index 000000000..d852fd0d1 --- /dev/null +++ b/scouter.client/src/scouter/client/visitor/views/VisitorRealtimeView.java @@ -0,0 +1,153 @@ +/* + * Copyright 2015 the original author or authors. + * @https://github.com/scouter-project/scouter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package scouter.client.visitor.views; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.PartInitException; + +import scouter.client.Images; +import scouter.client.counter.actions.OpenVisitorLoadAction; +import scouter.client.counter.actions.OpenVisitorTotalLoadAction; +import scouter.client.model.RefreshThread; +import scouter.client.net.TcpProxy; +import scouter.client.popup.CalendarDialog; +import scouter.client.popup.CalendarDialog.ILoadCalendarDialog; +import scouter.client.util.ExUtil; +import scouter.client.util.ImageUtil; +import scouter.client.views.DigitalCountView; +import scouter.lang.pack.MapPack; +import scouter.lang.value.Value; +import scouter.util.CastUtil; +import scouter.util.FormatUtil; + +public class VisitorRealtimeView extends DigitalCountView implements RefreshThread.Refreshable, ILoadCalendarDialog { + + public static final String ID = VisitorRealtimeView.class.getName(); + + protected RefreshThread thread; + private int serverId; + + String requestCmd; + MapPack param; + + @Override + public void init(IViewSite site) throws PartInitException { + super.init(site); + String secId = site.getSecondaryId(); + String ids[] = secId.split("&"); + serverId = CastUtil.cint(ids[0]); + } + + + + @Override + public void createPartControl(Composite parent) { + super.createPartControl(parent); + IToolBarManager man = getViewSite().getActionBars().getToolBarManager(); + man.add(new Action("Load", ImageUtil.getImageDescriptor(Images.calendar)) { + public void run() { + CalendarDialog dialog = new CalendarDialog(getSite().getShell().getDisplay(), VisitorRealtimeView.this); + dialog.show(); + } + }); + + Menu contextMenu = new Menu(canvas); + MenuItem loadCalendaer = new MenuItem(contextMenu, SWT.PUSH); + loadCalendaer.setText("&Load"); + loadCalendaer.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + CalendarDialog dialog = new CalendarDialog(getSite().getShell().getDisplay(), VisitorRealtimeView.this); + dialog.show(); + } + }); + canvas.setMenu(contextMenu); + } + + + + public void setInput(String title, String requestCmd, MapPack param){ + super.title = title != null ? title : super.title; + this.requestCmd = requestCmd; + this.param = param; + if (thread == null) { + thread = new RefreshThread(this, 2000); + thread.start(); + } + } + + @Override + public void dispose() { + super.dispose(); + if (thread != null && thread.isAlive()) { + thread.shutdown(); + } + } + + + @Override + public void setFocus() { + } + + public void refresh() { + TcpProxy tcp = TcpProxy.getTcpProxy(serverId); + Value v = null; + try { + v = tcp.getSingleValue(requestCmd, param); + } catch(Exception e){ + e.printStackTrace(); + } finally { + TcpProxy.putTcpProxy(tcp); + } + if (v != null) { + value = FormatUtil.print(CastUtil.clong(v), "#,##0"); + } else { + value = "unavailable"; + } + ExUtil.exec(canvas, new Runnable() { + public void run() { + canvas.redraw(); + } + }); + } + + + public void onPressedOk(String date) { + if (param.getText("objType") == null) { + new OpenVisitorLoadAction(getSite().getWorkbenchWindow(), serverId, date, param.getInt("objHash")).run(); + } else { + new OpenVisitorTotalLoadAction(getSite().getWorkbenchWindow(), serverId, date, param.getText("objType")).run(); + } + } + + public void onPressedOk(long startTime, long endTime) { + } + + + public void onPressedCancel() { + + } + +} diff --git a/scouter.client/src/scouter/client/xlog/actions/OpenXLogLoadTimeAction.java b/scouter.client/src/scouter/client/xlog/actions/OpenXLogLoadTimeAction.java index 1da36766c..b14fdc698 100644 --- a/scouter.client/src/scouter/client/xlog/actions/OpenXLogLoadTimeAction.java +++ b/scouter.client/src/scouter/client/xlog/actions/OpenXLogLoadTimeAction.java @@ -30,7 +30,7 @@ import scouter.client.util.ImageUtil; import scouter.client.xlog.views.XLogLoadTimeView; -public class OpenXLogLoadTimeAction extends Action implements CalendarDialog.ILoadCounterDialog { +public class OpenXLogLoadTimeAction extends Action implements CalendarDialog.ILoadCalendarDialog { public final static String ID = OpenXLogLoadTimeAction.class.getName(); private final IWorkbenchWindow window; diff --git a/scouter.client/src/scouter/client/xlog/dialog/XLogSearchDialog.java b/scouter.client/src/scouter/client/xlog/dialog/XLogSearchDialog.java index 8e4b84fe6..96751e268 100644 --- a/scouter.client/src/scouter/client/xlog/dialog/XLogSearchDialog.java +++ b/scouter.client/src/scouter/client/xlog/dialog/XLogSearchDialog.java @@ -70,7 +70,7 @@ import scouter.util.Hexa32; import scouter.util.StringUtil; -public class XLogSearchDialog implements CalendarDialog.ILoadCounterDialog{ +public class XLogSearchDialog implements CalendarDialog.ILoadCalendarDialog{ Shell dialog; IWorkbenchWindow win; diff --git a/scouter.client/src/scouter/client/xlog/views/XLogLoadTimeView.java b/scouter.client/src/scouter/client/xlog/views/XLogLoadTimeView.java index f2583f649..9a1c23698 100644 --- a/scouter.client/src/scouter/client/xlog/views/XLogLoadTimeView.java +++ b/scouter.client/src/scouter/client/xlog/views/XLogLoadTimeView.java @@ -75,7 +75,7 @@ import scouter.util.ThreadUtil; -public class XLogLoadTimeView extends XLogViewCommon implements TimeRangeDialog.ITimeRange, CalendarDialog.ILoadCounterDialog { +public class XLogLoadTimeView extends XLogViewCommon implements TimeRangeDialog.ITimeRange, CalendarDialog.ILoadCalendarDialog { public static final String ID = XLogLoadTimeView.class.getName(); From 39aa23a396d7920c6dbce6d49159eb427efa00c3 Mon Sep 17 00:00:00 2001 From: Gunhee Lee Date: Sat, 12 Dec 2015 09:37:23 +0900 Subject: [PATCH 39/42] add test --- .gitignore | 2 ++ .../test/scouter/util/ParamTextTest.java | 34 +++++++++++++++++++ .../lang/conf/ConfigValueUtilTest.java | 30 ++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 scouter.common/test/scouter/util/ParamTextTest.java create mode 100644 scouter.server/test/scouter/lang/conf/ConfigValueUtilTest.java diff --git a/.gitignore b/.gitignore index 17b901b3e..a447b5d57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ scouter.agent.java/bin/* scouter.client/bin/* scouter.common/bin/* +scouter.common/bin-test/* scouter.server/bin/* +scouter.server/bin-test/* scouter.deploy/out */.cache */.svn diff --git a/scouter.common/test/scouter/util/ParamTextTest.java b/scouter.common/test/scouter/util/ParamTextTest.java new file mode 100644 index 000000000..4f1010bc8 --- /dev/null +++ b/scouter.common/test/scouter/util/ParamTextTest.java @@ -0,0 +1,34 @@ +package scouter.util; + +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by gunlee on 2015. 12. 11.. + */ +public class ParamTextTest { + + @Test + public void testGetText() throws Exception { + + Map args = new HashMap(); + args.putAll(System.getenv()); + args.putAll(System.getProperties()); + + String text = new ParamText(StringUtil.trim("abc${df}df${df}xxx")).getText(args); + System.out.println(text); + + } + + @Test + public void testToString() throws Exception { + + } + + @Test + public void testGetKeyList() throws Exception { + + } +} \ No newline at end of file diff --git a/scouter.server/test/scouter/lang/conf/ConfigValueUtilTest.java b/scouter.server/test/scouter/lang/conf/ConfigValueUtilTest.java new file mode 100644 index 000000000..4d090e3ec --- /dev/null +++ b/scouter.server/test/scouter/lang/conf/ConfigValueUtilTest.java @@ -0,0 +1,30 @@ +package scouter.lang.conf; + +import org.junit.Test; + +/** + * Created by gunlee on 2015. 12. 11.. + */ +public class ConfigValueUtilTest { + + + @Test + public void test1() { + + } + + @Test + public void testReplaceSysProp() throws Exception { + + } + + @Test + public void testGetConfigDefault() throws Exception { + + } + + @Test + public void testToValue() throws Exception { + + } +} From fa0be4dcce4b3ca192bfa589417a258f48a0f907 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Sun, 13 Dec 2015 09:43:37 +0900 Subject: [PATCH 40/42] print configure key --- scouter.agent.host/src/scouter/agent/Configure.java | 9 ++++++++- scouter.agent.java/src/scouter/agent/Configure.java | 9 ++++++++- scouter.server/src/scouter/server/Configure.java | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/scouter.agent.host/src/scouter/agent/Configure.java b/scouter.agent.host/src/scouter/agent/Configure.java index 9c5c3a87a..2bd968181 100644 --- a/scouter.agent.host/src/scouter/agent/Configure.java +++ b/scouter.agent.host/src/scouter/agent/Configure.java @@ -377,6 +377,13 @@ public MapValue getKeyValueInfo() { } public static void main(String[] args) { - System.out.println(Configure.getInstance().getKeyValueInfo().toString().replace(',', '\n')); + StringKeyLinkedMap defMap = ConfigValueUtil.getConfigDefault(new Configure(true)); + StringEnumer enu = defMap.keys(); + while (enu.hasMoreElements()) { + String key = enu.nextString(); + if (ignoreSet.contains(key)) + continue; + System.out.println(key + " : " + ConfigValueUtil.toValue(defMap.get(key))); + } } } \ No newline at end of file diff --git a/scouter.agent.java/src/scouter/agent/Configure.java b/scouter.agent.java/src/scouter/agent/Configure.java index 826a1489f..df3d6768a 100644 --- a/scouter.agent.java/src/scouter/agent/Configure.java +++ b/scouter.agent.java/src/scouter/agent/Configure.java @@ -672,6 +672,13 @@ public int getHookSignature() { return this.hook_signature; } public static void main(String[] args) { - System.out.println(Configure.getInstance().getKeyValueInfo().toString().replace(',', '\n')); + StringKeyLinkedMap defMap = ConfigValueUtil.getConfigDefault(new Configure(true)); + StringEnumer enu = defMap.keys(); + while (enu.hasMoreElements()) { + String key = enu.nextString(); + if (ignoreSet.contains(key)) + continue; + System.out.println(key + " : " + ConfigValueUtil.toValue(defMap.get(key))); + } } } diff --git a/scouter.server/src/scouter/server/Configure.java b/scouter.server/src/scouter/server/Configure.java index 6916deffa..df89959f9 100644 --- a/scouter.server/src/scouter/server/Configure.java +++ b/scouter.server/src/scouter/server/Configure.java @@ -373,7 +373,14 @@ public boolean saveText(String text) { } public static void main(String[] args) { - System.out.println(new File("./scoute.aa").getParentFile().mkdirs()); + StringKeyLinkedMap defMap = ConfigValueUtil.getConfigDefault(new Configure(true)); + StringEnumer enu = defMap.keys(); + while (enu.hasMoreElements()) { + String key = enu.nextString(); + if (ignoreSet.contains(key)) + continue; + System.out.println(key + " : " + ConfigValueUtil.toValue(defMap.get(key))); + } } private static HashSet ignoreSet = new HashSet(); From f6345748eb00b9b8aa115ea49d0ae78848d445c2 Mon Sep 17 00:00:00 2001 From: SkyWorker Date: Sun, 13 Dec 2015 15:37:17 +0900 Subject: [PATCH 41/42] refactoring --- .../src/scouter/agent/JavaAgent.java | 36 ----- .../src/scouter/agent/LazyAgentBoot.java | 147 ------------------ .../netio/request/handle/AgentConfigure.java | 4 +- .../src/scouter/test/ObjectRush.java | 4 +- .../src/scouter/test/Service24H.java | 4 +- .../src/scouter/test/ShardMain.java | 4 +- .../src/scouter/test/TpsRush.java | 4 +- .../src/scouter/util/ClassUtil.java | 29 +++- 8 files changed, 38 insertions(+), 194 deletions(-) delete mode 100644 scouter.agent.java/src/scouter/agent/LazyAgentBoot.java diff --git a/scouter.agent.java/src/scouter/agent/JavaAgent.java b/scouter.agent.java/src/scouter/agent/JavaAgent.java index baec053dc..268ab9f65 100644 --- a/scouter.agent.java/src/scouter/agent/JavaAgent.java +++ b/scouter.agent.java/src/scouter/agent/JavaAgent.java @@ -41,42 +41,6 @@ public static void premain(String options, Instrumentation i) { AsyncRunner.getInstance().add(new AgentBoot()); } - public static void agentmain(String options, Instrumentation i) throws Exception { - if (JavaAgent.instrumentation != null) { - return; - } - setOpt(options); - intro(); - Configure.getInstance(); - JavaAgent.instrumentation = i; - JavaAgent.instrumentation.addTransformer(new AgentTransformer()); - // RequestAgent.getInstance(); - TcpRequestMgr.getInstance(); - AsyncRunner.getInstance().add(new LazyAgentBoot()); - } - - private static void setOpt(String opts) { - try { - opts = StringUtil.trim(opts); - if (StringUtil.isEmpty(opts)) - return; - String[] options = StringUtil.split(opts, ','); - for (int i = 0; i < options.length; i++) { - String[] op = StringUtil.split(options[i], '='); - if (op.length != 2) - continue; - String key = StringUtil.trimToEmpty(op[0]); - String value = StringUtil.trimToEmpty(op[1]); - if (key.length() > 0) { - System.setProperty(key, value); - Logger.println("A117", "add property : " + key + "=" + value); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - private static void intro() { try { System.setProperty("scouter.enabled", "true"); diff --git a/scouter.agent.java/src/scouter/agent/LazyAgentBoot.java b/scouter.agent.java/src/scouter/agent/LazyAgentBoot.java deleted file mode 100644 index 6b8eca0cb..000000000 --- a/scouter.agent.java/src/scouter/agent/LazyAgentBoot.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * @https://github.com/scouter-project/scouter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package scouter.agent; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.lang.instrument.ClassDefinition; -import java.lang.instrument.Instrumentation; -import java.util.ArrayList; -import java.util.List; - -import scouter.agent.asm.JDBCConnectionOpenASM; -import scouter.agent.asm.HttpServiceASM; -import scouter.agent.asm.IASM; -import scouter.agent.asm.JDBCDriverASM; -import scouter.agent.asm.JDBCPreparedStatementASM; -import scouter.agent.asm.JDBCResultSetASM; -import scouter.agent.asm.JDBCStatementASM; -import scouter.agent.asm.JspServletASM; -import scouter.agent.asm.SocketASM; -import scouter.agent.counter.CounterExecutingManager; -import scouter.agent.netio.data.net.TcpRequestMgr; -import scouter.agent.netio.request.ReqestHandlingProxy; -import scouter.util.FileUtil; - - -public class LazyAgentBoot implements Runnable { - public void run() { - boot(); - } - - private static boolean booted = false; - - private static List classes = new ArrayList(); - static { - classes.add( new HttpServiceASM()); - classes.add( new JDBCPreparedStatementASM()); - classes.add( new JDBCResultSetASM()); - classes.add( new JDBCStatementASM()); - classes.add(new JDBCConnectionOpenASM()); - classes.add(new JspServletASM()); - classes.add(new JDBCDriverASM()); - classes.add(new SocketASM()); - } - - public synchronized static void boot() { - if (booted) - return; - booted = true; - - - /*Attach로 한 경우에만 사용 - * JDBC설치 모드는 REDEFINED모드로 설정한다. 중첩 PSTMT에 대해서 SQL이 다르게 수집되는 현상이 발생할 수있다. - */ - Configure.JDBC_REDEFINED=true; - - CounterExecutingManager.load(); - ReqestHandlingProxy.load(); - - Configure.getInstance().printConfig(); - TcpRequestMgr.getInstance(); - - try { - Instrumentation instr =JavaAgent.getInstrumentation(); - if(instr==null) - return; - - List clsList = new ArrayList(); - List bytList = new ArrayList(); - - Class[] loadedClass = instr.getAllLoadedClasses(); - for (int i = 0; i < loadedClass.length; i++) { - String name = loadedClass[i].getName().replace('.', '/'); - for(IASM asm : classes){ - if(asm.isTarget(name)){ - Class cls = loadedClass[i]; - byte[] buff = getByteCode(cls); - clsList.add(cls); - bytList.add(buff); - if(clsList.size() >10){ - redefine(clsList, bytList); - } - break; - } - } - } - if (clsList.size() >= 0){ - redefine(clsList, bytList); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - - - private static void redefine(List clsList, List bytList) throws Exception { - ClassDefinition[] cd = new ClassDefinition[clsList.size()]; - for (int i = 0; i < clsList.size(); i++) { - cd[i] = new ClassDefinition(clsList.get(i), bytList.get(i)); - } - JavaAgent.getInstrumentation().redefineClasses(cd); - clsList.clear(); - bytList.clear(); - } - - - - public static byte[] getByteCode(Class c) { - - String clsAsResource = "/" + c.getName().replace('.', '/').concat(".class"); - InputStream in = null; - try { - in = c.getResourceAsStream(clsAsResource); - if (in == null) { - return null; - } - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - byte[] buff = new byte[1024]; - int n = 0; - while ((n = in.read(buff, 0, 1024)) >= 0) { - out.write(buff, 0, n); - } - return out.toByteArray(); - } catch (Exception e) { - } finally { - FileUtil.close(in); - } - return null; - } -} \ No newline at end of file diff --git a/scouter.agent.java/src/scouter/agent/netio/request/handle/AgentConfigure.java b/scouter.agent.java/src/scouter/agent/netio/request/handle/AgentConfigure.java index e52342a6e..ef9e8e195 100644 --- a/scouter.agent.java/src/scouter/agent/netio/request/handle/AgentConfigure.java +++ b/scouter.agent.java/src/scouter/agent/netio/request/handle/AgentConfigure.java @@ -23,7 +23,6 @@ import scouter.agent.Configure; import scouter.agent.JavaAgent; -import scouter.agent.LazyAgentBoot; import scouter.agent.netio.request.anotation.RequestHandler; import scouter.lang.pack.MapPack; import scouter.lang.pack.Pack; @@ -31,6 +30,7 @@ import scouter.lang.value.ListValue; import scouter.lang.value.MapValue; import scouter.net.RequestCmd; +import scouter.util.ClassUtil; public class AgentConfigure { @@ -89,7 +89,7 @@ public Pack redefineClasses(Pack param) { for (int i = 0; paramSet.size() > 0 && i < classes.length; i++) { if (paramSet.contains(classes[i].getName())) { try { - byte[] buff = LazyAgentBoot.getByteCode(classes[i]); + byte[] buff = ClassUtil.getByteCode(classes[i]); if (buff == null) { continue; } diff --git a/scouter.agent.java/src/scouter/test/ObjectRush.java b/scouter.agent.java/src/scouter/test/ObjectRush.java index 11573297d..e3217e3f2 100644 --- a/scouter.agent.java/src/scouter/test/ObjectRush.java +++ b/scouter.agent.java/src/scouter/test/ObjectRush.java @@ -19,7 +19,7 @@ import java.util.ArrayList; -import scouter.agent.LazyAgentBoot; +import scouter.agent.AgentBoot; import scouter.agent.Logger; import scouter.agent.counter.CounterBasket; import scouter.agent.counter.task.AgentHeartBeat; @@ -44,7 +44,7 @@ public static void main(String[] args) { System.setProperty("server.addr", server); System.setProperty("server.port", port); - LazyAgentBoot.boot(); + AgentBoot.boot(); ArrayList objNames = new ArrayList(); diff --git a/scouter.agent.java/src/scouter/test/Service24H.java b/scouter.agent.java/src/scouter/test/Service24H.java index a2160c887..d5ca84d8b 100644 --- a/scouter.agent.java/src/scouter/test/Service24H.java +++ b/scouter.agent.java/src/scouter/test/Service24H.java @@ -21,8 +21,8 @@ import java.util.Stack; import scouter.AnyTrace; +import scouter.agent.AgentBoot; import scouter.agent.Configure; -import scouter.agent.LazyAgentBoot; import scouter.agent.netio.data.net.TcpRequestMgr; import scouter.agent.trace.TraceContext; import scouter.agent.trace.TraceContextManager; @@ -58,7 +58,7 @@ public static void main(String[] args) { System.out.println(" server = " + server + ":" +port); System.out.println(" tcp = " + tps); - LazyAgentBoot.boot(); + AgentBoot.boot(); TcpRequestMgr.getInstance(); double interval = 1000.0/tps; diff --git a/scouter.agent.java/src/scouter/test/ShardMain.java b/scouter.agent.java/src/scouter/test/ShardMain.java index facf56a45..99eda2acc 100644 --- a/scouter.agent.java/src/scouter/test/ShardMain.java +++ b/scouter.agent.java/src/scouter/test/ShardMain.java @@ -19,8 +19,8 @@ import java.util.Random; +import scouter.agent.AgentBoot; import scouter.agent.Configure; -import scouter.agent.LazyAgentBoot; import scouter.agent.netio.data.net.TcpRequestMgr; import scouter.agent.trace.TraceMain; import scouter.util.CastUtil; @@ -46,7 +46,7 @@ public static void main(String[] args) { System.out.println(" server = " + server + ":" + port); System.out.println(" tcp = " + tps); - LazyAgentBoot.boot(); + AgentBoot.boot(); // RequestAgent.getInstance(); TcpRequestMgr.getInstance(); diff --git a/scouter.agent.java/src/scouter/test/TpsRush.java b/scouter.agent.java/src/scouter/test/TpsRush.java index 413cadc20..c0c6a0854 100644 --- a/scouter.agent.java/src/scouter/test/TpsRush.java +++ b/scouter.agent.java/src/scouter/test/TpsRush.java @@ -20,8 +20,8 @@ import java.util.Random; import scouter.AnyTrace; +import scouter.agent.AgentBoot; import scouter.agent.Configure; -import scouter.agent.LazyAgentBoot; import scouter.agent.netio.data.net.TcpRequestMgr; import scouter.agent.trace.TraceContext; import scouter.agent.trace.TraceContextManager; @@ -57,7 +57,7 @@ public static void main(String[] args) { System.out.println(" server = " + server + ":" +port); System.out.println(" tcp = " + tps); - LazyAgentBoot.boot(); + AgentBoot.boot(); //RequestAgent.getInstance(); TcpRequestMgr.getInstance(); diff --git a/scouter.common/src/scouter/util/ClassUtil.java b/scouter.common/src/scouter/util/ClassUtil.java index fdf5206ab..88fcfefa2 100644 --- a/scouter.common/src/scouter/util/ClassUtil.java +++ b/scouter.common/src/scouter/util/ClassUtil.java @@ -16,6 +16,8 @@ */ package scouter.util; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -132,7 +134,7 @@ public static String getClassDescription(Class c1) { sb.append(f[i].getName()).append(";\n"); } Method[] m = c1.getDeclaredMethods(); - if(f.length>0 && m.length >0){ + if (f.length > 0 && m.length > 0) { sb.append("\n"); } for (int i = 0; i < m.length; i++) { @@ -186,6 +188,31 @@ private static void mod(StringBuffer sb, int acc, boolean isInterface) { } } + public static byte[] getByteCode(Class c) { + if (c == null) + return null; + String clsAsResource = "/" + c.getName().replace('.', '/').concat(".class"); + InputStream in = null; + try { + in = c.getResourceAsStream(clsAsResource); + if (in == null) { + return null; + } + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + byte[] buff = new byte[1024]; + int n = 0; + while ((n = in.read(buff, 0, 1024)) >= 0) { + out.write(buff, 0, n); + } + return out.toByteArray(); + } catch (Exception e) { + } finally { + FileUtil.close(in); + } + return null; + } + public static void main(String[] args) { System.out.println(getClassDescription(XLogPack.class)); } From 25f68798e7dbe84d8d78ee85057df0dda9533fa6 Mon Sep 17 00:00:00 2001 From: KimEunsu Date: Sun, 13 Dec 2015 16:08:10 +0900 Subject: [PATCH 42/42] version up --- scouter.deploy/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scouter.deploy/build.xml b/scouter.deploy/build.xml index a4a1cb582..656ee4c92 100644 --- a/scouter.deploy/build.xml +++ b/scouter.deploy/build.xml @@ -4,7 +4,7 @@ - +