(1000, 302) {
44 | protected Slot create() {
45 | return new Slot();
46 | };
47 |
48 | protected void clear(Slot s) {
49 | s.netTx = 0;
50 | s.netRx = 0;
51 | s.diskRead = 0;
52 | s.diskWrite = 0;
53 | s.count = 0;
54 | }
55 | };
56 |
57 | public HostAgentStat(int objHash) {
58 | this.objHash = objHash;
59 | this.startTime = System.currentTimeMillis() / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
60 | }
61 |
62 | /**
63 | *
64 | * 10분 동안 사용되지 않으면 메모리에서 제거대상이 된다.
65 | *
66 | *
67 | * @return
68 | */
69 | public boolean isPurge() {
70 | return (System.currentTimeMillis() - lastAccessTime) > (10 * 60 * 1000);
71 | }
72 |
73 | public void clear() {
74 | isProcessing = true;
75 |
76 | try {
77 | Slot s = meter.getCurrentBucket();
78 | lastSlot.netTx = s.netTx;
79 | lastSlot.netRx = s.netRx;
80 | lastSlot.diskRead = s.diskRead;
81 | lastSlot.diskWrite = s.diskWrite;
82 | lastSlot.count = s.count;
83 |
84 | this.maxCpu = 0F;
85 | this.memTotal = 0;
86 | this.maxMem = 0F;
87 | this.maxMemUsed = 0;
88 | this.maxNetTx = 0;
89 | this.maxNetRx = 0;
90 | this.maxDiskRead = 0;
91 | this.maxDiskWrite = 0;
92 |
93 | // 현재 시간의 (0, 5, 10, 15, ... 50, 55분 단위로 변경)
94 | this.startTime = System.currentTimeMillis() / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
95 | } finally {
96 | isProcessing = false;
97 | }
98 | }
99 |
100 | public synchronized void addMax(float cpu, int memTotal, float mem, int memUsed, int netTx, int netRx, int diskRead, int diskWrite) {
101 | while (true) {
102 | if (isProcessing) {
103 | ThreadUtil.sleep(10);
104 | } else {
105 | break;
106 | }
107 | }
108 |
109 | // 현재 초(second)에 해당하는 슬롯에 데이터 저장
110 | Slot s = meter.getCurrentBucket();
111 | s.netTx += netTx;
112 | s.netRx += netRx;
113 | s.diskRead += diskRead;
114 | s.diskWrite += diskWrite;
115 | s.count++;
116 |
117 | this.memTotal = memTotal;
118 |
119 | // 5분 내 최대 값 갱신
120 | if (cpu > maxCpu) {
121 | maxCpu = cpu;
122 | }
123 | if (mem > maxMem) {
124 | maxMem = mem;
125 | }
126 | if (memUsed > maxMemUsed) {
127 | maxMemUsed = memUsed;
128 | }
129 | if (netTx > maxNetTx) {
130 | maxNetTx = netTx;
131 | }
132 | if (netRx > maxNetRx) {
133 | maxNetRx = netRx;
134 | }
135 | if (diskRead > maxDiskRead) {
136 | maxDiskRead = diskRead;
137 | }
138 | if (diskWrite > maxDiskWrite) {
139 | maxDiskWrite = diskWrite;
140 | }
141 |
142 | this.lastAccessTime = System.currentTimeMillis();
143 | }
144 |
145 | public synchronized void addAvg(float cpu, float mem, int memUsed) {
146 | this.avgCpu = cpu;
147 | this.avgMem = mem;
148 | this.avgMemUsed = memUsed;
149 |
150 | this.lastAccessTime = System.currentTimeMillis();
151 | }
152 |
153 | public HostAgent getHostAgent() {
154 | return getHostAgent(false);
155 | }
156 |
157 | private HostAgent getHostAgent(boolean isClear) {
158 | isProcessing = true;
159 |
160 | try {
161 | HostAgent agent = new HostAgent();
162 | agent.setDate(this.startTime);
163 | agent.setObject_hash(this.objHash);
164 | agent.setLog_dt(new java.sql.Date(this.startTime));
165 | agent.setLog_tm(new Time(this.startTime));
166 | agent.setCpu_avg(this.avgCpu);
167 | agent.setCpu_max(this.maxCpu);
168 | agent.setMem_total(this.memTotal);
169 | agent.setMem_avg(this.avgMem);
170 | agent.setMem_max(this.maxMem);
171 | agent.setMem_u_avg(this.avgMemUsed);
172 | agent.setMem_u_max(this.maxMemUsed);
173 | agent.setNet_tx_avg(getNetTxAvg(isClear));
174 | agent.setNet_tx_max(this.maxNetTx);
175 | agent.setNet_rx_avg(getNetRxAvg(isClear));
176 | agent.setNet_rx_max(this.maxNetRx);
177 | agent.setDisk_r_avg(getDiskReadAvg(isClear));
178 | agent.setDisk_r_max(this.maxDiskRead);
179 | agent.setDisk_w_avg(getDiskWriteAvg(isClear));
180 | agent.setDisk_w_max(this.maxDiskWrite);
181 |
182 | // host agent가 동작하지 않는 경우
183 | if (this.memTotal == 0) {
184 | return null;
185 | }
186 |
187 | return agent;
188 | } finally {
189 | isProcessing = false;
190 | }
191 | }
192 |
193 | public HostAgent getHostAgentAndClear() {
194 | HostAgent agent = getHostAgent();
195 | clear();
196 |
197 | return agent;
198 | }
199 |
200 | private int getNetTxAvg(boolean isClear) {
201 | final LONG sum = new LONG();
202 | final INT cnt = new INT();
203 |
204 | int period = isClear ? 301 : 300;
205 |
206 | meter.search(period, new Handler() {
207 | public void process(Slot s) {
208 | sum.value += s.netTx;
209 | cnt.value += s.count;
210 | }
211 | });
212 |
213 | if (isClear) {
214 | sum.value -= lastSlot.netTx;
215 | cnt.value -= lastSlot.count;
216 | }
217 |
218 | return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
219 | }
220 |
221 | private int getNetRxAvg(boolean isClear) {
222 | final LONG sum = new LONG();
223 | final INT cnt = new INT();
224 |
225 | int period = isClear ? 301 : 300;
226 |
227 | meter.search(period, new Handler() {
228 | public void process(Slot s) {
229 | sum.value += s.netRx;
230 | cnt.value += s.count;
231 | }
232 | });
233 |
234 | if (isClear) {
235 | sum.value -= lastSlot.netRx;
236 | cnt.value -= lastSlot.count;
237 | }
238 |
239 | return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
240 | }
241 |
242 | private int getDiskReadAvg(boolean isClear) {
243 | final LONG sum = new LONG();
244 | final INT cnt = new INT();
245 |
246 | int period = isClear ? 301 : 300;
247 |
248 | meter.search(period, new Handler() {
249 | public void process(Slot s) {
250 | sum.value += s.diskRead;
251 | cnt.value += s.count;
252 | }
253 | });
254 |
255 | if (isClear) {
256 | sum.value -= lastSlot.diskRead;
257 | cnt.value -= lastSlot.count;
258 | }
259 |
260 | return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
261 | }
262 |
263 | private int getDiskWriteAvg(boolean isClear) {
264 | final LONG sum = new LONG();
265 | final INT cnt = new INT();
266 |
267 | int period = isClear ? 301 : 300;
268 |
269 | meter.search(period, new Handler() {
270 | public void process(Slot s) {
271 | sum.value += s.diskWrite;
272 | cnt.value += s.count;
273 | }
274 | });
275 |
276 | if (isClear) {
277 | sum.value -= lastSlot.diskWrite;
278 | cnt.value -= lastSlot.count;
279 | }
280 |
281 | return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
282 | }
283 |
284 | public static void main(String[] args) {
285 | final HostAgentStat has = new HostAgentStat(12345);
286 |
287 | final long until = System.currentTimeMillis() + (60 * 60 * 1000);
288 |
289 | new Thread() {
290 | public void run() {
291 | while (System.currentTimeMillis() < until) {
292 | has.addMax(90.7f, 16 * 1024 * 1024, 52.5f, 7 * 1024 * 1024, 10, 20, 30, 40);
293 | has.addAvg(90.7f, 52.5f, 7 * 1024 * 1024);
294 | ThreadUtil.sleep(1000);
295 | }
296 | };
297 | }.start();
298 |
299 | long time = System.currentTimeMillis();
300 | long last_sent = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
301 |
302 | while (System.currentTimeMillis() < until) {
303 | time = System.currentTimeMillis();
304 | long now = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
305 |
306 | if (now != last_sent) {
307 | last_sent = now;
308 |
309 | time = (time - 10000) / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
310 |
311 | System.err.println(new Date(time) + ":" + has.getHostAgentAndClear());
312 | }
313 |
314 | ThreadUtil.sleep(1000);
315 | }
316 | }
317 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/collector/JavaAgentStat.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.collector;
2 |
3 | import java.sql.Time;
4 | import java.util.Date;
5 |
6 | import scouter.plugin.server.reporting.vo.JavaAgent;
7 | import scouter.util.DateUtil;
8 | import scouter.util.ThreadUtil;
9 |
10 | public class JavaAgentStat {
11 |
12 | private int objHash;
13 | private int avgActiveService;
14 | private int maxActiveService;
15 | private float heapTotal;
16 | private float avgHeapUsed;
17 | private float maxHeapUsed;
18 | private int avgRecentUser;
19 | private int maxRecentUser;
20 | private int avgServiceCount;
21 | private int maxServiceCount;
22 | private float avgApiTps;
23 | private float maxApiTps;
24 | private float avgSqlTps;
25 | private float maxSqlTps;
26 | private float avgTps;
27 | private float maxTps;
28 | private long startTime;
29 | private long lastAccessTime;
30 |
31 | private boolean isProcessing = false;
32 |
33 | public JavaAgentStat(int objHash) {
34 | this.objHash = objHash;
35 | this.startTime = System.currentTimeMillis() / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
36 | }
37 |
38 | /**
39 | *
40 | * 10분 동안 사용되지 않으면 메모리에서 제거대상이 된다.
41 | *
42 | *
43 | * @return
44 | */
45 | public boolean isPurge() {
46 | return (System.currentTimeMillis() - lastAccessTime) > (10 * 60 * 1000);
47 | }
48 |
49 | public void clear() {
50 | isProcessing = true;
51 |
52 | try {
53 | this.maxActiveService = 0;
54 | this.heapTotal = 0F;
55 | this.maxHeapUsed = 0F;
56 | this.maxRecentUser = 0;
57 | this.maxServiceCount = 0;
58 | this.maxSqlTps = 0F;
59 | this.maxTps = 0F;
60 |
61 | // 현재 시간의 (0, 5, 10, 15, ... 50, 55분 단위로 변경)
62 | this.startTime = System.currentTimeMillis() / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
63 | } finally {
64 | isProcessing = false;
65 | }
66 | }
67 |
68 | public synchronized void addMax(int activeService, float heapTotal, float heapUsed, int recentUser, int serviceCount, float apiTps, float sqlTps, float tps) {
69 | while (true) {
70 | if (isProcessing) {
71 | ThreadUtil.sleep(10);
72 | } else {
73 | break;
74 | }
75 | }
76 |
77 | if (heapTotal > 0f && this.heapTotal < heapTotal) {
78 | this.heapTotal = heapTotal;
79 | }
80 |
81 | // 5분 내 최대 값 갱신
82 | if (activeService > maxActiveService) {
83 | maxActiveService = activeService;
84 | }
85 | if (heapUsed > maxHeapUsed) {
86 | maxHeapUsed = heapUsed;
87 | }
88 | if (recentUser > maxRecentUser) {
89 | maxRecentUser = recentUser;
90 | }
91 | if (serviceCount > maxServiceCount) {
92 | maxServiceCount = serviceCount;
93 | }
94 | if (apiTps > maxApiTps) {
95 | maxApiTps = apiTps;
96 | }
97 | if (sqlTps > maxSqlTps) {
98 | maxSqlTps = sqlTps;
99 | }
100 | if (tps > maxTps) {
101 | maxTps = tps;
102 | }
103 |
104 | this.lastAccessTime = System.currentTimeMillis();
105 | }
106 |
107 | public synchronized void addAvg(int activeService, float heapUsed, int recentUser, int serviceCount, float apiTps, float sqlTps, float tps) {
108 | this.avgActiveService = activeService;
109 | this.avgHeapUsed = heapUsed;
110 | this.avgRecentUser = recentUser;
111 | this.avgServiceCount = serviceCount;
112 | this.avgApiTps = apiTps;
113 | this.avgSqlTps = sqlTps;
114 | this.avgTps = tps;
115 |
116 | this.lastAccessTime = System.currentTimeMillis();
117 | }
118 |
119 | public JavaAgent getJavaAgent() {
120 | isProcessing = true;
121 |
122 | try {
123 | JavaAgent agent = new JavaAgent();
124 | agent.setDate(this.startTime);
125 | agent.setObject_hash(this.objHash);
126 | agent.setLog_dt(new java.sql.Date(this.startTime));
127 | agent.setLog_tm(new Time(this.startTime));
128 | agent.setActive_service_avg(this.avgActiveService);
129 | agent.setActive_service_max(this.maxActiveService);
130 | agent.setHeap_total(this.heapTotal);
131 | agent.setHeap_used_avg(this.avgHeapUsed);
132 | agent.setHeap_used_max(this.maxHeapUsed);
133 | agent.setRecent_user_avg(this.avgRecentUser);
134 | agent.setRecent_user_max(this.maxRecentUser);
135 | agent.setService_count_avg(this.avgServiceCount);
136 | agent.setService_count_max(this.maxServiceCount);
137 | agent.setApi_tps_avg(this.avgApiTps);
138 | agent.setApi_tps_max(this.maxApiTps);
139 | agent.setSql_tps_avg(this.avgSqlTps);
140 | agent.setSql_tps_max(this.maxSqlTps);
141 | agent.setTps_avg(this.avgTps);
142 | agent.setTps_max(this.maxTps);
143 |
144 | // java agent가 동작하지 않는 경우
145 | if (this.heapTotal == 0f) {
146 | return null;
147 | }
148 |
149 | return agent;
150 | } finally {
151 | isProcessing = false;
152 | }
153 | }
154 |
155 | public JavaAgent getJavaAgentAndClear() {
156 | JavaAgent agent = getJavaAgent();
157 | clear();
158 |
159 | return agent;
160 | }
161 |
162 | public static void main(String[] args) {
163 | final JavaAgentStat jas = new JavaAgentStat(12345);
164 |
165 | final long until = System.currentTimeMillis() + (60 * 60 * 1000);
166 |
167 | new Thread() {
168 | public void run() {
169 | while (System.currentTimeMillis() < until) {
170 | jas.addMax(5, 1024f, 80.5f, 10, 9, 8, 7, 6);
171 | jas.addAvg(5, 80.5f, 10, 9, 8, 7, 6);
172 | ThreadUtil.sleep(1000);
173 | }
174 | };
175 | }.start();
176 |
177 | long time = System.currentTimeMillis();
178 | long last_sent = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
179 |
180 | while (System.currentTimeMillis() < until) {
181 | time = System.currentTimeMillis();
182 | long now = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
183 |
184 | if (now != last_sent) {
185 | last_sent = now;
186 |
187 | time = (time - 10000) / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
188 |
189 | System.err.println(new Date(time) + ":" + jas.getJavaAgentAndClear());
190 | }
191 |
192 | ThreadUtil.sleep(1000);
193 | }
194 | }
195 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/collector/ServiceStat.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.collector;
2 |
3 | import java.io.OutputStream;
4 | import java.io.PrintWriter;
5 | import java.net.InetAddress;
6 | import java.sql.DatabaseMetaData;
7 | import java.sql.ResultSet;
8 | import java.sql.Time;
9 | import java.util.ArrayList;
10 | import java.util.Collections;
11 | import java.util.Comparator;
12 | import java.util.Date;
13 | import java.util.HashMap;
14 | import java.util.LinkedHashMap;
15 | import java.util.LinkedList;
16 | import java.util.List;
17 | import java.util.Map;
18 | import java.util.Random;
19 |
20 | import org.apache.derby.drda.NetworkServerControl;
21 | import org.apache.derby.tools.ij;
22 | import org.apache.ibatis.session.SqlSession;
23 | import org.apache.ibatis.session.SqlSessionFactory;
24 | import org.apache.ibatis.session.SqlSessionFactoryBuilder;
25 |
26 | import scouter.lang.TextTypes;
27 | import scouter.lang.ref.INT;
28 | import scouter.lang.ref.LONG;
29 | import scouter.plugin.server.reporting.ReportingPlugin;
30 | import scouter.plugin.server.reporting.vo.AgentInfo;
31 | import scouter.plugin.server.reporting.vo.IpAddress;
32 | import scouter.plugin.server.reporting.vo.Service;
33 | import scouter.plugin.server.reporting.vo.UserAgent;
34 | import scouter.server.Logger;
35 | import scouter.server.db.TextRD;
36 | import scouter.util.DateUtil;
37 | import scouter.util.MeteringUtil;
38 | import scouter.util.MeteringUtil.Handler;
39 | import scouter.util.ThreadUtil;
40 |
41 | public class ServiceStat {
42 |
43 | public static final String REQUEST_CNT = "request_count";
44 | public static final String ERROR_CNT = "error_count";
45 |
46 | final static class Slot {
47 | int requestCount;
48 | int errorCount;
49 | long elapsed;
50 | long sqlCount;
51 | long sqlTime;
52 | }
53 |
54 | private int objHash;
55 | private int serviceHash;
56 | private String serviceName;
57 | private int maxElapsed;
58 | private int maxSqlCount;
59 | private int maxSqlTime;
60 | private int elapsedExceedCount;
61 | private int requestCount;
62 | private int errorCount;
63 | private Map> ipAddr = new HashMap>();
64 | private Map> userAgent = new HashMap>();
65 | private long startTime;
66 | private long lastAccessTime;
67 |
68 | private boolean isProcessing = false;
69 | private Slot lastSlot = new Slot();
70 |
71 | // 5분 슬롯 초기화
72 | private MeteringUtil meter = new MeteringUtil(1000, 302) {
73 | protected Slot create() {
74 | return new Slot();
75 | };
76 |
77 | protected void clear(Slot s) {
78 | s.requestCount = 0;
79 | s.errorCount = 0;
80 | s.elapsed = 0L;
81 | s.sqlCount = 0L;
82 | s.sqlTime = 0L;
83 | }
84 | };
85 |
86 | public ServiceStat(int objHash, int serviceHash) {
87 | this.objHash = objHash;
88 | this.serviceHash = serviceHash;
89 | this.startTime = System.currentTimeMillis() / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
90 | }
91 |
92 | /**
93 | *
94 | * 10분 동안 사용되지 않으면 메모리에서 제거대상이 된다.
95 | *
96 | *
97 | * @return
98 | */
99 | public boolean isPurge() {
100 | return (System.currentTimeMillis() - lastAccessTime) > (10 * 60 * 1000);
101 | }
102 |
103 | public void clear() {
104 | isProcessing = true;
105 |
106 | try {
107 | Slot s = meter.getCurrentBucket();
108 | lastSlot.requestCount = s.requestCount;
109 | lastSlot.errorCount = s.errorCount;
110 | lastSlot.elapsed = s.elapsed;
111 | lastSlot.sqlCount = s.sqlCount;
112 | lastSlot.sqlTime = s.sqlTime;
113 |
114 | this.maxElapsed = 0;
115 | this.maxSqlCount = 0;
116 | this.maxSqlTime = 0;
117 | this.elapsedExceedCount = 0;
118 | this.requestCount = 0;
119 | this.errorCount = 0;
120 | this.ipAddr = new HashMap>();
121 | this.userAgent = new HashMap>();
122 |
123 | // 현재 시간의 (0, 5, 10, 15, ... 50, 55분 단위로 변경)
124 | this.startTime = System.currentTimeMillis() / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
125 | } finally {
126 | isProcessing = false;
127 | }
128 | }
129 |
130 | public synchronized void add(String serviceName, int elapsed, boolean error, String ipAddress, int agentHash, int sqlCount, int sqlTime) {
131 | while (true) {
132 | if (isProcessing) {
133 | ThreadUtil.sleep(10);
134 | } else {
135 | break;
136 | }
137 | }
138 |
139 | if (serviceName != null) {
140 | this.serviceName = serviceName;
141 | }
142 |
143 | // 현재 초(second)에 해당하는 슬롯에 데이터 저장
144 | Slot s = meter.getCurrentBucket();
145 | s.elapsed += elapsed;
146 | s.sqlCount += sqlCount;
147 | s.sqlTime += sqlTime;
148 |
149 | // 요청 카운트 증가
150 | s.requestCount++;
151 | this.requestCount++;
152 |
153 | //System.out.println(serviceName + " [" + meter.getPosition() + ":" + s.requestCount + "] " + getRequestCount(true) + " : " + getRequestCount(false) + " : " + this.requestCount);
154 |
155 | // 에러 카운트 증가
156 | if (error) {
157 | s.errorCount++;
158 | this.errorCount = this.errorCount + 1;
159 | }
160 |
161 | // 5분 내 최대 값 갱신
162 | if (elapsed > maxElapsed) {
163 | maxElapsed = elapsed;
164 | }
165 | if (sqlCount > maxSqlCount) {
166 | maxSqlCount = sqlCount;
167 | }
168 | if (sqlTime > maxSqlTime) {
169 | maxSqlTime = sqlTime;
170 | }
171 |
172 | // 허용 시간 초과 카운트 증가
173 | if (elapsed >= ReportingPlugin.conf.getInt("ext_plugin_reporting_max_elapsed_time", 5000)) {
174 | this.elapsedExceedCount++;
175 | }
176 |
177 | // Remote IP Address 정보 추가
178 | putIpAddr(ipAddress, error);
179 |
180 | // UserAgent 정보 추가
181 | putUserAgent(agentHash, error);
182 |
183 | this.lastAccessTime = System.currentTimeMillis();
184 | }
185 |
186 | private synchronized void putIpAddr(String ipAddress, boolean isError) {
187 | if (ipAddress == null) {
188 | ipAddress = "N/A";
189 | }
190 |
191 | Map map = this.ipAddr.get(ipAddress);
192 |
193 | if (map == null) {
194 | map = new HashMap();
195 | }
196 |
197 | int requestCount = map.get(REQUEST_CNT) == null ? 0 : map.get(REQUEST_CNT);
198 | int errorCount = map.get(ERROR_CNT) == null ? 0 : map.get(ERROR_CNT);
199 |
200 | requestCount++;
201 |
202 | if (isError) {
203 | errorCount++;
204 | }
205 |
206 | map.put(REQUEST_CNT, requestCount);
207 | map.put(ERROR_CNT, errorCount);
208 |
209 | this.ipAddr.put(ipAddress, map);
210 | }
211 |
212 | private synchronized void putUserAgent(int agentHash, boolean isError) {
213 | Map map = this.userAgent.get(agentHash);
214 |
215 | if (map == null) {
216 | map = new HashMap();
217 | }
218 |
219 | int requestCount = map.get(REQUEST_CNT) == null ? 0 : map.get(REQUEST_CNT);
220 | int errorCount = map.get(ERROR_CNT) == null ? 0 : map.get(ERROR_CNT);
221 |
222 | requestCount++;
223 |
224 | if (isError) {
225 | errorCount++;
226 | }
227 |
228 | map.put(REQUEST_CNT, requestCount);
229 | map.put(ERROR_CNT, errorCount);
230 |
231 | this.userAgent.put(agentHash, map);
232 | }
233 |
234 | public Service getService() {
235 | return getService(false);
236 | }
237 |
238 | private Service getService(boolean isClear) {
239 | if (this.requestCount == 0) {
240 | return null;
241 | }
242 |
243 | isProcessing = true;
244 |
245 | try {
246 | if (this.serviceName == null) {
247 | this.serviceName = TextRD.getString(DateUtil.yyyymmdd(this.startTime), TextTypes.SERVICE, this.serviceHash);
248 | }
249 |
250 | if (this.serviceName == null) {
251 | return null;
252 | }
253 |
254 | Service service = new Service();
255 | service.setDate(this.startTime);
256 | service.setObject_hash(this.objHash);
257 | service.setService_hash(this.serviceHash);
258 | service.setLog_dt(new java.sql.Date(this.startTime));
259 | service.setLog_tm(new Time(this.startTime));
260 | service.setService_name(this.serviceName);
261 | service.setElapsed_avg(getElapsedAvg(isClear));
262 | service.setSql_count_avg(getSqlCountAvg(isClear));
263 | service.setSql_time_avg(getSqlTimeAvg(isClear));
264 | service.setElapsed_max(this.maxElapsed);
265 | service.setSql_count_max(this.maxSqlCount);
266 | service.setSql_time_max(this.maxSqlTime);
267 | service.setRequest_count(getRequestCount(isClear));
268 | service.setError_count(getErrorCount(isClear));
269 |
270 | List> keys = null;
271 | Map value = null;
272 | IpAddress ia = null;
273 | UserAgent ua = null;
274 |
275 | keys = new ArrayList(ipAddr.keySet());
276 | for (Object key : keys) {
277 | value = ipAddr.get(key);
278 |
279 | ia = new IpAddress();
280 | ia.setDate(this.startTime);
281 | ia.setService_hash(this.serviceHash);
282 | ia.setLog_dt(new java.sql.Date(this.startTime));
283 | ia.setLog_tm(new Time(this.startTime));
284 | ia.setIp_address((String) key);
285 | ia.setRequest_count(value.get(REQUEST_CNT));
286 | ia.setError_count(value.get(ERROR_CNT));
287 |
288 | service.addIpAddress(ia);
289 | }
290 |
291 | keys = new ArrayList(userAgent.keySet());
292 | String agent = null;
293 | for (Object key : keys) {
294 | value = userAgent.get(key);
295 |
296 | ua = new UserAgent();
297 | ua.setDate(this.startTime);
298 | ua.setService_hash(this.serviceHash);
299 | ua.setLog_dt(new java.sql.Date(this.startTime));
300 | ua.setLog_tm(new Time(this.startTime));
301 |
302 | agent = TextRD.getString(DateUtil.yyyymmdd(this.startTime), TextTypes.USER_AGENT, (Integer) key);
303 |
304 | if (agent == null) {
305 | agent = "N/A";
306 | }
307 |
308 | ua.setUser_agent(agent);
309 | ua.setRequest_count(value.get(REQUEST_CNT));
310 | ua.setError_count(value.get(ERROR_CNT));
311 |
312 | service.addUserAgent(ua);
313 | }
314 |
315 | //System.out.println("Request Count : " + service.getRequest_count() + " : " + this.requestCount);
316 | //System.out.println("Error Count : " + service.getError_count() + " : " + this.errorCount);
317 |
318 | service.setElapsed_exceed_count(elapsedExceedCount);
319 |
320 | return service;
321 | } finally {
322 | isProcessing = false;
323 | }
324 | }
325 |
326 | public Service getServiceAndClear() {
327 | Service service = getService(true);
328 | clear();
329 |
330 | return service;
331 | }
332 |
333 | public int getElapsedAvg(boolean isClear) {
334 | final LONG sum = new LONG();
335 | final INT cnt = new INT();
336 |
337 | int period = isClear ? 301 : 300;
338 |
339 | meter.search(period, new Handler() {
340 | public void process(Slot s) {
341 | sum.value += s.elapsed;
342 | cnt.value += s.requestCount;
343 | }
344 | });
345 |
346 | if (isClear) {
347 | sum.value -= lastSlot.elapsed;
348 | cnt.value -= lastSlot.requestCount;
349 | }
350 |
351 | return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
352 | }
353 |
354 | public int getSqlCountAvg(boolean isClear) {
355 | final LONG sum = new LONG();
356 | final INT cnt = new INT();
357 |
358 | int period = isClear ? 301 : 300;
359 |
360 | meter.search(period, new Handler() {
361 | public void process(Slot s) {
362 | sum.value += s.sqlCount;
363 | cnt.value += s.requestCount;
364 | }
365 | });
366 |
367 | if (isClear) {
368 | sum.value -= lastSlot.sqlCount;
369 | cnt.value -= lastSlot.requestCount;
370 | }
371 |
372 | return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
373 | }
374 |
375 | public int getSqlTimeAvg(boolean isClear) {
376 | final LONG sum = new LONG();
377 | final INT cnt = new INT();
378 |
379 | int period = isClear ? 301 : 300;
380 |
381 | meter.search(period, new Handler() {
382 | public void process(Slot s) {
383 | sum.value += s.sqlTime;
384 | cnt.value += s.requestCount;
385 | }
386 | });
387 |
388 | if (isClear) {
389 | sum.value -= lastSlot.sqlTime;
390 | cnt.value -= lastSlot.requestCount;
391 | }
392 |
393 | return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
394 | }
395 |
396 | public int getRequestCount(boolean isClear) {
397 | final INT sum = new INT();
398 |
399 | int period = isClear ? 301 : 300;
400 |
401 | meter.search(period, new Handler() {
402 | public void process(Slot s) {
403 | sum.value += s.requestCount;
404 | }
405 | });
406 |
407 | if (isClear) {
408 | sum.value -= lastSlot.requestCount;
409 | }
410 |
411 | return sum.value;
412 | }
413 |
414 | public int getErrorCount(boolean isClear) {
415 | final INT sum = new INT();
416 |
417 | int period = isClear ? 301 : 300;
418 |
419 | meter.search(period, new Handler() {
420 | public void process(Slot s) {
421 | sum.value += s.errorCount;
422 | }
423 | });
424 |
425 | if (isClear) {
426 | sum.value -= lastSlot.errorCount;
427 | }
428 |
429 | return sum.value;
430 | }
431 |
432 | public > Map sortByValue(Map map) {
433 | List> list = new LinkedList>(map.entrySet());
434 | Collections.sort(list, new Comparator>() {
435 | public int compare(Map.Entry o1, Map.Entry o2) {
436 | return (o2.getValue()).compareTo(o1.getValue());
437 | }
438 | });
439 |
440 | Map result = new LinkedHashMap();
441 | for (Map.Entry entry : list) {
442 | result.put(entry.getKey(), entry.getValue());
443 | }
444 |
445 | return result;
446 | }
447 |
448 | public static void main(String[] args) throws Exception {
449 | PrintWriter writer = new PrintWriter(System.out);
450 | OutputStream os = System.out;
451 |
452 | // Derby running as client/server mode
453 | NetworkServerControl server = new NetworkServerControl(InetAddress.getByName("0.0.0.0"), 1527);
454 | server.start(writer);
455 |
456 | SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(ServiceStat.class.getResourceAsStream("/mybatis-config.xml"));
457 | SqlSession session = sqlSessionFactory.openSession(true);
458 |
459 | String date = null;
460 | boolean initTables = true;
461 | if (initTables) {
462 | for (int i = 1; i <= 31; i++) {
463 | if (i < 10) {
464 | date = "0" + i;
465 | } else {
466 | date = i + "";
467 | }
468 |
469 | try {
470 | session.update("Scouter.dropIpAddress", date);
471 | } catch (Exception e) {
472 | Logger.println("[IP_ADDRESS_5M_" + date + "] Drop failed.");
473 | }
474 |
475 | try {
476 | session.update("Scouter.dropUserAgent", date);
477 | } catch (Exception e) {
478 | Logger.println("[USER_AGENT_5M_" + date + "] Drop failed.");
479 | }
480 |
481 | try {
482 | session.update("Scouter.dropHostAgent", date);
483 | } catch (Exception e) {
484 | Logger.println("[HOST_AGENT_5M_" + date + "] Drop failed.");
485 | }
486 |
487 | try {
488 | session.update("Scouter.dropJavaAgent", date);
489 | } catch (Exception e) {
490 | Logger.println("[JAVA_AGENT_5M_" + date + "] Drop failed.");
491 | }
492 |
493 | try {
494 | session.update("Scouter.dropService", date);
495 | } catch (Exception e) {
496 | Logger.println("[SERVICE_5M_" + date + "] Drop failed.");
497 | }
498 |
499 | try {
500 | session.update("Scouter.dropSql", date);
501 | } catch (Exception e) {
502 | Logger.println("[SQL_5M_" + date + "] Drop failed.");
503 | }
504 |
505 | try {
506 | session.update("Scouter.dropAlert", date);
507 | } catch (Exception e) {
508 | Logger.println("[ALERT_" + date + "] Drop failed.");
509 | }
510 | }
511 |
512 | try {
513 | session.update("Scouter.dropSqlInfo");
514 | } catch (Exception e) {
515 | Logger.println("[SQL_INFO_TBL] Drop failed.");
516 | }
517 |
518 | try {
519 | session.update("Scouter.dropAgentInfo");
520 | } catch (Exception e) {
521 | Logger.println("[AGENT_INFO_TBL] Drop failed.");
522 | }
523 |
524 | try {
525 | session.getConnection().prepareStatement("DROP TABLE TIME_TBL").execute();
526 | } catch (Exception e) {
527 | Logger.println("[TIME_TBL] Drop failed.");
528 | }
529 | }
530 |
531 | DatabaseMetaData dbmd = session.getConnection().getMetaData();
532 | ResultSet rs = null;
533 |
534 | /***********************************************
535 | * *
536 | * Check if required tables are exist or not. *
537 | * *
538 | ***********************************************/
539 |
540 | // 1. TIME_TBL
541 | rs = dbmd.getTables(null, "APP", "TIME_TBL", null);
542 |
543 | if (!rs.next()) {
544 | // create the TIME_TBL & insert rows
545 | ij.runScript(session.getConnection(), ReportingPlugin.class.getResourceAsStream("/init_time_table.sql"), "UTF-8", os, "UTF-8");
546 | }
547 |
548 | // 2. AGENT_INFO_TBL
549 | rs = dbmd.getTables(null, "APP", "AGENT_INFO_TBL", null);
550 |
551 | if (!rs.next()) {
552 | // create the AGENT_INFO_TBL
553 | try {
554 | session.update("Scouter.createAgentInfo");
555 | } catch (Exception e) {
556 | System.err.println("[AGENT_INFO_TBL] Already exists.");
557 | }
558 | }
559 |
560 | // 3. SQL_INFO_TBL
561 | rs = dbmd.getTables(null, "APP", "SQL_INFO_TBL", null);
562 |
563 | if (!rs.next()) {
564 | // create the SQL_INFO_TBL
565 | try {
566 | session.update("Scouter.createSqlInfo");
567 | } catch (Exception e) {
568 | System.err.println("[SQL_INFO_TBL] Already exists.");
569 | }
570 | }
571 |
572 | // 4. HOST_AGENT
573 | rs = dbmd.getTables(null, "APP", "HOST_AGENT_5M_01", null);
574 |
575 | if (!rs.next()) {
576 | // create HOST_AGENT tables
577 | for (int i = 1; i <= 31; i++) {
578 | if (i < 10) {
579 | date = "0" + i;
580 | } else {
581 | date = i + "";
582 | }
583 |
584 | try {
585 | session.update("Scouter.createHostAgent", date);
586 | } catch (Exception e) {
587 | System.err.println("[HOST_AGENT_5M_" + date + "] Already exists.");
588 | }
589 | }
590 | }
591 |
592 | // 5. JAVA_AGENT
593 | rs = dbmd.getTables(null, "APP", "JAVA_AGENT_5M_01", null);
594 |
595 | if (!rs.next()) {
596 | // create JAVA_AGENT tables
597 | for (int i = 1; i <= 31; i++) {
598 | if (i < 10) {
599 | date = "0" + i;
600 | } else {
601 | date = i + "";
602 | }
603 |
604 | try {
605 | session.update("Scouter.createJavaAgent", date);
606 | } catch (Exception e) {
607 | System.err.println("[JAVA_AGENT_5M_" + date + "] Already exists.");
608 | }
609 | }
610 | }
611 |
612 | // 6. SERVICE
613 | rs = dbmd.getTables(null, "APP", "SERVICE_5M_01", null);
614 |
615 | if (!rs.next()) {
616 | // create SERVICE tables
617 | for (int i = 1; i <= 31; i++) {
618 | if (i < 10) {
619 | date = "0" + i;
620 | } else {
621 | date = i + "";
622 | }
623 |
624 | try {
625 | session.update("Scouter.createService", date);
626 | } catch (Exception e) {
627 | System.err.println("[SERVICE_5M_" + date + "] Already exists.");
628 | }
629 | }
630 | }
631 |
632 | // 7. IP_ADDRESS
633 | rs = dbmd.getTables(null, "APP", "IP_ADDRESS_5M_01", null);
634 |
635 | if (!rs.next()) {
636 | // create IP_ADDRESS tables
637 | for (int i = 1; i <= 31; i++) {
638 | if (i < 10) {
639 | date = "0" + i;
640 | } else {
641 | date = i + "";
642 | }
643 |
644 | try {
645 | session.update("Scouter.createIpAddress", date);
646 | session.update("Scouter.alterIpAddress", date);
647 | } catch (Exception e) {
648 | System.err.println("[IP_ADDRESS_5M_" + date + "] Already exists.");
649 | }
650 | }
651 | }
652 |
653 | // 8. USER_AGENT
654 | rs = dbmd.getTables(null, "APP", "USER_AGENT_5M_01", null);
655 |
656 | if (!rs.next()) {
657 | // create USER_AGENT tables
658 | for (int i = 1; i <= 31; i++) {
659 | if (i < 10) {
660 | date = "0" + i;
661 | } else {
662 | date = i + "";
663 | }
664 |
665 | try {
666 | session.update("Scouter.createUserAgent", date);
667 | session.update("Scouter.alterUserAgent", date);
668 | } catch (Exception e) {
669 | System.err.println("[USER_AGENT_5M_" + date + "] Already exists.");
670 | }
671 | }
672 | }
673 |
674 | // 9. SQL
675 | rs = dbmd.getTables(null, "APP", "SQL_5M_01", null);
676 |
677 | if (!rs.next()) {
678 | // create SQL tables
679 | for (int i = 1; i <= 31; i++) {
680 | if (i < 10) {
681 | date = "0" + i;
682 | } else {
683 | date = i + "";
684 | }
685 |
686 | try {
687 | session.update("Scouter.createSql", date);
688 | } catch (Exception e) {
689 | System.err.println("[SQL_5M_" + date + "] Already exists.");
690 | }
691 | }
692 | }
693 |
694 | // 10. ALERT
695 | rs = dbmd.getTables(null, "APP", "ALERT_01", null);
696 |
697 | if (!rs.next()) {
698 | // create ALERT tables
699 | for (int i = 1; i <= 31; i++) {
700 | if (i < 10) {
701 | date = "0" + i;
702 | } else {
703 | date = i + "";
704 | }
705 |
706 | try {
707 | session.update("Scouter.createAlert", date);
708 | } catch (Exception e) {
709 | System.err.println("[ALERT_" + date + "] Already exists.");
710 | }
711 | }
712 | }
713 |
714 | final ServiceStat[] ss = new ServiceStat[] { new ServiceStat(12345, 111),
715 | new ServiceStat(12345, 222),
716 | new ServiceStat(12345, 333),
717 | new ServiceStat(12345, 444),
718 | new ServiceStat(12345, 555) };
719 |
720 | AgentInfo agentInfo = new AgentInfo();
721 | agentInfo.setObject_hash(12345);
722 | agentInfo.setObject_name("test");
723 | agentInfo.setObject_type("java");
724 | agentInfo.setIp_address("127.0.0.1");
725 | session.insert("Scouter.insertAgentInfo", agentInfo);
726 |
727 | final long until = System.currentTimeMillis() + (60 * 60 * 1000);
728 |
729 | new Thread() {
730 | public void run() {
731 | while (System.currentTimeMillis() < until) {
732 | for (ServiceStat s : ss) {
733 | s.add("/" + s.serviceHash + ".jsp",
734 | 9100 + new Random().nextInt(1000),
735 | new Random().nextInt(10) < 1 ? true : false,
736 | "192.168.0." + (new Random().nextInt(100) + 2),
737 | new Random().nextInt(10),
738 | 12345,
739 | 300 + new Random().nextInt(100));
740 | ThreadUtil.sleep(100);
741 | }
742 | }
743 | };
744 | }.start();
745 |
746 | long time = System.currentTimeMillis();
747 | long last_sent = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
748 |
749 | while (System.currentTimeMillis() < until) {
750 | time = System.currentTimeMillis();
751 | long now = time / DateUtil.MILLIS_PER_FIVE_MINUTE;
752 |
753 | if (now != last_sent) {
754 | last_sent = now;
755 |
756 | time = (time - 10000) / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
757 |
758 | Service service = null;
759 | for (ServiceStat s : ss) {
760 | service = s.getServiceAndClear();
761 |
762 | System.err.println(new Date(time) + ":" + service);
763 | session.insert("Scouter.insertService", service);
764 |
765 | System.out.println("IP_ADDRESS : " + service.getIpAddressList());
766 | session.insert("Scouter.insertIpAddress", service);
767 |
768 | System.out.println("USER_AGENT : " + service.getUserAgentList());
769 | session.insert("Scouter.insertUserAgent", service);
770 | }
771 | }
772 |
773 | ThreadUtil.sleep(1000);
774 | }
775 | }
776 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/report/AbstractReport.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.report;
2 |
3 | import java.io.File;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | import org.apache.poi.ss.usermodel.CellStyle;
8 | import org.apache.poi.ss.usermodel.CreationHelper;
9 | import org.apache.poi.ss.usermodel.DataFormat;
10 | import org.apache.poi.ss.usermodel.Font;
11 | import org.apache.poi.ss.usermodel.IndexedColors;
12 | import org.apache.poi.ss.usermodel.Workbook;
13 |
14 | import scouter.server.Configure;
15 |
16 | public abstract class AbstractReport {
17 |
18 | public static final String DEFAULT_DIR = System.getProperty("user.home") + File.separator + "scouter";
19 | public static Configure conf = Configure.getInstance();
20 | protected Map styles;
21 |
22 | public abstract void createExcel(int year, int month, int date) throws Exception;
23 | public abstract void createExcel(int year, int month) throws Exception;
24 |
25 | protected void createStyles(Workbook wb) {
26 | styles = new HashMap();
27 |
28 | CellStyle style;
29 | Font font = wb.createFont();
30 | font.setFontHeightInPoints((short)10);
31 | //font.setBold(true);
32 | //font.setColor(IndexedColors.DARK_BLUE.getIndex());
33 | style = wb.createCellStyle();
34 | style.setAlignment(CellStyle.ALIGN_CENTER);
35 | style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
36 | style.setFont(font);
37 | style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
38 | style.setFillPattern(CellStyle.SOLID_FOREGROUND);
39 | style.setBorderLeft(CellStyle.BORDER_THIN);
40 | style.setBorderRight(CellStyle.BORDER_THIN);
41 | style.setBorderBottom(CellStyle.BORDER_THIN);
42 | style.setBorderTop(CellStyle.BORDER_THIN);
43 | styles.put("header", style);
44 |
45 | style = wb.createCellStyle();
46 | font = wb.createFont();
47 | font.setFontHeightInPoints((short)10);
48 | style.setFont(font);
49 | CreationHelper createHelper = wb.getCreationHelper();
50 | style.setDataFormat(createHelper.createDataFormat().getFormat("yyyy.mm.dd"));
51 | style.setAlignment(CellStyle.ALIGN_CENTER);
52 | style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
53 | style.setBorderLeft(CellStyle.BORDER_THIN);
54 | style.setBorderRight(CellStyle.BORDER_THIN);
55 | style.setBorderBottom(CellStyle.BORDER_THIN);
56 | style.setBorderTop(CellStyle.BORDER_THIN);
57 | styles.put("date", style);
58 |
59 | style = wb.createCellStyle();
60 | font = wb.createFont();
61 | font.setFontHeightInPoints((short)10);
62 | style.setFont(font);
63 | style.setAlignment(CellStyle.ALIGN_CENTER);
64 | style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
65 | style.setBorderLeft(CellStyle.BORDER_THIN);
66 | style.setBorderRight(CellStyle.BORDER_THIN);
67 | style.setBorderBottom(CellStyle.BORDER_THIN);
68 | style.setBorderTop(CellStyle.BORDER_THIN);
69 | style.setWrapText(true);
70 | styles.put("text", style);
71 |
72 | style = wb.createCellStyle();
73 | font = wb.createFont();
74 | font.setFontHeightInPoints((short)10);
75 | style.setFont(font);
76 | style.setAlignment(CellStyle.ALIGN_LEFT);
77 | style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
78 | style.setBorderLeft(CellStyle.BORDER_THIN);
79 | style.setBorderRight(CellStyle.BORDER_THIN);
80 | style.setBorderBottom(CellStyle.BORDER_THIN);
81 | style.setBorderTop(CellStyle.BORDER_THIN);
82 | styles.put("l_text", style);
83 |
84 | style = wb.createCellStyle();
85 | font = wb.createFont();
86 | font.setFontHeightInPoints((short)10);
87 | font.setUnderline(Font.U_SINGLE);
88 | font.setColor(IndexedColors.BLUE.getIndex());
89 | style.setFont(font);
90 | style.setAlignment(CellStyle.ALIGN_CENTER);
91 | style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
92 | style.setBorderLeft(CellStyle.BORDER_THIN);
93 | style.setBorderRight(CellStyle.BORDER_THIN);
94 | style.setBorderBottom(CellStyle.BORDER_THIN);
95 | style.setBorderTop(CellStyle.BORDER_THIN);
96 | styles.put("link", style);
97 |
98 | style = wb.createCellStyle();
99 | font = wb.createFont();
100 | font.setFontHeightInPoints((short)10);
101 | style.setFont(font);
102 | style.setAlignment(CellStyle.ALIGN_RIGHT);
103 | style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
104 | style.setBorderLeft(CellStyle.BORDER_THIN);
105 | style.setBorderRight(CellStyle.BORDER_THIN);
106 | style.setBorderBottom(CellStyle.BORDER_THIN);
107 | style.setBorderTop(CellStyle.BORDER_THIN);
108 | DataFormat dataFormat = wb.createDataFormat();
109 | style.setDataFormat(dataFormat.getFormat("#,###,##0"));
110 | styles.put("numeric", style);
111 |
112 | style = wb.createCellStyle();
113 | font = wb.createFont();
114 | font.setFontHeightInPoints((short)10);
115 | style.setFont(font);
116 | style.setAlignment(CellStyle.ALIGN_RIGHT);
117 | style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
118 | style.setBorderLeft(CellStyle.BORDER_THIN);
119 | style.setBorderRight(CellStyle.BORDER_THIN);
120 | style.setBorderBottom(CellStyle.BORDER_THIN);
121 | style.setBorderTop(CellStyle.BORDER_THIN);
122 | dataFormat = wb.createDataFormat();
123 | style.setDataFormat(dataFormat.getFormat("#,###,##0.0#"));
124 | styles.put("numeric2", style);
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/report/AlertReport.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.report;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.util.HashMap;
6 | import java.util.List;
7 | import java.util.Map;
8 |
9 | import org.apache.poi.ss.util.CellRangeAddress;
10 | import org.apache.poi.xssf.usermodel.XSSFCell;
11 | import org.apache.poi.xssf.usermodel.XSSFRow;
12 | import org.apache.poi.xssf.usermodel.XSSFSheet;
13 | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
14 |
15 | import scouter.plugin.server.reporting.service.ScouterService;
16 | import scouter.plugin.server.reporting.vo.Alert;
17 |
18 | public class AlertReport extends AbstractReport {
19 |
20 | @Override
21 | public void createExcel(int year, int month, int date) throws Exception {
22 | XSSFWorkbook workbook = new XSSFWorkbook();
23 | XSSFSheet sheet = null;
24 | XSSFRow row = null;
25 | XSSFCell cell = null;
26 |
27 | String day = year + "." + (month < 10 ? "0" + month : month) + "." + (date < 10 ? "0" + date : date);
28 |
29 | createStyles(workbook);
30 |
31 | ScouterService service = new ScouterService();
32 |
33 | int rowIdx = 0;
34 | int colIdx = 0;
35 |
36 | List alertList = service.getAlertList(year, month, date);
37 | Map widthMap = new HashMap();
38 |
39 | sheet = workbook.createSheet(day);
40 |
41 | row = sheet.createRow(rowIdx++);
42 | cell = row.createCell(colIdx++);
43 | cell.setCellValue("OBJECT_NAME");
44 | cell.setCellStyle(styles.get("header"));
45 | widthMap.put(0, 5000);
46 |
47 | cell = row.createCell(colIdx++);
48 | cell.setCellValue("DATE");
49 | cell.setCellStyle(styles.get("header"));
50 | widthMap.put(1, 2500);
51 |
52 | cell = row.createCell(colIdx++);
53 | cell.setCellValue("TIME");
54 | cell.setCellStyle(styles.get("header"));
55 | widthMap.put(2, 2500);
56 |
57 | cell = row.createCell(colIdx++);
58 | cell.setCellValue("LEVEL");
59 | cell.setCellStyle(styles.get("header"));
60 | widthMap.put(3, 2500);
61 |
62 | cell = row.createCell(colIdx++);
63 | cell.setCellValue("TITLE");
64 | cell.setCellStyle(styles.get("header"));
65 | widthMap.put(4, 5000);
66 |
67 | cell = row.createCell(colIdx++);
68 | cell.setCellValue("MESSAGE");
69 | cell.setCellStyle(styles.get("header"));
70 | widthMap.put(5, 5000);
71 |
72 | if (alertList != null && !alertList.isEmpty()) {
73 | for (Alert alert : alertList) {
74 | colIdx = 0;
75 | row = sheet.createRow(rowIdx++);
76 |
77 | cell = row.createCell(colIdx++);
78 | cell.setCellValue(alert.getObject_name());
79 | cell.setCellStyle(styles.get("text"));
80 |
81 | if (widthMap.get(0) < alert.getObject_name().length() * 195) {
82 | widthMap.put(0, alert.getObject_name().length() * 195);
83 | }
84 |
85 | cell = row.createCell(colIdx++);
86 | cell.setCellValue(alert.getDay().replaceAll("-", "."));
87 | cell.setCellStyle(styles.get("date"));
88 |
89 | cell = row.createCell(colIdx++);
90 | cell.setCellValue(alert.getTime());
91 | cell.setCellStyle(styles.get("date"));
92 |
93 | cell = row.createCell(colIdx++);
94 | cell.setCellValue(alert.getLevel());
95 | cell.setCellStyle(styles.get("text"));
96 |
97 | cell = row.createCell(colIdx++);
98 | cell.setCellValue(alert.getTitle());
99 | cell.setCellStyle(styles.get("text"));
100 |
101 | if (widthMap.get(4) < alert.getTitle().length() * 250) {
102 | widthMap.put(4, alert.getTitle().length() * 250);
103 | }
104 |
105 | cell = row.createCell(colIdx++);
106 | cell.setCellValue(alert.getMessage());
107 | cell.setCellStyle(styles.get("l_text"));
108 |
109 | if (widthMap.get(5) < alert.getMessage().length() * 190) {
110 | widthMap.put(5, alert.getMessage().length() * 190);
111 | }
112 | }
113 |
114 | sheet.setAutoFilter(new CellRangeAddress(0, alertList.size(), 0, 5));
115 | }
116 |
117 | for (Integer idx : widthMap.keySet()) {
118 | int length = widthMap.get(idx);
119 |
120 | sheet.setColumnWidth(idx, length);
121 | }
122 |
123 | String dir = conf.getValue("ext_plugin_reporting_output_dir", DEFAULT_DIR);
124 |
125 | if (!dir.endsWith(File.separator)) {
126 | dir = dir + File.separator;
127 | }
128 |
129 | dir = dir + year + File.separator;
130 | dir = dir + (month < 10 ? "0" + month : month) + File.separator;
131 | dir = dir + (date < 10 ? "0" + date : date) + File.separator;
132 |
133 | File file = new File(dir + "alert_" + day + ".xlsx");
134 | file.getParentFile().mkdirs();
135 |
136 | FileOutputStream fileOut = new FileOutputStream(file);
137 | workbook.write(fileOut);
138 | workbook.close();
139 | fileOut.close();
140 | }
141 |
142 | @Override
143 | public void createExcel(int year, int month) throws Exception {
144 | XSSFWorkbook workbook = new XSSFWorkbook();
145 | XSSFSheet sheet = null;
146 | XSSFRow row = null;
147 | XSSFCell cell = null;
148 |
149 | String day = year + "." + (month < 10 ? "0" + month : month);
150 |
151 | createStyles(workbook);
152 |
153 | ScouterService service = new ScouterService();
154 |
155 | int rowIdx = 0;
156 | int colIdx = 0;
157 |
158 | List alertList = service.getAlertList(year, month);
159 | Map widthMap = new HashMap();
160 |
161 | sheet = workbook.createSheet(day);
162 |
163 | row = sheet.createRow(rowIdx++);
164 | cell = row.createCell(colIdx++);
165 | cell.setCellValue("OBJECT_NAME");
166 | cell.setCellStyle(styles.get("header"));
167 | widthMap.put(0, 5000);
168 |
169 | cell = row.createCell(colIdx++);
170 | cell.setCellValue("DATE");
171 | cell.setCellStyle(styles.get("header"));
172 | widthMap.put(1, 2500);
173 |
174 | cell = row.createCell(colIdx++);
175 | cell.setCellValue("TIME");
176 | cell.setCellStyle(styles.get("header"));
177 | widthMap.put(2, 2500);
178 |
179 | cell = row.createCell(colIdx++);
180 | cell.setCellValue("LEVEL");
181 | cell.setCellStyle(styles.get("header"));
182 | widthMap.put(3, 2500);
183 |
184 | cell = row.createCell(colIdx++);
185 | cell.setCellValue("TITLE");
186 | cell.setCellStyle(styles.get("header"));
187 | widthMap.put(4, 5000);
188 |
189 | cell = row.createCell(colIdx++);
190 | cell.setCellValue("MESSAGE");
191 | cell.setCellStyle(styles.get("header"));
192 | widthMap.put(5, 5000);
193 |
194 | if (alertList != null && !alertList.isEmpty()) {
195 | for (Alert alert : alertList) {
196 | colIdx = 0;
197 | row = sheet.createRow(rowIdx++);
198 |
199 | cell = row.createCell(colIdx++);
200 | cell.setCellValue(alert.getObject_name());
201 | cell.setCellStyle(styles.get("text"));
202 |
203 | if (widthMap.get(0) < alert.getObject_name().length() * 195) {
204 | widthMap.put(0, alert.getObject_name().length() * 195);
205 | }
206 |
207 | cell = row.createCell(colIdx++);
208 | cell.setCellValue(alert.getDay().replaceAll("-", "."));
209 | cell.setCellStyle(styles.get("date"));
210 |
211 | cell = row.createCell(colIdx++);
212 | cell.setCellValue(alert.getTime());
213 | cell.setCellStyle(styles.get("date"));
214 |
215 | cell = row.createCell(colIdx++);
216 | cell.setCellValue(alert.getLevel());
217 | cell.setCellStyle(styles.get("text"));
218 |
219 | cell = row.createCell(colIdx++);
220 | cell.setCellValue(alert.getTitle());
221 | cell.setCellStyle(styles.get("text"));
222 |
223 | if (widthMap.get(4) < alert.getTitle().length() * 250) {
224 | widthMap.put(4, alert.getTitle().length() * 250);
225 | }
226 |
227 | cell = row.createCell(colIdx++);
228 | cell.setCellValue(alert.getMessage());
229 | cell.setCellStyle(styles.get("l_text"));
230 |
231 | if (widthMap.get(5) < alert.getMessage().length() * 190) {
232 | widthMap.put(5, alert.getMessage().length() * 190);
233 | }
234 | }
235 |
236 | sheet.setAutoFilter(new CellRangeAddress(0, alertList.size(), 0, 5));
237 | }
238 |
239 | for (Integer idx : widthMap.keySet()) {
240 | int length = widthMap.get(idx);
241 |
242 | sheet.setColumnWidth(idx, length);
243 | }
244 |
245 | String dir = conf.getValue("ext_plugin_reporting_output_dir", DEFAULT_DIR);
246 |
247 | if (!dir.endsWith(File.separator)) {
248 | dir = dir + File.separator;
249 | }
250 |
251 | dir = dir + year + File.separator;
252 | dir = dir + (month < 10 ? "0" + month : month) + File.separator;
253 |
254 | File file = new File(dir + "alert_" + day + ".xlsx");
255 | file.getParentFile().mkdirs();
256 |
257 | FileOutputStream fileOut = new FileOutputStream(file);
258 | workbook.write(fileOut);
259 | workbook.close();
260 | fileOut.close();
261 | }
262 |
263 | }
264 |
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/report/HostReport.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.report;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.util.List;
6 |
7 | import org.apache.poi.ss.util.CellRangeAddress;
8 | import org.apache.poi.ss.util.RegionUtil;
9 | import org.apache.poi.xssf.usermodel.XSSFCell;
10 | import org.apache.poi.xssf.usermodel.XSSFChart;
11 | import org.apache.poi.xssf.usermodel.XSSFDrawing;
12 | import org.apache.poi.xssf.usermodel.XSSFRow;
13 | import org.apache.poi.xssf.usermodel.XSSFSheet;
14 | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
15 | import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart;
16 | import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineSer;
17 |
18 | import scouter.plugin.server.reporting.service.ScouterService;
19 | import scouter.plugin.server.reporting.vo.AgentInfo;
20 | import scouter.plugin.server.reporting.vo.HostAgent;
21 |
22 | public class HostReport extends AbstractReport {
23 |
24 | @Override
25 | public void createExcel(int year, int month, int date) throws Exception {
26 | XSSFWorkbook workbook = new XSSFWorkbook(HostReport.class.getResourceAsStream("/excel/host_hourly_template.xlsx"));
27 | XSSFSheet sheet = null;
28 | XSSFRow row = null;
29 | XSSFCell cell = null;
30 |
31 | String day = year + "." + (month < 10 ? "0" + month : month) + "." + (date < 10 ? "0" + date : date);
32 |
33 | createStyles(workbook);
34 |
35 | ScouterService service = new ScouterService();
36 | List agentInfoList = service.getAgentInfoList();
37 |
38 | AgentInfo agentInfo = null;
39 |
40 | int sheetCnt = 0;
41 | String sheetName = null;
42 | int rowIdx = 0;
43 | int colIdx = 0;
44 | List agentList = null;
45 | for (int i = 0; i < agentInfoList.size(); i++) {
46 | agentInfo = agentInfoList.get(i);
47 |
48 | if (agentInfo.getObject_family().equals("host")) {
49 | agentList = service.getHostHourlyStat(year, month, date, agentInfo.getObject_hash());
50 |
51 | if (agentList != null && !agentList.isEmpty()) {
52 | String name = agentList.get(0).getObject_name();
53 |
54 | if (name.indexOf("/") > -1) {
55 | name = name.substring(name.lastIndexOf("/") + 1);
56 | }
57 |
58 | sheet = workbook.getSheetAt(sheetCnt);
59 | sheetName = sheet.getSheetName();
60 | workbook.setSheetName(sheetCnt++, name);
61 |
62 | rowIdx = 1;
63 | for (HostAgent agent : agentList) {
64 | colIdx = 3;
65 | row = sheet.getRow(rowIdx++);
66 |
67 | if (rowIdx == 2) {
68 | cell = row.getCell(0);
69 | cell.setCellValue(agentList.get(0).getObject_name());
70 | cell.setCellStyle(styles.get("text"));
71 |
72 | cell = row.getCell(1);
73 | cell.setCellValue(year + "." + (month < 10 ? "0" + month : month) + "." + (date < 10 ? "0" + date : date));
74 | cell.setCellStyle(styles.get("date"));
75 | }
76 |
77 | cell = row.getCell(colIdx++);
78 | if (agent.getCpu_avg() != null) {
79 | cell.setCellValue(agent.getCpu_avg());
80 | cell.setCellStyle(styles.get("numeric2"));
81 | }
82 |
83 | cell = row.getCell(colIdx++);
84 | if (agent.getCpu_max() != null) {
85 | cell.setCellValue(agent.getCpu_max());
86 | cell.setCellStyle(styles.get("numeric2"));
87 | }
88 |
89 | cell = row.getCell(colIdx++);
90 | if (agent.getMem_total() != null) {
91 | cell.setCellValue(agent.getMem_total());
92 | cell.setCellStyle(styles.get("numeric"));
93 | }
94 |
95 | cell = row.getCell(colIdx++);
96 | if (agent.getMem_avg() != null) {
97 | cell.setCellValue(agent.getMem_avg());
98 | cell.setCellStyle(styles.get("numeric2"));
99 | }
100 |
101 | cell = row.getCell(colIdx++);
102 | if (agent.getMem_max() != null) {
103 | cell.setCellValue(agent.getMem_max());
104 | cell.setCellStyle(styles.get("numeric2"));
105 | }
106 |
107 | cell = row.getCell(colIdx++);
108 | if (agent.getMem_u_avg() != null) {
109 | cell.setCellValue(agent.getMem_u_avg());
110 | cell.setCellStyle(styles.get("numeric"));
111 | }
112 |
113 | cell = row.getCell(colIdx++);
114 | if (agent.getMem_u_max() != null) {
115 | cell.setCellValue(agent.getMem_u_max());
116 | cell.setCellStyle(styles.get("numeric"));
117 | }
118 |
119 | cell = row.getCell(colIdx++);
120 | if (agent.getNet_tx_avg() != null) {
121 | cell.setCellValue(agent.getNet_tx_avg());
122 | cell.setCellStyle(styles.get("numeric"));
123 | }
124 |
125 | cell = row.getCell(colIdx++);
126 | if (agent.getNet_tx_max() != null) {
127 | cell.setCellValue(agent.getNet_tx_max());
128 | cell.setCellStyle(styles.get("numeric"));
129 | }
130 |
131 | cell = row.getCell(colIdx++);
132 | if (agent.getNet_rx_avg() != null) {
133 | cell.setCellValue(agent.getNet_rx_avg());
134 | cell.setCellStyle(styles.get("numeric"));
135 | }
136 |
137 | cell = row.getCell(colIdx++);
138 | if (agent.getNet_rx_max() != null) {
139 | cell.setCellValue(agent.getNet_rx_max());
140 | cell.setCellStyle(styles.get("numeric"));
141 | }
142 |
143 | cell = row.getCell(colIdx++);
144 | if (agent.getDisk_r_avg() != null) {
145 | cell.setCellValue(agent.getDisk_r_avg());
146 | cell.setCellStyle(styles.get("numeric"));
147 | }
148 |
149 | cell = row.getCell(colIdx++);
150 | if (agent.getDisk_r_max() != null) {
151 | cell.setCellValue(agent.getDisk_r_max());
152 | cell.setCellStyle(styles.get("numeric2"));
153 | }
154 |
155 | cell = row.getCell(colIdx++);
156 | if (agent.getDisk_w_avg() != null) {
157 | cell.setCellValue(agent.getDisk_w_avg());
158 | cell.setCellStyle(styles.get("numeric2"));
159 | }
160 |
161 | cell = row.getCell(colIdx++);
162 | if (agent.getDisk_w_max() != null) {
163 | cell.setCellValue(agent.getDisk_w_max());
164 | cell.setCellStyle(styles.get("numeric"));
165 | }
166 | }
167 |
168 | XSSFDrawing drawing = sheet.getDrawingPatriarch();
169 | List chartList = drawing.getCharts();
170 | for (XSSFChart chart : chartList) {
171 | CTLineChart[] lineChartList = chart.getCTChart().getPlotArea().getLineChartArray();
172 | for (CTLineChart c : lineChartList) {
173 | CTLineSer[] seriesList = c.getSerArray();
174 | for (CTLineSer ser : seriesList) {
175 | String ref = ser.getTx().getStrRef().getF();
176 | ser.getTx().getStrRef().setF(ref.replaceAll("'" + sheetName + "'", "'" + name + "'"));
177 | ref = ser.getCat().getStrRef().getF();
178 | ser.getCat().getStrRef().setF(ref.replaceAll("'" + sheetName + "'", "'" + name + "'"));
179 | ref = ser.getVal().getNumRef().getF();
180 | ser.getVal().getNumRef().setF(ref.replaceAll("'" + sheetName + "'", "'" + name + "'"));
181 | }
182 | }
183 | }
184 | }
185 | }
186 | }
187 |
188 | int totalCnt = workbook.getNumberOfSheets();
189 | for (int i = sheetCnt; i < totalCnt; i++) {
190 | workbook.removeSheetAt(sheetCnt);
191 | }
192 |
193 | String dir = conf.getValue("ext_plugin_reporting_output_dir", DEFAULT_DIR);
194 |
195 | if (!dir.endsWith(File.separator)) {
196 | dir = dir + File.separator;
197 | }
198 |
199 | dir = dir + year + File.separator;
200 | dir = dir + (month < 10 ? "0" + month : month) + File.separator;
201 | dir = dir + (date < 10 ? "0" + date : date) + File.separator;
202 |
203 | File file = new File(dir + "host_" + day + ".xlsx");
204 | file.getParentFile().mkdirs();
205 |
206 | FileOutputStream fileOut = new FileOutputStream(file);
207 | workbook.write(fileOut);
208 | workbook.close();
209 | fileOut.close();
210 | }
211 |
212 | @Override
213 | public void createExcel(int year, int month) throws Exception {
214 | XSSFWorkbook workbook = new XSSFWorkbook(HostReport.class.getResourceAsStream("/excel/host_daily_template.xlsx"));
215 | XSSFSheet sheet = null;
216 | XSSFRow row = null;
217 | XSSFCell cell = null;
218 |
219 | String day = year + "." + (month < 10 ? "0" + month : month);
220 |
221 | createStyles(workbook);
222 |
223 | ScouterService service = new ScouterService();
224 | List agentInfoList = service.getAgentInfoList();
225 |
226 | AgentInfo agentInfo = null;
227 |
228 | int sheetCnt = 0;
229 | String sheetName = null;
230 | int rowIdx = 0;
231 | int colIdx = 0;
232 | List agentList = null;
233 | for (int i = 0; i < agentInfoList.size(); i++) {
234 | agentInfo = agentInfoList.get(i);
235 |
236 | if (agentInfo.getObject_family().equals("host")) {
237 | agentList = service.getHostDailyStat(year, month, agentInfo.getObject_hash());
238 |
239 | if (agentList != null && !agentList.isEmpty()) {
240 | String name = agentList.get(0).getObject_name();
241 |
242 | if (name.indexOf("/") > -1) {
243 | name = name.substring(name.lastIndexOf("/") + 1);
244 | }
245 |
246 | sheet = workbook.getSheetAt(sheetCnt);
247 | sheetName = sheet.getSheetName();
248 | workbook.setSheetName(sheetCnt++, name);
249 |
250 | int diff = (31 - agentList.size());
251 |
252 | rowIdx = 1;
253 | for (HostAgent agent : agentList) {
254 | if (rowIdx == 3) {
255 | if (diff > 0) {
256 | sheet.removeMergedRegion(0);
257 | sheet.addMergedRegion(new CellRangeAddress(1, agentList.size(), 0, 0));
258 | RegionUtil.setBorderBottom(1, new CellRangeAddress(1, agentList.size(), 0, 0), sheet, workbook);
259 | }
260 | }
261 |
262 | colIdx = 1;
263 | row = sheet.getRow(rowIdx++);
264 |
265 | if (rowIdx == 2) {
266 | cell = row.getCell(0);
267 | cell.setCellValue(agentList.get(0).getObject_name());
268 | cell.setCellStyle(styles.get("text"));
269 | }
270 |
271 | cell = row.getCell(colIdx++);
272 | cell.setCellValue(agent.getDay().replaceAll("-", "."));
273 | cell.setCellStyle(styles.get("date"));
274 |
275 | cell = row.getCell(colIdx++);
276 | if (agent.getCpu_avg() != null) {
277 | cell.setCellValue(agent.getCpu_avg());
278 | cell.setCellStyle(styles.get("numeric2"));
279 | }
280 |
281 | cell = row.getCell(colIdx++);
282 | if (agent.getCpu_max() != null) {
283 | cell.setCellValue(agent.getCpu_max());
284 | cell.setCellStyle(styles.get("numeric2"));
285 | }
286 |
287 | cell = row.getCell(colIdx++);
288 | if (agent.getMem_total() != null) {
289 | cell.setCellValue(agent.getMem_total());
290 | cell.setCellStyle(styles.get("numeric"));
291 | }
292 |
293 | cell = row.getCell(colIdx++);
294 | if (agent.getMem_avg() != null) {
295 | cell.setCellValue(agent.getMem_avg());
296 | cell.setCellStyle(styles.get("numeric2"));
297 | }
298 |
299 | cell = row.getCell(colIdx++);
300 | if (agent.getMem_max() != null) {
301 | cell.setCellValue(agent.getMem_max());
302 | cell.setCellStyle(styles.get("numeric2"));
303 | }
304 |
305 | cell = row.getCell(colIdx++);
306 | if (agent.getMem_u_avg() != null) {
307 | cell.setCellValue(agent.getMem_u_avg());
308 | cell.setCellStyle(styles.get("numeric"));
309 | }
310 |
311 | cell = row.getCell(colIdx++);
312 | if (agent.getMem_u_max() != null) {
313 | cell.setCellValue(agent.getMem_u_max());
314 | cell.setCellStyle(styles.get("numeric"));
315 | }
316 |
317 | cell = row.getCell(colIdx++);
318 | if (agent.getNet_tx_avg() != null) {
319 | cell.setCellValue(agent.getNet_tx_avg());
320 | cell.setCellStyle(styles.get("numeric"));
321 | }
322 |
323 | cell = row.getCell(colIdx++);
324 | if (agent.getNet_tx_max() != null) {
325 | cell.setCellValue(agent.getNet_tx_max());
326 | cell.setCellStyle(styles.get("numeric"));
327 | }
328 |
329 | cell = row.getCell(colIdx++);
330 | if (agent.getNet_rx_avg() != null) {
331 | cell.setCellValue(agent.getNet_rx_avg());
332 | cell.setCellStyle(styles.get("numeric"));
333 | }
334 |
335 | cell = row.getCell(colIdx++);
336 | if (agent.getNet_rx_max() != null) {
337 | cell.setCellValue(agent.getNet_rx_max());
338 | cell.setCellStyle(styles.get("numeric"));
339 | }
340 |
341 | cell = row.getCell(colIdx++);
342 | if (agent.getDisk_r_avg() != null) {
343 | cell.setCellValue(agent.getDisk_r_avg());
344 | cell.setCellStyle(styles.get("numeric"));
345 | }
346 |
347 | cell = row.getCell(colIdx++);
348 | if (agent.getDisk_r_max() != null) {
349 | cell.setCellValue(agent.getDisk_r_max());
350 | cell.setCellStyle(styles.get("numeric"));
351 | }
352 |
353 | cell = row.getCell(colIdx++);
354 | if (agent.getDisk_w_avg() != null) {
355 | cell.setCellValue(agent.getDisk_w_avg());
356 | cell.setCellStyle(styles.get("numeric"));
357 | }
358 |
359 | cell = row.getCell(colIdx++);
360 | if (agent.getDisk_w_max() != null) {
361 | cell.setCellValue(agent.getDisk_w_max());
362 | cell.setCellStyle(styles.get("numeric"));
363 | }
364 | }
365 |
366 | if (diff > 0) {
367 | for (int r = 0; r < diff; r++) {
368 | row = sheet.getRow(rowIdx++);
369 | sheet.removeRow(row);
370 | }
371 | }
372 |
373 | XSSFDrawing drawing = sheet.getDrawingPatriarch();
374 | List chartList = drawing.getCharts();
375 | for (XSSFChart chart : chartList) {
376 | CTLineChart[] lineChartList = chart.getCTChart().getPlotArea().getLineChartArray();
377 | for (CTLineChart c : lineChartList) {
378 | CTLineSer[] seriesList = c.getSerArray();
379 | for (CTLineSer ser : seriesList) {
380 | String ref = ser.getTx().getStrRef().getF().replaceAll("'" + sheetName + "'", "'" + name + "'");
381 |
382 | if (diff > 0) {
383 | ref = ref.replaceAll("32", Integer.toString(32 - diff));
384 | }
385 | ser.getTx().getStrRef().setF(ref);
386 |
387 | ref = ser.getCat().getNumRef().getF().replaceAll("'" + sheetName + "'", "'" + name + "'");
388 |
389 | if (diff > 0) {
390 | ref = ref.replaceAll("32", Integer.toString(32 - diff));
391 | }
392 | ser.getCat().getNumRef().setF(ref);
393 |
394 |
395 | ref = ser.getVal().getNumRef().getF().replaceAll("'" + sheetName + "'", "'" + name + "'");
396 |
397 | if (diff > 0) {
398 | ref = ref.replaceAll("32", Integer.toString(32 - diff));
399 | }
400 | ser.getVal().getNumRef().setF(ref);
401 | }
402 | }
403 | }
404 | }
405 | }
406 | }
407 |
408 | int totalCnt = workbook.getNumberOfSheets();
409 | for (int i = sheetCnt; i < totalCnt; i++) {
410 | workbook.removeSheetAt(sheetCnt);
411 | }
412 |
413 | String dir = conf.getValue("ext_plugin_reporting_output_dir", DEFAULT_DIR);
414 |
415 | if (!dir.endsWith(File.separator)) {
416 | dir = dir + File.separator;
417 | }
418 |
419 | dir = dir + year + File.separator;
420 | dir = dir + (month < 10 ? "0" + month : month) + File.separator;
421 |
422 | File file = new File(dir + "host_" + day + ".xlsx");
423 | file.getParentFile().mkdirs();
424 |
425 | FileOutputStream fileOut = new FileOutputStream(file);
426 | workbook.write(fileOut);
427 | workbook.close();
428 | fileOut.close();
429 | }
430 |
431 | }
432 |
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/report/JavaReport.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.report;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.util.List;
6 |
7 | import org.apache.poi.ss.util.CellRangeAddress;
8 | import org.apache.poi.ss.util.RegionUtil;
9 | import org.apache.poi.xssf.usermodel.XSSFCell;
10 | import org.apache.poi.xssf.usermodel.XSSFChart;
11 | import org.apache.poi.xssf.usermodel.XSSFDrawing;
12 | import org.apache.poi.xssf.usermodel.XSSFRow;
13 | import org.apache.poi.xssf.usermodel.XSSFSheet;
14 | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
15 | import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart;
16 | import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineSer;
17 |
18 | import scouter.plugin.server.reporting.service.ScouterService;
19 | import scouter.plugin.server.reporting.vo.AgentInfo;
20 | import scouter.plugin.server.reporting.vo.JavaAgent;
21 |
22 | public class JavaReport extends AbstractReport {
23 |
24 | @Override
25 | public void createExcel(int year, int month, int date) throws Exception {
26 | XSSFWorkbook workbook = new XSSFWorkbook(JavaReport.class.getResourceAsStream("/excel/java_hourly_template.xlsx"));
27 | XSSFSheet sheet = null;
28 | XSSFRow row = null;
29 | XSSFCell cell = null;
30 |
31 | String day = year + "." + (month < 10 ? "0" + month : month) + "." + (date < 10 ? "0" + date : date);
32 |
33 | createStyles(workbook);
34 |
35 | ScouterService service = new ScouterService();
36 | List agentInfoList = service.getAgentInfoList();
37 |
38 | AgentInfo agentInfo = null;
39 |
40 | int sheetCnt = 0;
41 | String sheetName = null;
42 | int rowIdx = 0;
43 | int colIdx = 0;
44 | List agentList = null;
45 | for (int i = 0; i < agentInfoList.size(); i++) {
46 | agentInfo = agentInfoList.get(i);
47 |
48 | if (agentInfo.getObject_family().equals("javaee") || agentInfo.getObject_family().equals("java")) {
49 | agentList = service.getJavaHourlyStat(year, month, date, agentInfo.getObject_hash());
50 |
51 | if (agentList != null && !agentList.isEmpty()) {
52 | String name = agentList.get(0).getObject_name();
53 |
54 | if (name.indexOf("/") > -1) {
55 | name = name.substring(name.lastIndexOf("/") + 1);
56 | }
57 |
58 | sheet = workbook.getSheetAt(sheetCnt);
59 | sheetName = sheet.getSheetName();
60 | workbook.setSheetName(sheetCnt++, name);
61 |
62 | rowIdx = 1;
63 | for (JavaAgent agent : agentList) {
64 | colIdx = 3;
65 | row = sheet.getRow(rowIdx++);
66 |
67 | if (rowIdx == 2) {
68 | cell = row.getCell(0);
69 | cell.setCellValue(agentList.get(0).getObject_name());
70 | cell.setCellStyle(styles.get("text"));
71 |
72 | cell = row.getCell(1);
73 | cell.setCellValue(year + "." + (month < 10 ? "0" + month : month) + "." + (date < 10 ? "0" + date : date));
74 | cell.setCellStyle(styles.get("date"));
75 | }
76 |
77 | cell = row.getCell(colIdx++);
78 | if (agent.getActive_service_avg() != null) {
79 | cell.setCellValue(agent.getActive_service_avg());
80 | cell.setCellStyle(styles.get("numeric"));
81 | }
82 |
83 | cell = row.getCell(colIdx++);
84 | if (agent.getActive_service_max() != null) {
85 | cell.setCellValue(agent.getActive_service_max());
86 | cell.setCellStyle(styles.get("numeric"));
87 | }
88 |
89 | cell = row.getCell(colIdx++);
90 | if (agent.getHeap_total() != null) {
91 | cell.setCellValue(agent.getHeap_total());
92 | cell.setCellStyle(styles.get("numeric2"));
93 | }
94 |
95 | cell = row.getCell(colIdx++);
96 | if (agent.getHeap_used_avg() != null) {
97 | cell.setCellValue(agent.getHeap_used_avg());
98 | cell.setCellStyle(styles.get("numeric2"));
99 | }
100 |
101 | cell = row.getCell(colIdx++);
102 | if (agent.getHeap_used_max() != null) {
103 | cell.setCellValue(agent.getHeap_used_max());
104 | cell.setCellStyle(styles.get("numeric2"));
105 | }
106 |
107 | cell = row.getCell(colIdx++);
108 | if (agent.getRecent_user_avg() != null) {
109 | cell.setCellValue(agent.getRecent_user_avg());
110 | cell.setCellStyle(styles.get("numeric"));
111 | }
112 |
113 | cell = row.getCell(colIdx++);
114 | if (agent.getRecent_user_max() != null) {
115 | cell.setCellValue(agent.getRecent_user_max());
116 | cell.setCellStyle(styles.get("numeric"));
117 | }
118 |
119 | cell = row.getCell(colIdx++);
120 | if (agent.getService_count_avg() != null) {
121 | cell.setCellValue(agent.getService_count_avg());
122 | cell.setCellStyle(styles.get("numeric"));
123 | }
124 |
125 | cell = row.getCell(colIdx++);
126 | if (agent.getService_count_max() != null) {
127 | cell.setCellValue(agent.getService_count_max());
128 | cell.setCellStyle(styles.get("numeric"));
129 | }
130 |
131 | cell = row.getCell(colIdx++);
132 | if (agent.getApi_tps_avg() != null) {
133 | cell.setCellValue(agent.getApi_tps_avg());
134 | cell.setCellStyle(styles.get("numeric2"));
135 | }
136 |
137 | cell = row.getCell(colIdx++);
138 | if (agent.getApi_tps_max() != null) {
139 | cell.setCellValue(agent.getApi_tps_max());
140 | cell.setCellStyle(styles.get("numeric2"));
141 | }
142 |
143 | cell = row.getCell(colIdx++);
144 | if (agent.getSql_tps_avg() != null) {
145 | cell.setCellValue(agent.getSql_tps_avg());
146 | cell.setCellStyle(styles.get("numeric2"));
147 | }
148 |
149 | cell = row.getCell(colIdx++);
150 | if (agent.getSql_tps_max() != null) {
151 | cell.setCellValue(agent.getSql_tps_max());
152 | cell.setCellStyle(styles.get("numeric2"));
153 | }
154 |
155 | cell = row.getCell(colIdx++);
156 | if (agent.getTps_avg() != null) {
157 | cell.setCellValue(agent.getTps_avg());
158 | cell.setCellStyle(styles.get("numeric2"));
159 | }
160 |
161 | cell = row.getCell(colIdx++);
162 | if (agent.getTps_max() != null) {
163 | cell.setCellValue(agent.getTps_max());
164 | cell.setCellStyle(styles.get("numeric2"));
165 | }
166 | }
167 |
168 | XSSFDrawing drawing = sheet.getDrawingPatriarch();
169 | List chartList = drawing.getCharts();
170 | for (XSSFChart chart : chartList) {
171 | CTLineChart[] lineChartList = chart.getCTChart().getPlotArea().getLineChartArray();
172 | for (CTLineChart c : lineChartList) {
173 | CTLineSer[] seriesList = c.getSerArray();
174 | for (CTLineSer ser : seriesList) {
175 | String ref = ser.getTx().getStrRef().getF();
176 | ser.getTx().getStrRef().setF(ref.replaceAll("'" + sheetName + "'", "'" + name + "'"));
177 | ref = ser.getCat().getStrRef().getF();
178 | ser.getCat().getStrRef().setF(ref.replaceAll("'" + sheetName + "'", "'" + name + "'"));
179 | ref = ser.getVal().getNumRef().getF();
180 | ser.getVal().getNumRef().setF(ref.replaceAll("'" + sheetName + "'", "'" + name + "'"));
181 | }
182 | }
183 | }
184 | }
185 | }
186 | }
187 |
188 | int totalCnt = workbook.getNumberOfSheets();
189 | for (int i = sheetCnt; i < totalCnt; i++) {
190 | workbook.removeSheetAt(sheetCnt);
191 | }
192 |
193 | String dir = conf.getValue("ext_plugin_reporting_output_dir", DEFAULT_DIR);
194 |
195 | if (!dir.endsWith(File.separator)) {
196 | dir = dir + File.separator;
197 | }
198 |
199 | dir = dir + year + File.separator;
200 | dir = dir + (month < 10 ? "0" + month : month) + File.separator;
201 | dir = dir + (date < 10 ? "0" + date : date) + File.separator;
202 |
203 | File file = new File(dir + "java_" + day + ".xlsx");
204 | file.getParentFile().mkdirs();
205 |
206 | FileOutputStream fileOut = new FileOutputStream(file);
207 | workbook.write(fileOut);
208 | workbook.close();
209 | fileOut.close();
210 | }
211 |
212 | @Override
213 | public void createExcel(int year, int month) throws Exception {
214 | XSSFWorkbook workbook = new XSSFWorkbook(JavaReport.class.getResourceAsStream("/excel/java_daily_template.xlsx"));
215 | XSSFSheet sheet = null;
216 | XSSFRow row = null;
217 | XSSFCell cell = null;
218 |
219 | String day = year + "." + (month < 10 ? "0" + month : month);
220 |
221 | createStyles(workbook);
222 |
223 | ScouterService service = new ScouterService();
224 | List agentInfoList = service.getAgentInfoList();
225 |
226 | AgentInfo agentInfo = null;
227 |
228 | int sheetCnt = 0;
229 | String sheetName = null;
230 | int rowIdx = 0;
231 | int colIdx = 0;
232 | List agentList = null;
233 | for (int i = 0; i < agentInfoList.size(); i++) {
234 | agentInfo = agentInfoList.get(i);
235 |
236 | if (agentInfo.getObject_family().equals("javaee") || agentInfo.getObject_family().equals("java")) {
237 | agentList = service.getJavaDailyStat(year, month, agentInfo.getObject_hash());
238 |
239 | if (agentList != null && !agentList.isEmpty()) {
240 | String name = agentList.get(0).getObject_name();
241 |
242 | if (name.indexOf("/") > -1) {
243 | name = name.substring(name.lastIndexOf("/") + 1);
244 | }
245 |
246 | sheet = workbook.getSheetAt(sheetCnt);
247 | sheetName = sheet.getSheetName();
248 | workbook.setSheetName(sheetCnt++, name);
249 |
250 | int diff = (31 - agentList.size());
251 |
252 | rowIdx = 1;
253 | for (JavaAgent agent : agentList) {
254 | if (rowIdx == 3) {
255 | if (diff > 0) {
256 | sheet.removeMergedRegion(0);
257 | sheet.addMergedRegion(new CellRangeAddress(1, agentList.size(), 0, 0));
258 | RegionUtil.setBorderBottom(1, new CellRangeAddress(1, agentList.size(), 0, 0), sheet, workbook);
259 | }
260 | }
261 |
262 | colIdx = 1;
263 | row = sheet.getRow(rowIdx++);
264 |
265 | if (rowIdx == 2) {
266 | cell = row.getCell(0);
267 | cell.setCellValue(agentList.get(0).getObject_name());
268 | cell.setCellStyle(styles.get("text"));
269 | }
270 |
271 | cell = row.getCell(colIdx++);
272 | cell.setCellValue(agent.getDay().replaceAll("-", "."));
273 | cell.setCellStyle(styles.get("date"));
274 |
275 | cell = row.getCell(colIdx++);
276 | if (agent.getActive_service_avg() != null) {
277 | cell.setCellValue(agent.getActive_service_avg());
278 | cell.setCellStyle(styles.get("numeric"));
279 | }
280 |
281 | cell = row.getCell(colIdx++);
282 | if (agent.getActive_service_max() != null) {
283 | cell.setCellValue(agent.getActive_service_max());
284 | cell.setCellStyle(styles.get("numeric"));
285 | }
286 |
287 | cell = row.getCell(colIdx++);
288 | if (agent.getHeap_total() != null) {
289 | cell.setCellValue(agent.getHeap_total());
290 | cell.setCellStyle(styles.get("numeric2"));
291 | }
292 |
293 | cell = row.getCell(colIdx++);
294 | if (agent.getHeap_used_avg() != null) {
295 | cell.setCellValue(agent.getHeap_used_avg());
296 | cell.setCellStyle(styles.get("numeric2"));
297 | }
298 |
299 | cell = row.getCell(colIdx++);
300 | if (agent.getHeap_used_max() != null) {
301 | cell.setCellValue(agent.getHeap_used_max());
302 | cell.setCellStyle(styles.get("numeric2"));
303 | }
304 |
305 | cell = row.getCell(colIdx++);
306 | if (agent.getRecent_user_avg() != null) {
307 | cell.setCellValue(agent.getRecent_user_avg());
308 | cell.setCellStyle(styles.get("numeric"));
309 | }
310 |
311 | cell = row.getCell(colIdx++);
312 | if (agent.getRecent_user_max() != null) {
313 | cell.setCellValue(agent.getRecent_user_max());
314 | cell.setCellStyle(styles.get("numeric"));
315 | }
316 |
317 | cell = row.getCell(colIdx++);
318 | if (agent.getService_count_avg() != null) {
319 | cell.setCellValue(agent.getService_count_avg());
320 | cell.setCellStyle(styles.get("numeric"));
321 | }
322 |
323 | cell = row.getCell(colIdx++);
324 | if (agent.getService_count_max() != null) {
325 | cell.setCellValue(agent.getService_count_max());
326 | cell.setCellStyle(styles.get("numeric"));
327 | }
328 |
329 | cell = row.getCell(colIdx++);
330 | if (agent.getApi_tps_avg() != null) {
331 | cell.setCellValue(agent.getApi_tps_avg());
332 | cell.setCellStyle(styles.get("numeric2"));
333 | }
334 |
335 | cell = row.getCell(colIdx++);
336 | if (agent.getApi_tps_max() != null) {
337 | cell.setCellValue(agent.getApi_tps_max());
338 | cell.setCellStyle(styles.get("numeric2"));
339 | }
340 |
341 | cell = row.getCell(colIdx++);
342 | if (agent.getSql_tps_avg() != null) {
343 | cell.setCellValue(agent.getSql_tps_avg());
344 | cell.setCellStyle(styles.get("numeric2"));
345 | }
346 |
347 | cell = row.getCell(colIdx++);
348 | if (agent.getSql_tps_max() != null) {
349 | cell.setCellValue(agent.getSql_tps_max());
350 | cell.setCellStyle(styles.get("numeric2"));
351 | }
352 |
353 | cell = row.getCell(colIdx++);
354 | if (agent.getTps_avg() != null) {
355 | cell.setCellValue(agent.getTps_avg());
356 | cell.setCellStyle(styles.get("numeric2"));
357 | }
358 |
359 | cell = row.getCell(colIdx++);
360 | if (agent.getTps_max() != null) {
361 | cell.setCellValue(agent.getTps_max());
362 | cell.setCellStyle(styles.get("numeric2"));
363 | }
364 | }
365 |
366 | if (diff > 0) {
367 | for (int r = 0; r < diff; r++) {
368 | row = sheet.getRow(rowIdx++);
369 | sheet.removeRow(row);
370 | }
371 | }
372 |
373 | XSSFDrawing drawing = sheet.getDrawingPatriarch();
374 | List chartList = drawing.getCharts();
375 | for (XSSFChart chart : chartList) {
376 | CTLineChart[] lineChartList = chart.getCTChart().getPlotArea().getLineChartArray();
377 | for (CTLineChart c : lineChartList) {
378 | CTLineSer[] seriesList = c.getSerArray();
379 | for (CTLineSer ser : seriesList) {
380 | String ref = ser.getTx().getStrRef().getF().replaceAll("'" + sheetName + "'", "'" + name + "'");
381 |
382 | if (diff > 0) {
383 | ref = ref.replaceAll("32", Integer.toString(32 - diff));
384 | }
385 | ser.getTx().getStrRef().setF(ref);
386 |
387 | ref = ser.getCat().getNumRef().getF().replaceAll("'" + sheetName + "'", "'" + name + "'");
388 |
389 | if (diff > 0) {
390 | ref = ref.replaceAll("32", Integer.toString(32 - diff));
391 | }
392 | ser.getCat().getNumRef().setF(ref);
393 |
394 |
395 | ref = ser.getVal().getNumRef().getF().replaceAll("'" + sheetName + "'", "'" + name + "'");
396 |
397 | if (diff > 0) {
398 | ref = ref.replaceAll("32", Integer.toString(32 - diff));
399 | }
400 | ser.getVal().getNumRef().setF(ref);
401 | }
402 | }
403 | }
404 | }
405 | }
406 | }
407 |
408 | int totalCnt = workbook.getNumberOfSheets();
409 | for (int i = sheetCnt; i < totalCnt; i++) {
410 | workbook.removeSheetAt(sheetCnt);
411 | }
412 |
413 | String dir = conf.getValue("ext_plugin_reporting_output_dir", DEFAULT_DIR);
414 |
415 | if (!dir.endsWith(File.separator)) {
416 | dir = dir + File.separator;
417 | }
418 |
419 | dir = dir + year + File.separator;
420 | dir = dir + (month < 10 ? "0" + month : month) + File.separator;
421 |
422 | File file = new File(dir + "java_" + day + ".xlsx");
423 | file.getParentFile().mkdirs();
424 |
425 | FileOutputStream fileOut = new FileOutputStream(file);
426 | workbook.write(fileOut);
427 | workbook.close();
428 | fileOut.close();
429 | }
430 | }
431 |
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/report/ServiceReport.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.report;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.util.ArrayList;
6 | import java.util.HashMap;
7 | import java.util.LinkedHashMap;
8 | import java.util.List;
9 | import java.util.Map;
10 |
11 | import org.apache.poi.ss.util.CellRangeAddress;
12 | import org.apache.poi.ss.util.RegionUtil;
13 | import org.apache.poi.xssf.usermodel.XSSFCell;
14 | import org.apache.poi.xssf.usermodel.XSSFChart;
15 | import org.apache.poi.xssf.usermodel.XSSFDrawing;
16 | import org.apache.poi.xssf.usermodel.XSSFHyperlink;
17 | import org.apache.poi.xssf.usermodel.XSSFRow;
18 | import org.apache.poi.xssf.usermodel.XSSFSheet;
19 | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
20 | import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart;
21 | import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineSer;
22 |
23 | import scouter.plugin.server.reporting.service.ScouterService;
24 | import scouter.plugin.server.reporting.vo.Service;
25 | import scouter.util.Hexa32;
26 |
27 | public class ServiceReport extends AbstractReport {
28 |
29 | @Override
30 | public void createExcel(int year, int month, int date) throws Exception {
31 | XSSFWorkbook workbook = new XSSFWorkbook(ServiceReport.class.getResourceAsStream("/excel/service_hourly_template.xlsx"));
32 | XSSFSheet sheet = null;
33 | XSSFRow row = null;
34 | XSSFCell cell = null;
35 |
36 | String day = year + "." + (month < 10 ? "0" + month : month) + "." + (date < 10 ? "0" + date : date);
37 |
38 | createStyles(workbook);
39 |
40 | int sheetCnt = 0;
41 | String sheetName = null;
42 | int rowIdx = 0;
43 | int colIdx = 0;
44 |
45 | ScouterService scouterService = new ScouterService();
46 | List serviceSummaryList = scouterService.getServiceDaySummary(year, month, date);
47 |
48 | Map> serviceMap = new LinkedHashMap>();
49 |
50 | sheet = workbook.getSheetAt(sheetCnt++);
51 | rowIdx = 1;
52 | for (Service service : serviceSummaryList) {
53 | if (rowIdx <= 30) {
54 | serviceMap.put(service.getApp_id() + "-" + Hexa32.toString32(service.getService_hash()), new ArrayList());
55 | }
56 |
57 | row = sheet.createRow(rowIdx++);
58 | colIdx = 0;
59 |
60 | cell = row.createCell(colIdx++);
61 | cell.setCellValue(service.getDay().replaceAll("-", "."));
62 | cell.setCellStyle(styles.get("date"));
63 |
64 | if (rowIdx == serviceSummaryList.size()) {
65 | sheet.addMergedRegion(new CellRangeAddress(1, serviceSummaryList.size(), 0, 0));
66 | RegionUtil.setBorderBottom(1, new CellRangeAddress(1, serviceSummaryList.size(), 0, 0), sheet, workbook);
67 | }
68 |
69 | cell = row.createCell(colIdx++);
70 | if (service.getApp_id() != null) {
71 | cell.setCellValue(service.getApp_id());
72 | cell.setCellStyle(styles.get("text"));
73 | }
74 |
75 | cell = row.createCell(colIdx++);
76 | cell.setCellValue(service.getService_name());
77 |
78 | if (rowIdx <= 31) {
79 | String name = service.getApp_id() + "-" + Hexa32.toString32(service.getService_hash());
80 |
81 | XSSFHyperlink link = workbook.getCreationHelper().createHyperlink(XSSFHyperlink.LINK_DOCUMENT);
82 | link.setAddress("'" + name + "'!A1");
83 | cell.setHyperlink(link);
84 | cell.setCellStyle(styles.get("link"));
85 | } else {
86 | cell.setCellStyle(styles.get("text"));
87 | }
88 |
89 | cell = row.createCell(colIdx++);
90 | if (service.getElapsed_avg() != null) {
91 | cell.setCellValue(service.getElapsed_avg());
92 | cell.setCellStyle(styles.get("numeric"));
93 | }
94 |
95 | cell = row.createCell(colIdx++);
96 | if (service.getElapsed_max() != null) {
97 | cell.setCellValue(service.getElapsed_max());
98 | cell.setCellStyle(styles.get("numeric"));
99 | }
100 |
101 | cell = row.createCell(colIdx++);
102 | if (service.getSql_count_avg() != null) {
103 | cell.setCellValue(service.getSql_count_avg());
104 | cell.setCellStyle(styles.get("numeric"));
105 | }
106 |
107 | cell = row.createCell(colIdx++);
108 | if (service.getSql_count_max() != null) {
109 | cell.setCellValue(service.getSql_count_max());
110 | cell.setCellStyle(styles.get("numeric"));
111 | }
112 |
113 | cell = row.createCell(colIdx++);
114 | if (service.getSql_time_avg() != null) {
115 | cell.setCellValue(service.getSql_time_avg());
116 | cell.setCellStyle(styles.get("numeric"));
117 | }
118 |
119 | cell = row.createCell(colIdx++);
120 | if (service.getSql_time_max() != null) {
121 | cell.setCellValue(service.getSql_time_max());
122 | cell.setCellStyle(styles.get("numeric"));
123 | }
124 |
125 | cell = row.createCell(colIdx++);
126 | if (service.getRequest_count() != null) {
127 | cell.setCellValue(service.getRequest_count());
128 | cell.setCellStyle(styles.get("numeric"));
129 | }
130 |
131 | cell = row.createCell(colIdx++);
132 | if (service.getError_count() != null) {
133 | cell.setCellValue(service.getError_count());
134 | cell.setCellStyle(styles.get("numeric"));
135 | }
136 |
137 | cell = row.createCell(colIdx++);
138 | if (service.getElapsed_exceed_count() != null) {
139 | cell.setCellValue(service.getElapsed_exceed_count());
140 | cell.setCellStyle(styles.get("numeric"));
141 | }
142 | }
143 |
144 | List serviceList = null;
145 |
146 | for (String key : serviceMap.keySet()) {
147 | serviceList = scouterService.getServiceHourlyStat(year, month, date, key.split("-")[0], Hexa32.toLong32(key.split("-")[1]));
148 |
149 | String name = key;
150 |
151 | sheet = workbook.getSheetAt(sheetCnt);
152 | sheetName = sheet.getSheetName();
153 | workbook.setSheetName(sheetCnt++, name);
154 |
155 | // remove IP_ADDRESS_GROUP, USER_AGENT_GROUP
156 | row = sheet.getRow(0);
157 | row.removeCell(row.getCell(11));
158 | row.removeCell(row.getCell(12));
159 |
160 | rowIdx = 1;
161 | for (Service service : serviceList) {
162 | colIdx = 2;
163 | row = sheet.getRow(rowIdx++);
164 |
165 | if (rowIdx == 2) {
166 | cell = row.getCell(0);
167 | cell.setCellValue("[" + service.getApp_id() + "]\n" + service.getService_name());
168 | cell.setCellStyle(styles.get("text"));
169 | }
170 |
171 | cell = row.getCell(colIdx++);
172 | if (service.getElapsed_avg() != null) {
173 | cell.setCellValue(service.getElapsed_avg());
174 | cell.setCellStyle(styles.get("numeric"));
175 | }
176 |
177 | cell = row.getCell(colIdx++);
178 | if (service.getElapsed_max() != null) {
179 | cell.setCellValue(service.getElapsed_max());
180 | cell.setCellStyle(styles.get("numeric"));
181 | }
182 |
183 | cell = row.getCell(colIdx++);
184 | if (service.getSql_count_avg() != null) {
185 | cell.setCellValue(service.getSql_count_avg());
186 | cell.setCellStyle(styles.get("numeric"));
187 | }
188 |
189 | cell = row.getCell(colIdx++);
190 | if (service.getSql_count_max() != null) {
191 | cell.setCellValue(service.getSql_count_max());
192 | cell.setCellStyle(styles.get("numeric"));
193 | }
194 |
195 | cell = row.getCell(colIdx++);
196 | if (service.getSql_time_avg() != null) {
197 | cell.setCellValue(service.getSql_time_avg());
198 | cell.setCellStyle(styles.get("numeric"));
199 | }
200 |
201 | cell = row.getCell(colIdx++);
202 | if (service.getSql_time_max() != null) {
203 | cell.setCellValue(service.getSql_time_max());
204 | cell.setCellStyle(styles.get("numeric"));
205 | }
206 |
207 | cell = row.getCell(colIdx++);
208 | if (service.getRequest_count() != null) {
209 | cell.setCellValue(service.getRequest_count());
210 | cell.setCellStyle(styles.get("numeric"));
211 | }
212 |
213 | cell = row.getCell(colIdx++);
214 | if (service.getError_count() != null) {
215 | cell.setCellValue(service.getError_count());
216 | cell.setCellStyle(styles.get("numeric"));
217 | }
218 |
219 | cell = row.getCell(colIdx++);
220 | if (service.getElapsed_exceed_count() != null) {
221 | cell.setCellValue(service.getElapsed_exceed_count());
222 | cell.setCellStyle(styles.get("numeric"));
223 | }
224 |
225 | cell = row.getCell(colIdx++);
226 | /*
227 | if (service.getIp_count() != null && service.getIp_count() != 0) {
228 | cell.setCellValue(service.getIp_count());
229 | cell.setCellStyle(styles.get("numeric"));
230 | }
231 | */
232 | row.removeCell(cell);
233 |
234 | cell = row.getCell(colIdx++);
235 | /*
236 | if (service.getUa_count() != null && service.getUa_count() != 0) {
237 | cell.setCellValue(service.getUa_count());
238 | cell.setCellStyle(styles.get("numeric"));
239 | }
240 | */
241 | row.removeCell(cell);
242 | }
243 |
244 | XSSFDrawing drawing = sheet.getDrawingPatriarch();
245 | List chartList = drawing.getCharts();
246 | for (XSSFChart chart : chartList) {
247 | CTLineChart[] lineChartList = chart.getCTChart().getPlotArea().getLineChartArray();
248 | for (CTLineChart c : lineChartList) {
249 | CTLineSer[] seriesList = c.getSerArray();
250 | for (CTLineSer ser : seriesList) {
251 | String ref = ser.getTx().getStrRef().getF();
252 | ser.getTx().getStrRef().setF(ref.replaceAll("'" + sheetName + "'", "'" + name + "'"));
253 | ref = ser.getCat().getStrRef().getF();
254 | ser.getCat().getStrRef().setF(ref.replaceAll("'" + sheetName + "'", "'" + name + "'"));
255 | ref = ser.getVal().getNumRef().getF();
256 | ser.getVal().getNumRef().setF(ref.replaceAll("'" + sheetName + "'", "'" + name + "'"));
257 | }
258 | }
259 | }
260 | }
261 |
262 | int totalCnt = workbook.getNumberOfSheets();
263 | for (int i = sheetCnt; i < totalCnt; i++) {
264 | workbook.removeSheetAt(sheetCnt);
265 | }
266 |
267 | String dir = conf.getValue("ext_plugin_reporting_output_dir", DEFAULT_DIR);
268 |
269 | if (!dir.endsWith(File.separator)) {
270 | dir = dir + File.separator;
271 | }
272 |
273 | dir = dir + year + File.separator;
274 | dir = dir + (month < 10 ? "0" + month : month) + File.separator;
275 | dir = dir + (date < 10 ? "0" + date : date) + File.separator;
276 |
277 | File file = new File(dir + "service_" + day + ".xlsx");
278 | file.getParentFile().mkdirs();
279 |
280 | FileOutputStream fileOut = new FileOutputStream(file);
281 | workbook.write(fileOut);
282 | workbook.close();
283 | fileOut.close();
284 | }
285 |
286 | @Override
287 | public void createExcel(int year, int month) throws Exception {
288 | XSSFWorkbook workbook = new XSSFWorkbook(ServiceReport.class.getResourceAsStream("/excel/service_daily_template.xlsx"));
289 | XSSFSheet sheet = null;
290 | XSSFRow row = null;
291 | XSSFCell cell = null;
292 |
293 | String day = year + "." + (month < 10 ? "0" + month : month);
294 |
295 | createStyles(workbook);
296 |
297 | int sheetCnt = 0;
298 | String sheetName = null;
299 | int rowIdx = 0;
300 | int colIdx = 0;
301 |
302 | ScouterService scouterService = new ScouterService();
303 | List serviceSummaryList = scouterService.getServiceMonthSummary(year, month);
304 |
305 | Map> serviceMap = new LinkedHashMap>();
306 |
307 | Map keyMap = new HashMap();
308 |
309 | sheet = workbook.getSheetAt(sheetCnt++);
310 | rowIdx = 1;
311 | for (Service service : serviceSummaryList) {
312 | if (rowIdx <= 30) {
313 | serviceMap.put(service.getApp_id() + "-" + Hexa32.toString32(service.getService_hash()), new ArrayList());
314 | keyMap.put(service.getApp_id() + "-" + Hexa32.toString32(service.getService_hash()), "[" + service.getApp_id() + "]\n" + service.getService_name());
315 | }
316 |
317 | row = sheet.createRow(rowIdx++);
318 | colIdx = 0;
319 |
320 | cell = row.createCell(colIdx++);
321 | cell.setCellValue(service.getDay().replaceAll("-", "."));
322 | cell.setCellStyle(styles.get("date"));
323 |
324 | if (rowIdx == serviceSummaryList.size()) {
325 | sheet.addMergedRegion(new CellRangeAddress(1, serviceSummaryList.size(), 0, 0));
326 | RegionUtil.setBorderBottom(1, new CellRangeAddress(1, serviceSummaryList.size(), 0, 0), sheet, workbook);
327 | }
328 |
329 | cell = row.createCell(colIdx++);
330 | if (service.getApp_id() != null) {
331 | cell.setCellValue(service.getApp_id());
332 | cell.setCellStyle(styles.get("text"));
333 | }
334 |
335 | cell = row.createCell(colIdx++);
336 | cell.setCellValue(service.getService_name());
337 |
338 | if (rowIdx <= 31) {
339 | String name = service.getApp_id() + "-" + Hexa32.toString32(service.getService_hash());
340 |
341 | XSSFHyperlink link = workbook.getCreationHelper().createHyperlink(XSSFHyperlink.LINK_DOCUMENT);
342 | link.setAddress("'" + name + "'!A1");
343 | cell.setHyperlink(link);
344 | cell.setCellStyle(styles.get("link"));
345 | } else {
346 | cell.setCellStyle(styles.get("text"));
347 | }
348 |
349 | cell = row.createCell(colIdx++);
350 | if (service.getElapsed_avg() != null) {
351 | cell.setCellValue(service.getElapsed_avg());
352 | cell.setCellStyle(styles.get("numeric"));
353 | }
354 |
355 | cell = row.createCell(colIdx++);
356 | if (service.getElapsed_max() != null) {
357 | cell.setCellValue(service.getElapsed_max());
358 | cell.setCellStyle(styles.get("numeric"));
359 | }
360 |
361 | cell = row.createCell(colIdx++);
362 | if (service.getSql_count_avg() != null) {
363 | cell.setCellValue(service.getSql_count_avg());
364 | cell.setCellStyle(styles.get("numeric"));
365 | }
366 |
367 | cell = row.createCell(colIdx++);
368 | if (service.getSql_count_max() != null) {
369 | cell.setCellValue(service.getSql_count_max());
370 | cell.setCellStyle(styles.get("numeric"));
371 | }
372 |
373 | cell = row.createCell(colIdx++);
374 | if (service.getSql_time_avg() != null) {
375 | cell.setCellValue(service.getSql_time_avg());
376 | cell.setCellStyle(styles.get("numeric"));
377 | }
378 |
379 | cell = row.createCell(colIdx++);
380 | if (service.getSql_time_max() != null) {
381 | cell.setCellValue(service.getSql_time_max());
382 | cell.setCellStyle(styles.get("numeric"));
383 | }
384 |
385 | cell = row.createCell(colIdx++);
386 | if (service.getRequest_count() != null) {
387 | cell.setCellValue(service.getRequest_count());
388 | cell.setCellStyle(styles.get("numeric"));
389 | }
390 |
391 | cell = row.createCell(colIdx++);
392 | if (service.getError_count() != null) {
393 | cell.setCellValue(service.getError_count());
394 | cell.setCellStyle(styles.get("numeric"));
395 | }
396 |
397 | cell = row.createCell(colIdx++);
398 | if (service.getElapsed_exceed_count() != null) {
399 | cell.setCellValue(service.getElapsed_exceed_count());
400 | cell.setCellStyle(styles.get("numeric"));
401 | }
402 | }
403 |
404 | Map> resultMap = scouterService.getServiceDailyStat(year, month);
405 |
406 | List serviceList = null;
407 |
408 | for (String key : serviceMap.keySet()) {
409 | for (String idx : resultMap.keySet()) {
410 | serviceList = resultMap.get(idx);
411 |
412 | boolean exist = false;
413 | for (Service service : serviceList) {
414 | if (service.getService_hash() != null && key.equals(service.getApp_id() + "-" + Hexa32.toString32(service.getService_hash()))) {
415 | exist = true;
416 | serviceMap.get(key).add(service);
417 | }
418 | }
419 |
420 | if (!exist) {
421 | Service s = new Service();
422 | s.setDay(idx);
423 | s.setService_name(keyMap.get(key));
424 | serviceMap.get(key).add(s);
425 | }
426 | }
427 | }
428 |
429 | for (String key : serviceMap.keySet()) {
430 | serviceList = serviceMap.get(key);
431 |
432 | String name = key;
433 |
434 | sheet = workbook.getSheetAt(sheetCnt);
435 | sheetName = sheet.getSheetName();
436 | workbook.setSheetName(sheetCnt++, name);
437 |
438 | int diff = (31 - serviceList.size());
439 |
440 | // remove IP_ADDRESS_GROUP, USER_AGENT_GROUP
441 | row = sheet.getRow(0);
442 | row.removeCell(row.getCell(11));
443 | row.removeCell(row.getCell(12));
444 |
445 | rowIdx = 1;
446 | for (Service service : serviceList) {
447 | if (rowIdx == 3) {
448 | if (diff > 0) {
449 | sheet.removeMergedRegion(0);
450 | sheet.addMergedRegion(new CellRangeAddress(1, serviceList.size(), 0, 0));
451 | RegionUtil.setBorderBottom(1, new CellRangeAddress(1, serviceList.size(), 0, 0), sheet, workbook);
452 | }
453 | }
454 |
455 | colIdx = 1;
456 | row = sheet.getRow(rowIdx++);
457 |
458 | if (rowIdx == 2) {
459 | cell = row.getCell(0);
460 | cell.setCellValue(service.getService_name());
461 | cell.setCellStyle(styles.get("text"));
462 | }
463 |
464 | cell = row.getCell(colIdx++);
465 | cell.setCellValue(service.getDay().replaceAll("-", "."));
466 | cell.setCellStyle(styles.get("date"));
467 |
468 | cell = row.getCell(colIdx++);
469 | if (service.getElapsed_avg() != null) {
470 | cell.setCellValue(service.getElapsed_avg());
471 | }
472 | cell.setCellStyle(styles.get("numeric"));
473 |
474 | cell = row.getCell(colIdx++);
475 | if (service.getElapsed_max() != null) {
476 | cell.setCellValue(service.getElapsed_max());
477 | }
478 | cell.setCellStyle(styles.get("numeric"));
479 |
480 | cell = row.getCell(colIdx++);
481 | if (service.getSql_count_avg() != null) {
482 | cell.setCellValue(service.getSql_count_avg());
483 | }
484 | cell.setCellStyle(styles.get("numeric"));
485 |
486 | cell = row.getCell(colIdx++);
487 | if (service.getSql_count_max() != null) {
488 | cell.setCellValue(service.getSql_count_max());
489 | }
490 | cell.setCellStyle(styles.get("numeric"));
491 |
492 | cell = row.getCell(colIdx++);
493 | if (service.getSql_time_avg() != null) {
494 | cell.setCellValue(service.getSql_time_avg());
495 | }
496 | cell.setCellStyle(styles.get("numeric"));
497 |
498 | cell = row.getCell(colIdx++);
499 | if (service.getSql_time_max() != null) {
500 | cell.setCellValue(service.getSql_time_max());
501 | }
502 | cell.setCellStyle(styles.get("numeric"));
503 |
504 | cell = row.getCell(colIdx++);
505 | if (service.getRequest_count() != null) {
506 | cell.setCellValue(service.getRequest_count());
507 | }
508 | cell.setCellStyle(styles.get("numeric"));
509 |
510 | cell = row.getCell(colIdx++);
511 | if (service.getError_count() != null) {
512 | cell.setCellValue(service.getError_count());
513 | }
514 | cell.setCellStyle(styles.get("numeric"));
515 |
516 | cell = row.getCell(colIdx++);
517 | if (service.getElapsed_exceed_count() != null) {
518 | cell.setCellValue(service.getElapsed_exceed_count());
519 | }
520 | cell.setCellStyle(styles.get("numeric"));
521 |
522 | cell = row.getCell(colIdx++);
523 | /*
524 | if (service.getIp_count() != null) {
525 | cell.setCellValue(service.getIp_count());
526 | }
527 | cell.setCellStyle(styles.get("numeric"));
528 | */
529 | row.removeCell(cell);
530 |
531 | cell = row.getCell(colIdx++);
532 | /*
533 | if (service.getUa_count() != null) {
534 | cell.setCellValue(service.getUa_count());
535 | }
536 | cell.setCellStyle(styles.get("numeric"));
537 | */
538 | row.removeCell(cell);
539 | }
540 |
541 | if (diff > 0) {
542 | for (int r = 0; r < diff; r++) {
543 | row = sheet.getRow(rowIdx++);
544 | sheet.removeRow(row);
545 | }
546 | }
547 |
548 | XSSFDrawing drawing = sheet.getDrawingPatriarch();
549 | List chartList = drawing.getCharts();
550 | for (XSSFChart chart : chartList) {
551 | CTLineChart[] lineChartList = chart.getCTChart().getPlotArea().getLineChartArray();
552 | for (CTLineChart c : lineChartList) {
553 | CTLineSer[] seriesList = c.getSerArray();
554 | for (CTLineSer ser : seriesList) {
555 | String ref = ser.getTx().getStrRef().getF().replaceAll("'" + sheetName + "'", "'" + name + "'");
556 |
557 | if (diff > 0) {
558 | ref = ref.replaceAll("32", Integer.toString(32 - diff));
559 | }
560 | ser.getTx().getStrRef().setF(ref);
561 |
562 | ref = ser.getCat().getNumRef().getF().replaceAll("'" + sheetName + "'", "'" + name + "'");
563 |
564 | if (diff > 0) {
565 | ref = ref.replaceAll("32", Integer.toString(32 - diff));
566 | }
567 | ser.getCat().getNumRef().setF(ref);
568 |
569 | ref = ser.getVal().getNumRef().getF().replaceAll("'" + sheetName + "'", "'" + name + "'");
570 |
571 | if (diff > 0) {
572 | ref = ref.replaceAll("32", Integer.toString(32 - diff));
573 | }
574 | ser.getVal().getNumRef().setF(ref);
575 | }
576 | }
577 | }
578 | }
579 |
580 | int totalCnt = workbook.getNumberOfSheets();
581 | for (int i = sheetCnt; i < totalCnt; i++) {
582 | workbook.removeSheetAt(sheetCnt);
583 | }
584 |
585 | String dir = conf.getValue("ext_plugin_reporting_output_dir", DEFAULT_DIR);
586 |
587 | if (!dir.endsWith(File.separator)) {
588 | dir = dir + File.separator;
589 | }
590 |
591 | dir = dir + year + File.separator;
592 | dir = dir + (month < 10 ? "0" + month : month) + File.separator;
593 |
594 | File file = new File(dir + "service_" + day + ".xlsx");
595 | file.getParentFile().mkdirs();
596 |
597 | FileOutputStream fileOut = new FileOutputStream(file);
598 | workbook.write(fileOut);
599 | workbook.close();
600 | fileOut.close();
601 | }
602 | }
603 |
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/service/AbstractService.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.service;
2 |
3 | import org.apache.ibatis.session.SqlSession;
4 | import org.apache.ibatis.session.SqlSessionFactory;
5 |
6 | import scouter.plugin.server.reporting.ReportingPlugin;
7 |
8 | public abstract class AbstractService {
9 |
10 | private static SqlSessionFactory sqlSessionFactory;
11 |
12 | protected synchronized SqlSession getSession() {
13 | if (sqlSessionFactory == null) {
14 | sqlSessionFactory = ReportingPlugin.getSqlSessionFactory();
15 | }
16 |
17 | return sqlSessionFactory.openSession(true);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/service/ScouterService.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.service;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Calendar;
5 | import java.util.HashMap;
6 | import java.util.LinkedHashMap;
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | import org.apache.ibatis.session.SqlSession;
11 |
12 | import scouter.plugin.server.reporting.vo.AgentInfo;
13 | import scouter.plugin.server.reporting.vo.Alert;
14 | import scouter.plugin.server.reporting.vo.HostAgent;
15 | import scouter.plugin.server.reporting.vo.JavaAgent;
16 | import scouter.plugin.server.reporting.vo.Service;
17 |
18 | public class ScouterService extends AbstractService {
19 | private SqlSession session;
20 |
21 | public List getAgentInfoList() {
22 | session = getSession();
23 |
24 | try {
25 | return getSession().selectList("Scouter.selectAgentInfoList");
26 | } finally {
27 | if (session != null) {
28 | session.close();
29 | }
30 | }
31 | }
32 |
33 | public AgentInfo getAgentInfo(int objHash) {
34 | session = getSession();
35 |
36 | try {
37 | return getSession().selectOne("Scouter.selectAgentInfo", objHash);
38 | } finally {
39 | if (session != null) {
40 | session.close();
41 | }
42 | }
43 | }
44 |
45 | public List getHostDailyStat(int year, int month, int objHash) {
46 | List hostAgentList = new ArrayList();
47 |
48 | int date = 1;
49 | int maxDay = 0;
50 |
51 | Calendar calendar = Calendar.getInstance();
52 | calendar.set(year, month - 1, date);
53 | maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
54 |
55 | String m, d = null;
56 |
57 | if (month < 10) {
58 | m = "0" + month;
59 | } else {
60 | m = month + "";
61 | }
62 |
63 | session = getSession();
64 | try {
65 | Map param = null;
66 | for (int i = 1; i <= maxDay; i++) {
67 | param = new HashMap();
68 | param.put("object_hash", objHash);
69 | param.put("year", Integer.toString(year));
70 | param.put("month", m);
71 |
72 | if (i < 10) {
73 | d = "0" + i;
74 | } else {
75 | d = i + "";
76 | }
77 |
78 | param.put("date", d);
79 |
80 | hostAgentList.add((HostAgent) session.selectOne("Scouter.selectHostDailyStat", param));
81 | }
82 | } finally {
83 | if (session != null) {
84 | session.close();
85 | }
86 | }
87 |
88 | return hostAgentList;
89 | }
90 |
91 | public List getJavaDailyStat(int year, int month, int objHash) {
92 | List javaAgentList = new ArrayList();
93 |
94 | int date = 1;
95 | int maxDay = 0;
96 |
97 | Calendar calendar = Calendar.getInstance();
98 | calendar.set(year, month - 1, date);
99 | maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
100 |
101 | String m, d = null;
102 |
103 | if (month < 10) {
104 | m = "0" + month;
105 | } else {
106 | m = month + "";
107 | }
108 |
109 | session = getSession();
110 | try {
111 | Map param = null;
112 | for (int i = 1; i <= maxDay; i++) {
113 | param = new HashMap();
114 | param.put("object_hash", objHash);
115 | param.put("year", Integer.toString(year));
116 | param.put("month", m);
117 |
118 | if (i < 10) {
119 | d = "0" + i;
120 | } else {
121 | d = i + "";
122 | }
123 |
124 | param.put("date", d);
125 |
126 | javaAgentList.add((JavaAgent) session.selectOne("Scouter.selectJavaDailyStat", param));
127 | }
128 | } finally {
129 | if (session != null) {
130 | session.close();
131 | }
132 | }
133 |
134 | return javaAgentList;
135 | }
136 |
137 | @SuppressWarnings({ "rawtypes", "unchecked" })
138 | public Map> getServiceDailyStat(int year, int month) {
139 | Map> serviceMap = new LinkedHashMap>();
140 |
141 | int date = 1;
142 | int maxDay = 0;
143 |
144 | Calendar calendar = Calendar.getInstance();
145 | calendar.set(year, month - 1, date);
146 | maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
147 |
148 | String m, d = null;
149 |
150 | if (month < 10) {
151 | m = "0" + month;
152 | } else {
153 | m = month + "";
154 | }
155 |
156 | session = getSession();
157 | try {
158 | Map param = null;
159 | for (int i = 1; i <= maxDay; i++) {
160 | param = new HashMap();
161 | param.put("year", Integer.toString(year));
162 | param.put("month", m);
163 |
164 | if (i < 10) {
165 | d = "0" + i;
166 | } else {
167 | d = i + "";
168 | }
169 |
170 | param.put("date", d);
171 |
172 | serviceMap.put(Integer.toString(year) + "." + m + "." + d, (List) session.selectList("Scouter.selectServiceDailyStat", param));
173 | }
174 | } finally {
175 | if (session != null) {
176 | session.close();
177 | }
178 | }
179 |
180 | return serviceMap;
181 | }
182 |
183 | public List getServiceMonthSummary(int year, int month) {
184 | Map param = new HashMap();
185 | param.put("year", Integer.toString(year));
186 |
187 | if (month < 10) {
188 | param.put("month", "0" + month);
189 | } else {
190 | param.put("month", month + "");
191 | }
192 |
193 | session = getSession();
194 | try {
195 | return session.selectList("Scouter.selectServiceMonthSummary", param);
196 | } finally {
197 | if (session != null) {
198 | session.close();
199 | }
200 | }
201 | }
202 |
203 | public List getServiceDaySummary(int year, int month, int date) {
204 | Map param = new HashMap();
205 | param.put("year", Integer.toString(year));
206 |
207 | if (month < 10) {
208 | param.put("month", "0" + month);
209 | } else {
210 | param.put("month", month + "");
211 | }
212 |
213 | if (date < 10) {
214 | param.put("date", "0" + date);
215 | } else {
216 | param.put("date", date + "");
217 | }
218 |
219 | session = getSession();
220 | try {
221 | return session.selectList("Scouter.selectServiceDaySummary", param);
222 | } finally {
223 | if (session != null) {
224 | session.close();
225 | }
226 | }
227 | }
228 |
229 | public List getHostHourlyStat(int year, int month, int date, int objHash) {
230 | Map param = new HashMap();
231 | param.put("object_hash", objHash);
232 | param.put("year", Integer.toString(year));
233 | param.put("month", month);
234 | param.put("date", date < 10 ? "0" + date : date);
235 |
236 | session = getSession();
237 | try {
238 | return session.selectList("Scouter.selectHostHourlyStat", param);
239 | } finally {
240 | if (session != null) {
241 | session.close();
242 | }
243 | }
244 | }
245 |
246 | public List getJavaHourlyStat(int year, int month, int date, int objHash) {
247 | Map param = new HashMap();
248 | param.put("object_hash", objHash);
249 | param.put("year", Integer.toString(year));
250 | param.put("month", month);
251 | param.put("date", date < 10 ? "0" + date : date);
252 |
253 | session = getSession();
254 | try {
255 | return session.selectList("Scouter.selectJavaHourlyStat", param);
256 | } finally {
257 | if (session != null) {
258 | session.close();
259 | }
260 | }
261 | }
262 |
263 | public List getServiceHourlyStat(int year, int month, int date, String appId, long hash) {
264 | Map param = new HashMap();
265 | param.put("year", Integer.toString(year));
266 |
267 | if (month < 10) {
268 | param.put("month", "0" + month);
269 | } else {
270 | param.put("month", month + "");
271 | }
272 |
273 | if (date < 10) {
274 | param.put("date", "0" + date);
275 | } else {
276 | param.put("date", date + "");
277 | }
278 |
279 | param.put("app_id", appId);
280 | param.put("service_hash", hash);
281 |
282 | session = getSession();
283 | try {
284 | return session.selectList("Scouter.selectServiceHourlyStat", param);
285 | } finally {
286 | if (session != null) {
287 | session.close();
288 | }
289 | }
290 | }
291 |
292 | @SuppressWarnings({ "rawtypes", "unchecked" })
293 | public List getAlertList(int year, int month) {
294 | List alertList = new ArrayList();
295 |
296 | int date = 1;
297 | int maxDay = 0;
298 |
299 | Calendar calendar = Calendar.getInstance();
300 | calendar.set(year, month - 1, date);
301 | maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
302 |
303 | String m, d = null;
304 |
305 | if (month < 10) {
306 | m = "0" + month;
307 | } else {
308 | m = month + "";
309 | }
310 |
311 | session = getSession();
312 | try {
313 | Map param = null;
314 | for (int i = 1; i <= maxDay; i++) {
315 | param = new HashMap();
316 | param.put("year", Integer.toString(year));
317 | param.put("month", m);
318 |
319 | if (i < 10) {
320 | d = "0" + i;
321 | } else {
322 | d = i + "";
323 | }
324 |
325 | param.put("date", d);
326 |
327 | alertList.addAll((List) session.selectList("Scouter.selectAlert", param));
328 | }
329 | } finally {
330 | if (session != null) {
331 | session.close();
332 | }
333 | }
334 |
335 | return alertList;
336 | }
337 |
338 | public List getAlertList(int year, int month, int date) {
339 | Map param = new HashMap();
340 | param.put("year", Integer.toString(year));
341 |
342 | if (month < 10) {
343 | param.put("month", "0" + month);
344 | } else {
345 | param.put("month", month + "");
346 | }
347 |
348 | if (date < 10) {
349 | param.put("date", "0" + date);
350 | } else {
351 | param.put("date", date + "");
352 | }
353 |
354 | session = getSession();
355 | try {
356 | return session.selectList("Scouter.selectAlert", param);
357 | } finally {
358 | if (session != null) {
359 | session.close();
360 | }
361 | }
362 | }
363 |
364 | public List getApplicationOperationStat(int year, int month) {
365 | Map param = new HashMap();
366 | param.put("year", Integer.toString(year));
367 |
368 | if (month < 10) {
369 | param.put("month", "0" + month);
370 | } else {
371 | param.put("month", month + "");
372 | }
373 |
374 | session = getSession();
375 | try {
376 | return session.selectList("Scouter.selectApplicationOperationStat", param);
377 | } finally {
378 | if (session != null) {
379 | session.close();
380 | }
381 | }
382 | }
383 |
384 | public Service getApplicationOperationStatPrev(int year, int month, String appId, Integer hash) {
385 | Map param = new HashMap();
386 | param.put("year", Integer.toString(year));
387 |
388 | if (month < 10) {
389 | param.put("month", "0" + month);
390 | } else {
391 | param.put("month", month + "");
392 | }
393 |
394 | param.put("app_id", appId);
395 | param.put("service_hash", hash);
396 |
397 | session = getSession();
398 | try {
399 | return session.selectOne("Scouter.selectApplicationOperationStatPrev", param);
400 | } finally {
401 | if (session != null) {
402 | session.close();
403 | }
404 | }
405 | }
406 |
407 | public List getWorstApplications(int year, int month) {
408 | Map param = new HashMap();
409 | param.put("year", Integer.toString(year));
410 |
411 | if (month < 10) {
412 | param.put("month", "0" + month);
413 | } else {
414 | param.put("month", month + "");
415 | }
416 |
417 | session = getSession();
418 | try {
419 | return session.selectList("Scouter.selectWorstApplications", param);
420 | } finally {
421 | if (session != null) {
422 | session.close();
423 | }
424 | }
425 | }
426 |
427 | public static void main(String[] args) {
428 | Calendar calendar = Calendar.getInstance();
429 | System.out.println(calendar.getTime());
430 |
431 | calendar.set(2016, 1, 1);
432 |
433 | System.out.println(calendar.getTime());
434 |
435 | int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
436 |
437 | System.out.println(maxDay);
438 | }
439 | }
440 |
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/task/HostAgentTask.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.task;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.apache.ibatis.session.SqlSession;
8 | import org.apache.ibatis.session.SqlSessionFactory;
9 |
10 | import scouter.plugin.server.reporting.ReportingPlugin;
11 | import scouter.plugin.server.reporting.collector.HostAgentStat;
12 | import scouter.plugin.server.reporting.vo.HostAgent;
13 | import scouter.server.Logger;
14 |
15 | public class HostAgentTask implements Runnable {
16 |
17 | private SqlSessionFactory sqlSessionFactory;
18 | private Map hostAgentStatMap;
19 |
20 | public HostAgentTask(SqlSessionFactory sqlSessionFactory, Map hostAgentStatMap) {
21 | this.sqlSessionFactory = sqlSessionFactory;
22 | this.hostAgentStatMap = hostAgentStatMap;
23 | }
24 |
25 | @Override
26 | public void run() {
27 | SqlSession session = sqlSessionFactory.openSession(true);
28 |
29 | try {
30 | List keyList = new ArrayList(hostAgentStatMap.keySet());
31 |
32 | HostAgentStat hostAgentStat = null;
33 | HostAgent hostAgent = null;
34 |
35 | if (ReportingPlugin.conf.getBoolean("ext_plugin_reporting_logging_enabled", false)) {
36 | Logger.println("hostAgentStatMap's size : " + keyList.size());
37 | }
38 |
39 | for (Integer key : keyList) {
40 | hostAgentStat = hostAgentStatMap.get(key);
41 |
42 | if (hostAgentStat.isPurge()) {
43 | hostAgentStatMap.remove(key);
44 | } else {
45 | hostAgent = hostAgentStat.getHostAgentAndClear();
46 |
47 | if (hostAgent != null) {
48 | // long time = (System.currentTimeMillis() - 10000) / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
49 | //
50 | // if (ReportingPlugin.conf.getBoolean("ext_plugin_reporting_logging_enabled", false)) {
51 | // Logger.println(new Date(time) + ":" + hostAgent);
52 | // }
53 |
54 | try {
55 | session.insert("Scouter.insertHostAgent", hostAgent);
56 |
57 | if (ReportingPlugin.conf.getBoolean("ext_plugin_reporting_logging_enabled", false)) {
58 | Logger.println("[" + key + "] hostAgent inserted.");
59 | }
60 | } catch (Exception e) {
61 | Logger.printStackTrace(e);
62 | }
63 | }
64 | }
65 | }
66 | } catch (Exception e) {
67 | Logger.printStackTrace(e);
68 | } finally {
69 | if (session != null) {
70 | session.close();
71 | }
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/task/JavaAgentTask.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.task;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import org.apache.ibatis.session.SqlSession;
8 | import org.apache.ibatis.session.SqlSessionFactory;
9 |
10 | import scouter.plugin.server.reporting.ReportingPlugin;
11 | import scouter.plugin.server.reporting.collector.JavaAgentStat;
12 | import scouter.plugin.server.reporting.vo.JavaAgent;
13 | import scouter.server.Logger;
14 |
15 | public class JavaAgentTask implements Runnable {
16 |
17 | private SqlSessionFactory sqlSessionFactory;
18 | private Map javaAgentStatMap;
19 |
20 | public JavaAgentTask(SqlSessionFactory sqlSessionFactory, Map javaAgentStatMap) {
21 | this.sqlSessionFactory = sqlSessionFactory;
22 | this.javaAgentStatMap = javaAgentStatMap;
23 | }
24 |
25 | @Override
26 | public void run() {
27 | SqlSession session = sqlSessionFactory.openSession(true);
28 |
29 | try {
30 | List keyList = new ArrayList(javaAgentStatMap.keySet());
31 |
32 | JavaAgentStat javaAgentStat = null;
33 | JavaAgent javaAgent = null;
34 |
35 | if (ReportingPlugin.conf.getBoolean("ext_plugin_reporting_logging_enabled", false)) {
36 | Logger.println("javaAgentStatMap's size : " + keyList.size());
37 | }
38 |
39 | for (Integer key : keyList) {
40 | javaAgentStat = javaAgentStatMap.get(key);
41 |
42 | if (javaAgentStat.isPurge()) {
43 | javaAgentStatMap.remove(key);
44 | } else {
45 | javaAgent = javaAgentStat.getJavaAgentAndClear();
46 |
47 | if (javaAgent != null) {
48 | // long time = (System.currentTimeMillis() - 10000) / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
49 | //
50 | // if (ReportingPlugin.conf.getBoolean("ext_plugin_reporting_logging_enabled", false)) {
51 | // Logger.println(new Date(time) + ":" + javaAgent);
52 | // }
53 |
54 | try {
55 | session.insert("Scouter.insertJavaAgent", javaAgent);
56 |
57 | if (ReportingPlugin.conf.getBoolean("ext_plugin_reporting_logging_enabled", false)) {
58 | Logger.println("[" + key + "] javaAgent inserted.");
59 | }
60 | } catch (Exception e) {
61 | Logger.printStackTrace(e);
62 | }
63 | }
64 | }
65 | }
66 | } catch (Exception e) {
67 | Logger.printStackTrace(e);
68 | } finally {
69 | if (session != null) {
70 | session.close();
71 | }
72 | }
73 | }
74 |
75 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/task/ServiceTask.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.task;
2 |
3 | import java.sql.Time;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | import org.apache.ibatis.session.SqlSession;
9 | import org.apache.ibatis.session.SqlSessionFactory;
10 |
11 | import scouter.plugin.server.reporting.ReportingPlugin;
12 | import scouter.plugin.server.reporting.collector.ServiceStat;
13 | import scouter.plugin.server.reporting.vo.Service;
14 | import scouter.server.Logger;
15 | import scouter.util.DateUtil;
16 |
17 | public class ServiceTask implements Runnable {
18 |
19 | private SqlSessionFactory sqlSessionFactory;
20 | private Map> serviceStatMap;
21 |
22 | public ServiceTask(SqlSessionFactory sqlSessionFactory, Map> serviceStatMap) {
23 | this.sqlSessionFactory = sqlSessionFactory;
24 | this.serviceStatMap = serviceStatMap;
25 | }
26 |
27 | @Override
28 | public void run() {
29 | SqlSession session = sqlSessionFactory.openSession(true);
30 |
31 | try {
32 | long time = (System.currentTimeMillis() - 10000) / DateUtil.MILLIS_PER_FIVE_MINUTE * DateUtil.MILLIS_PER_FIVE_MINUTE;
33 |
34 | List mainKeyList = new ArrayList(serviceStatMap.keySet());
35 |
36 | List subKeyList = null;
37 | Map serviceMap = null;
38 | ServiceStat serviceStat = null;
39 | Service service = null;
40 |
41 | // DB insert 시간이 길면 다음 스케쥴 시간에 해당하는 데이터도 함께 수집이 되므로, 현재 스케쥴 시간에 해당하는 데이터 목록만 구한다.
42 | List serviceList = new ArrayList();
43 | for (Integer mainKey : mainKeyList) {
44 | serviceMap = serviceStatMap.get(mainKey);
45 |
46 | subKeyList = new ArrayList(serviceMap.keySet());
47 | for (Integer subKey : subKeyList) {
48 | serviceStat = serviceMap.get(subKey);
49 |
50 | if (serviceStat.isPurge()) {
51 | serviceMap.remove(subKey);
52 | } else {
53 | service = serviceStat.getServiceAndClear();
54 |
55 | if (service != null) {
56 | serviceList.add(service);
57 | }
58 | }
59 | }
60 | }
61 |
62 | for (Service s : serviceList) {
63 | // 서비스의 경우 데이터 처리에 많은 시간이 소요될 경우 다음 스케줄 시간에 해당하는 데이터도 함께 처리될 수 있으며,
64 | // 그런 경우 PK 충돌이 발생할 수 있다. 따라서 현재 스케쥴 시간에 해당하는 데이터만 처리한다.
65 | if (s.getLog_tm().equals(new Time(time))) {
66 | try {
67 | session.insert("Scouter.insertService", s);
68 |
69 | if (ReportingPlugin.conf.getBoolean("ext_plugin_reporting_logging_enabled", false)) {
70 | Logger.println("[" + s.getObject_hash() + "," + s.getService_hash() + "] service inserted.");
71 | }
72 | } catch (Exception e) {
73 | //Logger.printStackTrace(e);
74 | Logger.println("[Duplicated] : " + s);
75 | }
76 |
77 | try {
78 | session.insert("Scouter.insertIpAddress", s);
79 | } catch (Exception e) {}
80 |
81 | try {
82 | session.insert("Scouter.insertUserAgent", s);
83 | } catch (Exception e) {}
84 | }
85 | }
86 | } catch (Exception e) {
87 | Logger.printStackTrace(e);
88 | } finally {
89 | if (session != null) {
90 | session.close();
91 | }
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/AgentInfo.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | import java.util.Date;
4 |
5 | public class AgentInfo {
6 |
7 | private int object_hash;
8 | private String object_name;
9 | private String object_family;
10 | private String object_type;
11 | private String ip_address;
12 | private Date last_up_time;
13 | private Date last_down_time;
14 |
15 | public int getObject_hash() {
16 | return object_hash;
17 | }
18 |
19 | public void setObject_hash(int object_hash) {
20 | this.object_hash = object_hash;
21 | }
22 |
23 | public String getObject_name() {
24 | return object_name;
25 | }
26 |
27 | public void setObject_name(String object_name) {
28 | this.object_name = object_name;
29 | }
30 |
31 | public String getObject_family() {
32 | return object_family;
33 | }
34 |
35 | public void setObject_family(String object_family) {
36 | this.object_family = object_family;
37 | }
38 |
39 | public String getObject_type() {
40 | return object_type;
41 | }
42 |
43 | public void setObject_type(String object_type) {
44 | this.object_type = object_type;
45 | }
46 |
47 | public String getIp_address() {
48 | return ip_address;
49 | }
50 |
51 | public void setIp_address(String ip_address) {
52 | this.ip_address = ip_address;
53 | }
54 |
55 | public Date getLast_up_time() {
56 | return last_up_time;
57 | }
58 |
59 | public void setLast_up_time(Date last_up_time) {
60 | this.last_up_time = last_up_time;
61 | }
62 |
63 | public Date getLast_down_time() {
64 | return last_down_time;
65 | }
66 |
67 | public void setLast_down_time(Date last_down_time) {
68 | this.last_down_time = last_down_time;
69 | }
70 |
71 | @Override
72 | public String toString() {
73 | return "AgentInfo [object_hash=" + object_hash + ", object_name=" + object_name + ", object_family="
74 | + object_family + ", object_type=" + object_type + ", ip_address=" + ip_address + ", last_up_time="
75 | + last_up_time + ", last_down_time=" + last_down_time + "]";
76 | }
77 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/Alert.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | public class Alert extends BaseObject {
4 |
5 | private String object_name;
6 | private String day;
7 | private String time;
8 | private String level;
9 | private String title;
10 | private String message;
11 |
12 | public String getObject_name() {
13 | return object_name;
14 | }
15 |
16 | public void setObject_name(String object_name) {
17 | this.object_name = object_name;
18 | }
19 |
20 | public String getDay() {
21 | return day;
22 | }
23 |
24 | public void setDay(String day) {
25 | this.day = day;
26 | }
27 |
28 | public String getTime() {
29 | return time;
30 | }
31 |
32 | public void setTime(String time) {
33 | this.time = time;
34 | }
35 |
36 | public String getLevel() {
37 | return level;
38 | }
39 |
40 | public void setLevel(String level) {
41 | this.level = level;
42 | }
43 |
44 | public String getTitle() {
45 | return title;
46 | }
47 |
48 | public void setTitle(String title) {
49 | this.title = title;
50 | }
51 |
52 | public String getMessage() {
53 | return message;
54 | }
55 |
56 | public void setMessage(String message) {
57 | this.message = message;
58 | }
59 |
60 | @Override
61 | public String toString() {
62 | return "Alert [object_name=" + object_name + ", day=" + day + ", time=" + time + ", level=" + level + ", title="
63 | + title + ", message=" + message + ", date=" + date + ", object_hash=" + object_hash + ", log_dt="
64 | + log_dt + ", log_tm=" + log_tm + "]";
65 | }
66 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/BaseObject.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | import java.sql.Date;
4 | import java.sql.Time;
5 | import java.util.Calendar;
6 |
7 | public abstract class BaseObject {
8 |
9 | protected String date;
10 | protected int object_hash;
11 | protected Date log_dt;
12 | protected Time log_tm;
13 |
14 | public String getDate() {
15 | if (date == null) {
16 | int d = Calendar.getInstance().get(Calendar.DATE);
17 |
18 | if (d < 10) {
19 | date = "0" + d;
20 | } else {
21 | date = d + "";
22 | }
23 | }
24 |
25 | return date;
26 | }
27 |
28 | public void setDate(String date) {
29 | this.date = date;
30 | }
31 |
32 | public void setDate(long timestamp) {
33 | Calendar c = Calendar.getInstance();
34 | c.setTimeInMillis(timestamp);
35 |
36 | int d = c.get(Calendar.DATE);
37 |
38 | if (d < 10) {
39 | date = "0" + d;
40 | } else {
41 | date = d + "";
42 | }
43 | }
44 |
45 | public int getObject_hash() {
46 | return object_hash;
47 | }
48 |
49 | public void setObject_hash(int object_hash) {
50 | this.object_hash = object_hash;
51 | }
52 |
53 | public Date getLog_dt() {
54 | return log_dt;
55 | }
56 |
57 | public void setLog_dt(Date log_dt) {
58 | this.log_dt = log_dt;
59 | }
60 |
61 | public Time getLog_tm() {
62 | return log_tm;
63 | }
64 |
65 | public void setLog_tm(Time log_tm) {
66 | this.log_tm = log_tm;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/HostAgent.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | public class HostAgent extends BaseObject {
4 |
5 | private String object_name;
6 | private String day;
7 | private String time;
8 | private Float cpu_avg;
9 | private Float cpu_max;
10 | private Integer mem_total;
11 | private Float mem_avg;
12 | private Float mem_max;
13 | private Integer mem_u_avg;
14 | private Integer mem_u_max;
15 | private Integer net_tx_avg;
16 | private Integer net_tx_max;
17 | private Integer net_rx_avg;
18 | private Integer net_rx_max;
19 | private Integer disk_r_avg;
20 | private Integer disk_r_max;
21 | private Integer disk_w_avg;
22 | private Integer disk_w_max;
23 |
24 | public String getObject_name() {
25 | return object_name;
26 | }
27 |
28 | public void setObject_name(String object_name) {
29 | this.object_name = object_name;
30 | }
31 |
32 | public String getDay() {
33 | return day;
34 | }
35 |
36 | public void setDay(String day) {
37 | this.day = day;
38 | }
39 |
40 | public String getTime() {
41 | return time;
42 | }
43 |
44 | public void setTime(String time) {
45 | this.time = time;
46 | }
47 |
48 | public Float getCpu_avg() {
49 | return cpu_avg;
50 | }
51 |
52 | public void setCpu_avg(Float cpu_avg) {
53 | this.cpu_avg = cpu_avg;
54 | }
55 |
56 | public Float getCpu_max() {
57 | return cpu_max;
58 | }
59 |
60 | public void setCpu_max(Float cpu_max) {
61 | this.cpu_max = cpu_max;
62 | }
63 |
64 | public Integer getMem_total() {
65 | return mem_total;
66 | }
67 |
68 | public void setMem_total(Integer mem_total) {
69 | this.mem_total = mem_total;
70 | }
71 |
72 | public Float getMem_avg() {
73 | return mem_avg;
74 | }
75 |
76 | public void setMem_avg(Float mem_avg) {
77 | this.mem_avg = mem_avg;
78 | }
79 |
80 | public Float getMem_max() {
81 | return mem_max;
82 | }
83 |
84 | public void setMem_max(Float mem_max) {
85 | this.mem_max = mem_max;
86 | }
87 |
88 | public Integer getMem_u_avg() {
89 | return mem_u_avg;
90 | }
91 |
92 | public void setMem_u_avg(Integer mem_u_avg) {
93 | this.mem_u_avg = mem_u_avg;
94 | }
95 |
96 | public Integer getMem_u_max() {
97 | return mem_u_max;
98 | }
99 |
100 | public void setMem_u_max(Integer mem_u_max) {
101 | this.mem_u_max = mem_u_max;
102 | }
103 |
104 | public Integer getNet_tx_avg() {
105 | return net_tx_avg;
106 | }
107 |
108 | public void setNet_tx_avg(Integer net_tx_avg) {
109 | this.net_tx_avg = net_tx_avg;
110 | }
111 |
112 | public Integer getNet_tx_max() {
113 | return net_tx_max;
114 | }
115 |
116 | public void setNet_tx_max(Integer net_tx_max) {
117 | this.net_tx_max = net_tx_max;
118 | }
119 |
120 | public Integer getNet_rx_avg() {
121 | return net_rx_avg;
122 | }
123 |
124 | public void setNet_rx_avg(Integer net_rx_avg) {
125 | this.net_rx_avg = net_rx_avg;
126 | }
127 |
128 | public Integer getNet_rx_max() {
129 | return net_rx_max;
130 | }
131 |
132 | public void setNet_rx_max(Integer net_rx_max) {
133 | this.net_rx_max = net_rx_max;
134 | }
135 |
136 | public Integer getDisk_r_avg() {
137 | return disk_r_avg;
138 | }
139 |
140 | public void setDisk_r_avg(Integer disk_r_avg) {
141 | this.disk_r_avg = disk_r_avg;
142 | }
143 |
144 | public Integer getDisk_r_max() {
145 | return disk_r_max;
146 | }
147 |
148 | public void setDisk_r_max(Integer disk_r_max) {
149 | this.disk_r_max = disk_r_max;
150 | }
151 |
152 | public Integer getDisk_w_avg() {
153 | return disk_w_avg;
154 | }
155 |
156 | public void setDisk_w_avg(Integer disk_w_avg) {
157 | this.disk_w_avg = disk_w_avg;
158 | }
159 |
160 | public Integer getDisk_w_max() {
161 | return disk_w_max;
162 | }
163 |
164 | public void setDisk_w_max(Integer disk_w_max) {
165 | this.disk_w_max = disk_w_max;
166 | }
167 |
168 | @Override
169 | public String toString() {
170 | return "HostAgent [object_name=" + object_name + ", day=" + day + ", time=" + time + ", cpu_avg=" + cpu_avg
171 | + ", cpu_max=" + cpu_max + ", mem_total=" + mem_total + ", mem_avg=" + mem_avg + ", mem_max=" + mem_max
172 | + ", mem_u_avg=" + mem_u_avg + ", mem_u_max=" + mem_u_max + ", net_tx_avg=" + net_tx_avg
173 | + ", net_tx_max=" + net_tx_max + ", net_rx_avg=" + net_rx_avg + ", net_rx_max=" + net_rx_max
174 | + ", disk_r_avg=" + disk_r_avg + ", disk_r_max=" + disk_r_max + ", disk_w_avg=" + disk_w_avg
175 | + ", disk_w_max=" + disk_w_max + ", date=" + date + ", object_hash=" + object_hash + ", log_dt="
176 | + log_dt + ", log_tm=" + log_tm + "]";
177 | }
178 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/IpAddress.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | public class IpAddress extends BaseObject {
4 |
5 | private int service_hash;
6 | private String ip_address;
7 | private int request_count;
8 | private int error_count;
9 |
10 | public int getService_hash() {
11 | return service_hash;
12 | }
13 |
14 | public void setService_hash(int service_hash) {
15 | this.service_hash = service_hash;
16 | }
17 |
18 | public String getIp_address() {
19 | return ip_address;
20 | }
21 |
22 | public void setIp_address(String ip_address) {
23 | this.ip_address = ip_address;
24 | }
25 |
26 | public int getRequest_count() {
27 | return request_count;
28 | }
29 |
30 | public void setRequest_count(int request_count) {
31 | this.request_count = request_count;
32 | }
33 |
34 | public int getError_count() {
35 | return error_count;
36 | }
37 |
38 | public void setError_count(int error_count) {
39 | this.error_count = error_count;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "IpAddress [service_hash=" + service_hash + ", ip_address=" + ip_address + ", request_count="
45 | + request_count + ", error_count=" + error_count + ", date=" + getDate() + ", object_hash=" + object_hash
46 | + ", log_dt=" + log_dt + ", log_tm=" + log_tm + "]";
47 | }
48 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/JavaAgent.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | public class JavaAgent extends BaseObject {
4 |
5 | private String object_name;
6 | private String day;
7 | private String time;
8 | private Integer active_service_avg;
9 | private Integer active_service_max;
10 | private Float heap_total;
11 | private Float heap_used_avg;
12 | private Float heap_used_max;
13 | private Integer recent_user_avg;
14 | private Integer recent_user_max;
15 | private Integer service_count_avg;
16 | private Integer service_count_max;
17 | private Float api_tps_avg;
18 | private Float api_tps_max;
19 | private Float sql_tps_avg;
20 | private Float sql_tps_max;
21 | private Float tps_avg;
22 | private Float tps_max;
23 |
24 | public String getObject_name() {
25 | return object_name;
26 | }
27 |
28 | public void setObject_name(String object_name) {
29 | this.object_name = object_name;
30 | }
31 |
32 | public String getDay() {
33 | return day;
34 | }
35 |
36 | public void setDay(String day) {
37 | this.day = day;
38 | }
39 |
40 | public String getTime() {
41 | return time;
42 | }
43 |
44 | public void setTime(String time) {
45 | this.time = time;
46 | }
47 |
48 | public Integer getActive_service_avg() {
49 | return active_service_avg;
50 | }
51 |
52 | public void setActive_service_avg(Integer active_service_avg) {
53 | this.active_service_avg = active_service_avg;
54 | }
55 |
56 | public Integer getActive_service_max() {
57 | return active_service_max;
58 | }
59 |
60 | public void setActive_service_max(Integer active_service_max) {
61 | this.active_service_max = active_service_max;
62 | }
63 |
64 | public Float getHeap_total() {
65 | return heap_total;
66 | }
67 |
68 | public void setHeap_total(Float heap_total) {
69 | this.heap_total = heap_total;
70 | }
71 |
72 | public Float getHeap_used_avg() {
73 | return heap_used_avg;
74 | }
75 |
76 | public void setHeap_used_avg(Float heap_used_avg) {
77 | this.heap_used_avg = heap_used_avg;
78 | }
79 |
80 | public Float getHeap_used_max() {
81 | return heap_used_max;
82 | }
83 |
84 | public void setHeap_used_max(Float heap_used_max) {
85 | this.heap_used_max = heap_used_max;
86 | }
87 |
88 | public Integer getRecent_user_avg() {
89 | return recent_user_avg;
90 | }
91 |
92 | public void setRecent_user_avg(Integer recent_user_avg) {
93 | this.recent_user_avg = recent_user_avg;
94 | }
95 |
96 | public Integer getRecent_user_max() {
97 | return recent_user_max;
98 | }
99 |
100 | public void setRecent_user_max(Integer recent_user_max) {
101 | this.recent_user_max = recent_user_max;
102 | }
103 |
104 | public Integer getService_count_avg() {
105 | return service_count_avg;
106 | }
107 |
108 | public void setService_count_avg(Integer service_count_avg) {
109 | this.service_count_avg = service_count_avg;
110 | }
111 |
112 | public Integer getService_count_max() {
113 | return service_count_max;
114 | }
115 |
116 | public void setService_count_max(Integer service_count_max) {
117 | this.service_count_max = service_count_max;
118 | }
119 |
120 | public Float getApi_tps_avg() {
121 | return api_tps_avg;
122 | }
123 |
124 | public void setApi_tps_avg(Float api_tps_avg) {
125 | this.api_tps_avg = api_tps_avg;
126 | }
127 |
128 | public Float getApi_tps_max() {
129 | return api_tps_max;
130 | }
131 |
132 | public void setApi_tps_max(Float api_tps_max) {
133 | this.api_tps_max = api_tps_max;
134 | }
135 |
136 | public Float getSql_tps_avg() {
137 | return sql_tps_avg;
138 | }
139 |
140 | public void setSql_tps_avg(Float sql_tps_avg) {
141 | this.sql_tps_avg = sql_tps_avg;
142 | }
143 |
144 | public Float getSql_tps_max() {
145 | return sql_tps_max;
146 | }
147 |
148 | public void setSql_tps_max(Float sql_tps_max) {
149 | this.sql_tps_max = sql_tps_max;
150 | }
151 |
152 | public Float getTps_avg() {
153 | return tps_avg;
154 | }
155 |
156 | public void setTps_avg(Float tps_avg) {
157 | this.tps_avg = tps_avg;
158 | }
159 |
160 | public Float getTps_max() {
161 | return tps_max;
162 | }
163 |
164 | public void setTps_max(Float tps_max) {
165 | this.tps_max = tps_max;
166 | }
167 |
168 | @Override
169 | public String toString() {
170 | return "JavaAgent [object_name=" + object_name + ", day=" + day + ", time=" + time + ", active_service_avg="
171 | + active_service_avg + ", active_service_max=" + active_service_max + ", heap_total=" + heap_total
172 | + ", heap_used_avg=" + heap_used_avg + ", heap_used_max=" + heap_used_max + ", recent_user_avg="
173 | + recent_user_avg + ", recent_user_max=" + recent_user_max + ", service_count_avg=" + service_count_avg
174 | + ", service_count_max=" + service_count_max + ", api_tps_avg=" + api_tps_avg + ", api_tps_max="
175 | + api_tps_max + ", sql_tps_avg=" + sql_tps_avg + ", sql_tps_max=" + sql_tps_max + ", tps_avg=" + tps_avg
176 | + ", tps_max=" + tps_max + ", date=" + date + ", object_hash=" + object_hash + ", log_dt=" + log_dt
177 | + ", log_tm=" + log_tm + "]";
178 | }
179 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/Service.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class Service extends BaseObject {
7 |
8 | private String day;
9 | private String time;
10 | private String app_id;
11 | private Integer service_hash;
12 | private String service_name;
13 | private Integer elapsed_avg;
14 | private Integer elapsed_max;
15 | private Integer sql_count_avg;
16 | private Integer sql_count_max;
17 | private Integer sql_time_avg;
18 | private Integer sql_time_max;
19 | private Integer request_count;
20 | private Integer error_count;
21 | private Integer elapsed_exceed_count;
22 | private Integer ip_count;
23 | private Integer ua_count;
24 |
25 | private List ipAddressList;
26 | private List userAgentList;
27 |
28 | public String getDay() {
29 | return day;
30 | }
31 |
32 | public void setDay(String day) {
33 | this.day = day;
34 | }
35 |
36 | public String getTime() {
37 | return time;
38 | }
39 |
40 | public void setTime(String time) {
41 | this.time = time;
42 | }
43 |
44 | public String getApp_id() {
45 | return app_id;
46 | }
47 |
48 | public void setApp_id(String app_id) {
49 | this.app_id = app_id;
50 | }
51 |
52 | public Integer getService_hash() {
53 | return service_hash;
54 | }
55 |
56 | public void setService_hash(Integer service_hash) {
57 | this.service_hash = service_hash;
58 | }
59 |
60 | public String getService_name() {
61 | return service_name;
62 | }
63 |
64 | public void setService_name(String service_name) {
65 | this.service_name = service_name;
66 | }
67 |
68 | public Integer getElapsed_avg() {
69 | return elapsed_avg;
70 | }
71 |
72 | public void setElapsed_avg(Integer elapsed_avg) {
73 | this.elapsed_avg = elapsed_avg;
74 | }
75 |
76 | public Integer getElapsed_max() {
77 | return elapsed_max;
78 | }
79 |
80 | public void setElapsed_max(Integer elapsed_max) {
81 | this.elapsed_max = elapsed_max;
82 | }
83 |
84 | public Integer getSql_count_avg() {
85 | return sql_count_avg;
86 | }
87 |
88 | public void setSql_count_avg(Integer sql_count_avg) {
89 | this.sql_count_avg = sql_count_avg;
90 | }
91 |
92 | public Integer getSql_count_max() {
93 | return sql_count_max;
94 | }
95 |
96 | public void setSql_count_max(Integer sql_count_max) {
97 | this.sql_count_max = sql_count_max;
98 | }
99 |
100 | public Integer getSql_time_avg() {
101 | return sql_time_avg;
102 | }
103 |
104 | public void setSql_time_avg(Integer sql_time_avg) {
105 | this.sql_time_avg = sql_time_avg;
106 | }
107 |
108 | public Integer getSql_time_max() {
109 | return sql_time_max;
110 | }
111 |
112 | public void setSql_time_max(Integer sql_time_max) {
113 | this.sql_time_max = sql_time_max;
114 | }
115 |
116 | public Integer getRequest_count() {
117 | return request_count;
118 | }
119 |
120 | public void setRequest_count(Integer request_count) {
121 | this.request_count = request_count;
122 | }
123 |
124 | public Integer getError_count() {
125 | return error_count;
126 | }
127 |
128 | public void setError_count(Integer error_count) {
129 | this.error_count = error_count;
130 | }
131 |
132 | public Integer getElapsed_exceed_count() {
133 | return elapsed_exceed_count;
134 | }
135 |
136 | public void setElapsed_exceed_count(Integer elapsed_exceed_count) {
137 | this.elapsed_exceed_count = elapsed_exceed_count;
138 | }
139 |
140 | public Integer getIp_count() {
141 | return ip_count;
142 | }
143 |
144 | public void setIp_count(Integer ip_count) {
145 | this.ip_count = ip_count;
146 | }
147 |
148 | public Integer getUa_count() {
149 | return ua_count;
150 | }
151 |
152 | public void setUa_count(Integer ua_count) {
153 | this.ua_count = ua_count;
154 | }
155 |
156 | public List getIpAddressList() {
157 | if (ipAddressList == null) {
158 | ipAddressList = new ArrayList();
159 | }
160 |
161 | return ipAddressList;
162 | }
163 |
164 | public void addIpAddress(IpAddress ipAddress) {
165 | getIpAddressList().add(ipAddress);
166 | }
167 |
168 | public List getUserAgentList() {
169 | if (userAgentList == null) {
170 | userAgentList = new ArrayList();
171 | }
172 |
173 | return userAgentList;
174 | }
175 |
176 | public void addUserAgent(UserAgent userAgent) {
177 | getUserAgentList().add(userAgent);
178 | }
179 |
180 | @Override
181 | public String toString() {
182 | return "Service [day=" + day + ", time=" + time + ", app_id=" + app_id + ", service_hash=" + service_hash + ", service_name="
183 | + service_name + ", elapsed_avg=" + elapsed_avg + ", elapsed_max=" + elapsed_max + ", sql_count_avg="
184 | + sql_count_avg + ", sql_count_max=" + sql_count_max + ", sql_time_avg=" + sql_time_avg
185 | + ", sql_time_max=" + sql_time_max + ", request_count=" + request_count + ", error_count=" + error_count
186 | + ", elapsed_exceed_count=" + elapsed_exceed_count + ", ip_count=" + ip_count + ", ua_count=" + ua_count
187 | + ", ipAddressList=" + ipAddressList + ", userAgentList=" + userAgentList + ", date=" + date
188 | + ", object_hash=" + object_hash + ", log_dt=" + log_dt + ", log_tm=" + log_tm + "]";
189 | }
190 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/Sql.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | public class Sql extends BaseObject {
4 |
5 | private int sql_hash;
6 | private int execute_count;
7 | private int error_count;
8 | private int elapsed;
9 |
10 | public int getSql_hash() {
11 | return sql_hash;
12 | }
13 |
14 | public void setSql_hash(int sql_hash) {
15 | this.sql_hash = sql_hash;
16 | }
17 |
18 | public int getExecute_count() {
19 | return execute_count;
20 | }
21 |
22 | public void setExecute_count(int execute_count) {
23 | this.execute_count = execute_count;
24 | }
25 |
26 | public int getError_count() {
27 | return error_count;
28 | }
29 |
30 | public void setError_count(int error_count) {
31 | this.error_count = error_count;
32 | }
33 |
34 | public int getElapsed() {
35 | return elapsed;
36 | }
37 |
38 | public void setElapsed(int elapsed) {
39 | this.elapsed = elapsed;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "Sql [sql_hash=" + sql_hash + ", execute_count=" + execute_count
45 | + ", error_count=" + error_count + ", elapsed=" + elapsed + ", date=" + getDate() + ", object_hash="
46 | + object_hash + ", log_dt=" + log_dt + ", log_tm=" + log_tm + "]";
47 | }
48 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/SqlInfo.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | public class SqlInfo {
4 |
5 | private int sql_hash;
6 | private String sql_str;
7 |
8 | public int getSql_hash() {
9 | return sql_hash;
10 | }
11 |
12 | public void setSql_hash(int sql_hash) {
13 | this.sql_hash = sql_hash;
14 | }
15 |
16 | public String getSql_str() {
17 | return sql_str;
18 | }
19 |
20 | public void setSql_str(String sql_str) {
21 | this.sql_str = sql_str;
22 | }
23 |
24 | @Override
25 | public String toString() {
26 | return "SqlInfo [sql_hash=" + sql_hash + ", sql_str=" + sql_str + "]";
27 | }
28 | }
--------------------------------------------------------------------------------
/src/main/java/scouter/plugin/server/reporting/vo/UserAgent.java:
--------------------------------------------------------------------------------
1 | package scouter.plugin.server.reporting.vo;
2 |
3 | public class UserAgent extends BaseObject {
4 |
5 | private int service_hash;
6 | private String user_agent;
7 | private int request_count;
8 | private int error_count;
9 |
10 | public int getService_hash() {
11 | return service_hash;
12 | }
13 |
14 | public void setService_hash(int service_hash) {
15 | this.service_hash = service_hash;
16 | }
17 |
18 | public String getUser_agent() {
19 | return user_agent;
20 | }
21 |
22 | public void setUser_agent(String user_agent) {
23 | this.user_agent = user_agent;
24 | }
25 |
26 | public int getRequest_count() {
27 | return request_count;
28 | }
29 |
30 | public void setRequest_count(int request_count) {
31 | this.request_count = request_count;
32 | }
33 |
34 | public int getError_count() {
35 | return error_count;
36 | }
37 |
38 | public void setError_count(int error_count) {
39 | this.error_count = error_count;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "UserAgent [service_hash=" + service_hash + ", user_agent=" + user_agent + ", request_count="
45 | + request_count + ", error_count=" + error_count + ", date=" + getDate() + ", object_hash=" + object_hash
46 | + ", log_dt=" + log_dt + ", log_tm=" + log_tm + "]";
47 | }
48 | }
--------------------------------------------------------------------------------
/src/main/resources/excel/host_daily_template.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceConsulting/scouter-plugin-server-reporting/132c5ef605d97ddffa11220e4998e65b8be440ed/src/main/resources/excel/host_daily_template.xlsx
--------------------------------------------------------------------------------
/src/main/resources/excel/host_hourly_template.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceConsulting/scouter-plugin-server-reporting/132c5ef605d97ddffa11220e4998e65b8be440ed/src/main/resources/excel/host_hourly_template.xlsx
--------------------------------------------------------------------------------
/src/main/resources/excel/java_daily_template.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceConsulting/scouter-plugin-server-reporting/132c5ef605d97ddffa11220e4998e65b8be440ed/src/main/resources/excel/java_daily_template.xlsx
--------------------------------------------------------------------------------
/src/main/resources/excel/java_hourly_template.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceConsulting/scouter-plugin-server-reporting/132c5ef605d97ddffa11220e4998e65b8be440ed/src/main/resources/excel/java_hourly_template.xlsx
--------------------------------------------------------------------------------
/src/main/resources/excel/service_daily_template.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceConsulting/scouter-plugin-server-reporting/132c5ef605d97ddffa11220e4998e65b8be440ed/src/main/resources/excel/service_daily_template.xlsx
--------------------------------------------------------------------------------
/src/main/resources/excel/service_hourly_template.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenSourceConsulting/scouter-plugin-server-reporting/132c5ef605d97ddffa11220e4998e65b8be440ed/src/main/resources/excel/service_hourly_template.xlsx
--------------------------------------------------------------------------------
/src/main/resources/init_time_table.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE TIME_TBL(
2 | TIME TIME NOT NULL,
3 | PRIMARY KEY (TIME)
4 | );
5 |
6 | INSERT INTO TIME_TBL (TIME) VALUES ('00:00:00');
7 | INSERT INTO TIME_TBL (TIME) VALUES ('00:05:00');
8 | INSERT INTO TIME_TBL (TIME) VALUES ('00:10:00');
9 | INSERT INTO TIME_TBL (TIME) VALUES ('00:15:00');
10 | INSERT INTO TIME_TBL (TIME) VALUES ('00:20:00');
11 | INSERT INTO TIME_TBL (TIME) VALUES ('00:25:00');
12 | INSERT INTO TIME_TBL (TIME) VALUES ('00:30:00');
13 | INSERT INTO TIME_TBL (TIME) VALUES ('00:35:00');
14 | INSERT INTO TIME_TBL (TIME) VALUES ('00:40:00');
15 | INSERT INTO TIME_TBL (TIME) VALUES ('00:45:00');
16 | INSERT INTO TIME_TBL (TIME) VALUES ('00:50:00');
17 | INSERT INTO TIME_TBL (TIME) VALUES ('00:55:00');
18 | INSERT INTO TIME_TBL (TIME) VALUES ('01:00:00');
19 | INSERT INTO TIME_TBL (TIME) VALUES ('01:05:00');
20 | INSERT INTO TIME_TBL (TIME) VALUES ('01:10:00');
21 | INSERT INTO TIME_TBL (TIME) VALUES ('01:15:00');
22 | INSERT INTO TIME_TBL (TIME) VALUES ('01:20:00');
23 | INSERT INTO TIME_TBL (TIME) VALUES ('01:25:00');
24 | INSERT INTO TIME_TBL (TIME) VALUES ('01:30:00');
25 | INSERT INTO TIME_TBL (TIME) VALUES ('01:35:00');
26 | INSERT INTO TIME_TBL (TIME) VALUES ('01:40:00');
27 | INSERT INTO TIME_TBL (TIME) VALUES ('01:45:00');
28 | INSERT INTO TIME_TBL (TIME) VALUES ('01:50:00');
29 | INSERT INTO TIME_TBL (TIME) VALUES ('01:55:00');
30 | INSERT INTO TIME_TBL (TIME) VALUES ('02:00:00');
31 | INSERT INTO TIME_TBL (TIME) VALUES ('02:05:00');
32 | INSERT INTO TIME_TBL (TIME) VALUES ('02:10:00');
33 | INSERT INTO TIME_TBL (TIME) VALUES ('02:15:00');
34 | INSERT INTO TIME_TBL (TIME) VALUES ('02:20:00');
35 | INSERT INTO TIME_TBL (TIME) VALUES ('02:25:00');
36 | INSERT INTO TIME_TBL (TIME) VALUES ('02:30:00');
37 | INSERT INTO TIME_TBL (TIME) VALUES ('02:35:00');
38 | INSERT INTO TIME_TBL (TIME) VALUES ('02:40:00');
39 | INSERT INTO TIME_TBL (TIME) VALUES ('02:45:00');
40 | INSERT INTO TIME_TBL (TIME) VALUES ('02:50:00');
41 | INSERT INTO TIME_TBL (TIME) VALUES ('02:55:00');
42 | INSERT INTO TIME_TBL (TIME) VALUES ('03:00:00');
43 | INSERT INTO TIME_TBL (TIME) VALUES ('03:05:00');
44 | INSERT INTO TIME_TBL (TIME) VALUES ('03:10:00');
45 | INSERT INTO TIME_TBL (TIME) VALUES ('03:15:00');
46 | INSERT INTO TIME_TBL (TIME) VALUES ('03:20:00');
47 | INSERT INTO TIME_TBL (TIME) VALUES ('03:25:00');
48 | INSERT INTO TIME_TBL (TIME) VALUES ('03:30:00');
49 | INSERT INTO TIME_TBL (TIME) VALUES ('03:35:00');
50 | INSERT INTO TIME_TBL (TIME) VALUES ('03:40:00');
51 | INSERT INTO TIME_TBL (TIME) VALUES ('03:45:00');
52 | INSERT INTO TIME_TBL (TIME) VALUES ('03:50:00');
53 | INSERT INTO TIME_TBL (TIME) VALUES ('03:55:00');
54 | INSERT INTO TIME_TBL (TIME) VALUES ('04:00:00');
55 | INSERT INTO TIME_TBL (TIME) VALUES ('04:05:00');
56 | INSERT INTO TIME_TBL (TIME) VALUES ('04:10:00');
57 | INSERT INTO TIME_TBL (TIME) VALUES ('04:15:00');
58 | INSERT INTO TIME_TBL (TIME) VALUES ('04:20:00');
59 | INSERT INTO TIME_TBL (TIME) VALUES ('04:25:00');
60 | INSERT INTO TIME_TBL (TIME) VALUES ('04:30:00');
61 | INSERT INTO TIME_TBL (TIME) VALUES ('04:35:00');
62 | INSERT INTO TIME_TBL (TIME) VALUES ('04:40:00');
63 | INSERT INTO TIME_TBL (TIME) VALUES ('04:45:00');
64 | INSERT INTO TIME_TBL (TIME) VALUES ('04:50:00');
65 | INSERT INTO TIME_TBL (TIME) VALUES ('04:55:00');
66 | INSERT INTO TIME_TBL (TIME) VALUES ('05:00:00');
67 | INSERT INTO TIME_TBL (TIME) VALUES ('05:05:00');
68 | INSERT INTO TIME_TBL (TIME) VALUES ('05:10:00');
69 | INSERT INTO TIME_TBL (TIME) VALUES ('05:15:00');
70 | INSERT INTO TIME_TBL (TIME) VALUES ('05:20:00');
71 | INSERT INTO TIME_TBL (TIME) VALUES ('05:25:00');
72 | INSERT INTO TIME_TBL (TIME) VALUES ('05:30:00');
73 | INSERT INTO TIME_TBL (TIME) VALUES ('05:35:00');
74 | INSERT INTO TIME_TBL (TIME) VALUES ('05:40:00');
75 | INSERT INTO TIME_TBL (TIME) VALUES ('05:45:00');
76 | INSERT INTO TIME_TBL (TIME) VALUES ('05:50:00');
77 | INSERT INTO TIME_TBL (TIME) VALUES ('05:55:00');
78 | INSERT INTO TIME_TBL (TIME) VALUES ('06:00:00');
79 | INSERT INTO TIME_TBL (TIME) VALUES ('06:05:00');
80 | INSERT INTO TIME_TBL (TIME) VALUES ('06:10:00');
81 | INSERT INTO TIME_TBL (TIME) VALUES ('06:15:00');
82 | INSERT INTO TIME_TBL (TIME) VALUES ('06:20:00');
83 | INSERT INTO TIME_TBL (TIME) VALUES ('06:25:00');
84 | INSERT INTO TIME_TBL (TIME) VALUES ('06:30:00');
85 | INSERT INTO TIME_TBL (TIME) VALUES ('06:35:00');
86 | INSERT INTO TIME_TBL (TIME) VALUES ('06:40:00');
87 | INSERT INTO TIME_TBL (TIME) VALUES ('06:45:00');
88 | INSERT INTO TIME_TBL (TIME) VALUES ('06:50:00');
89 | INSERT INTO TIME_TBL (TIME) VALUES ('06:55:00');
90 | INSERT INTO TIME_TBL (TIME) VALUES ('07:00:00');
91 | INSERT INTO TIME_TBL (TIME) VALUES ('07:05:00');
92 | INSERT INTO TIME_TBL (TIME) VALUES ('07:10:00');
93 | INSERT INTO TIME_TBL (TIME) VALUES ('07:15:00');
94 | INSERT INTO TIME_TBL (TIME) VALUES ('07:20:00');
95 | INSERT INTO TIME_TBL (TIME) VALUES ('07:25:00');
96 | INSERT INTO TIME_TBL (TIME) VALUES ('07:30:00');
97 | INSERT INTO TIME_TBL (TIME) VALUES ('07:35:00');
98 | INSERT INTO TIME_TBL (TIME) VALUES ('07:40:00');
99 | INSERT INTO TIME_TBL (TIME) VALUES ('07:45:00');
100 | INSERT INTO TIME_TBL (TIME) VALUES ('07:50:00');
101 | INSERT INTO TIME_TBL (TIME) VALUES ('07:55:00');
102 | INSERT INTO TIME_TBL (TIME) VALUES ('08:00:00');
103 | INSERT INTO TIME_TBL (TIME) VALUES ('08:05:00');
104 | INSERT INTO TIME_TBL (TIME) VALUES ('08:10:00');
105 | INSERT INTO TIME_TBL (TIME) VALUES ('08:15:00');
106 | INSERT INTO TIME_TBL (TIME) VALUES ('08:20:00');
107 | INSERT INTO TIME_TBL (TIME) VALUES ('08:25:00');
108 | INSERT INTO TIME_TBL (TIME) VALUES ('08:30:00');
109 | INSERT INTO TIME_TBL (TIME) VALUES ('08:35:00');
110 | INSERT INTO TIME_TBL (TIME) VALUES ('08:40:00');
111 | INSERT INTO TIME_TBL (TIME) VALUES ('08:45:00');
112 | INSERT INTO TIME_TBL (TIME) VALUES ('08:50:00');
113 | INSERT INTO TIME_TBL (TIME) VALUES ('08:55:00');
114 | INSERT INTO TIME_TBL (TIME) VALUES ('09:00:00');
115 | INSERT INTO TIME_TBL (TIME) VALUES ('09:05:00');
116 | INSERT INTO TIME_TBL (TIME) VALUES ('09:10:00');
117 | INSERT INTO TIME_TBL (TIME) VALUES ('09:15:00');
118 | INSERT INTO TIME_TBL (TIME) VALUES ('09:20:00');
119 | INSERT INTO TIME_TBL (TIME) VALUES ('09:25:00');
120 | INSERT INTO TIME_TBL (TIME) VALUES ('09:30:00');
121 | INSERT INTO TIME_TBL (TIME) VALUES ('09:35:00');
122 | INSERT INTO TIME_TBL (TIME) VALUES ('09:40:00');
123 | INSERT INTO TIME_TBL (TIME) VALUES ('09:45:00');
124 | INSERT INTO TIME_TBL (TIME) VALUES ('09:50:00');
125 | INSERT INTO TIME_TBL (TIME) VALUES ('09:55:00');
126 | INSERT INTO TIME_TBL (TIME) VALUES ('10:00:00');
127 | INSERT INTO TIME_TBL (TIME) VALUES ('10:05:00');
128 | INSERT INTO TIME_TBL (TIME) VALUES ('10:10:00');
129 | INSERT INTO TIME_TBL (TIME) VALUES ('10:15:00');
130 | INSERT INTO TIME_TBL (TIME) VALUES ('10:20:00');
131 | INSERT INTO TIME_TBL (TIME) VALUES ('10:25:00');
132 | INSERT INTO TIME_TBL (TIME) VALUES ('10:30:00');
133 | INSERT INTO TIME_TBL (TIME) VALUES ('10:35:00');
134 | INSERT INTO TIME_TBL (TIME) VALUES ('10:40:00');
135 | INSERT INTO TIME_TBL (TIME) VALUES ('10:45:00');
136 | INSERT INTO TIME_TBL (TIME) VALUES ('10:50:00');
137 | INSERT INTO TIME_TBL (TIME) VALUES ('10:55:00');
138 | INSERT INTO TIME_TBL (TIME) VALUES ('11:00:00');
139 | INSERT INTO TIME_TBL (TIME) VALUES ('11:05:00');
140 | INSERT INTO TIME_TBL (TIME) VALUES ('11:10:00');
141 | INSERT INTO TIME_TBL (TIME) VALUES ('11:15:00');
142 | INSERT INTO TIME_TBL (TIME) VALUES ('11:20:00');
143 | INSERT INTO TIME_TBL (TIME) VALUES ('11:25:00');
144 | INSERT INTO TIME_TBL (TIME) VALUES ('11:30:00');
145 | INSERT INTO TIME_TBL (TIME) VALUES ('11:35:00');
146 | INSERT INTO TIME_TBL (TIME) VALUES ('11:40:00');
147 | INSERT INTO TIME_TBL (TIME) VALUES ('11:45:00');
148 | INSERT INTO TIME_TBL (TIME) VALUES ('11:50:00');
149 | INSERT INTO TIME_TBL (TIME) VALUES ('11:55:00');
150 | INSERT INTO TIME_TBL (TIME) VALUES ('12:00:00');
151 | INSERT INTO TIME_TBL (TIME) VALUES ('12:05:00');
152 | INSERT INTO TIME_TBL (TIME) VALUES ('12:10:00');
153 | INSERT INTO TIME_TBL (TIME) VALUES ('12:15:00');
154 | INSERT INTO TIME_TBL (TIME) VALUES ('12:20:00');
155 | INSERT INTO TIME_TBL (TIME) VALUES ('12:25:00');
156 | INSERT INTO TIME_TBL (TIME) VALUES ('12:30:00');
157 | INSERT INTO TIME_TBL (TIME) VALUES ('12:35:00');
158 | INSERT INTO TIME_TBL (TIME) VALUES ('12:40:00');
159 | INSERT INTO TIME_TBL (TIME) VALUES ('12:45:00');
160 | INSERT INTO TIME_TBL (TIME) VALUES ('12:50:00');
161 | INSERT INTO TIME_TBL (TIME) VALUES ('12:55:00');
162 | INSERT INTO TIME_TBL (TIME) VALUES ('13:00:00');
163 | INSERT INTO TIME_TBL (TIME) VALUES ('13:05:00');
164 | INSERT INTO TIME_TBL (TIME) VALUES ('13:10:00');
165 | INSERT INTO TIME_TBL (TIME) VALUES ('13:15:00');
166 | INSERT INTO TIME_TBL (TIME) VALUES ('13:20:00');
167 | INSERT INTO TIME_TBL (TIME) VALUES ('13:25:00');
168 | INSERT INTO TIME_TBL (TIME) VALUES ('13:30:00');
169 | INSERT INTO TIME_TBL (TIME) VALUES ('13:35:00');
170 | INSERT INTO TIME_TBL (TIME) VALUES ('13:40:00');
171 | INSERT INTO TIME_TBL (TIME) VALUES ('13:45:00');
172 | INSERT INTO TIME_TBL (TIME) VALUES ('13:50:00');
173 | INSERT INTO TIME_TBL (TIME) VALUES ('13:55:00');
174 | INSERT INTO TIME_TBL (TIME) VALUES ('14:00:00');
175 | INSERT INTO TIME_TBL (TIME) VALUES ('14:05:00');
176 | INSERT INTO TIME_TBL (TIME) VALUES ('14:10:00');
177 | INSERT INTO TIME_TBL (TIME) VALUES ('14:15:00');
178 | INSERT INTO TIME_TBL (TIME) VALUES ('14:20:00');
179 | INSERT INTO TIME_TBL (TIME) VALUES ('14:25:00');
180 | INSERT INTO TIME_TBL (TIME) VALUES ('14:30:00');
181 | INSERT INTO TIME_TBL (TIME) VALUES ('14:35:00');
182 | INSERT INTO TIME_TBL (TIME) VALUES ('14:40:00');
183 | INSERT INTO TIME_TBL (TIME) VALUES ('14:45:00');
184 | INSERT INTO TIME_TBL (TIME) VALUES ('14:50:00');
185 | INSERT INTO TIME_TBL (TIME) VALUES ('14:55:00');
186 | INSERT INTO TIME_TBL (TIME) VALUES ('15:00:00');
187 | INSERT INTO TIME_TBL (TIME) VALUES ('15:05:00');
188 | INSERT INTO TIME_TBL (TIME) VALUES ('15:10:00');
189 | INSERT INTO TIME_TBL (TIME) VALUES ('15:15:00');
190 | INSERT INTO TIME_TBL (TIME) VALUES ('15:20:00');
191 | INSERT INTO TIME_TBL (TIME) VALUES ('15:25:00');
192 | INSERT INTO TIME_TBL (TIME) VALUES ('15:30:00');
193 | INSERT INTO TIME_TBL (TIME) VALUES ('15:35:00');
194 | INSERT INTO TIME_TBL (TIME) VALUES ('15:40:00');
195 | INSERT INTO TIME_TBL (TIME) VALUES ('15:45:00');
196 | INSERT INTO TIME_TBL (TIME) VALUES ('15:50:00');
197 | INSERT INTO TIME_TBL (TIME) VALUES ('15:55:00');
198 | INSERT INTO TIME_TBL (TIME) VALUES ('16:00:00');
199 | INSERT INTO TIME_TBL (TIME) VALUES ('16:05:00');
200 | INSERT INTO TIME_TBL (TIME) VALUES ('16:10:00');
201 | INSERT INTO TIME_TBL (TIME) VALUES ('16:15:00');
202 | INSERT INTO TIME_TBL (TIME) VALUES ('16:20:00');
203 | INSERT INTO TIME_TBL (TIME) VALUES ('16:25:00');
204 | INSERT INTO TIME_TBL (TIME) VALUES ('16:30:00');
205 | INSERT INTO TIME_TBL (TIME) VALUES ('16:35:00');
206 | INSERT INTO TIME_TBL (TIME) VALUES ('16:40:00');
207 | INSERT INTO TIME_TBL (TIME) VALUES ('16:45:00');
208 | INSERT INTO TIME_TBL (TIME) VALUES ('16:50:00');
209 | INSERT INTO TIME_TBL (TIME) VALUES ('16:55:00');
210 | INSERT INTO TIME_TBL (TIME) VALUES ('17:00:00');
211 | INSERT INTO TIME_TBL (TIME) VALUES ('17:05:00');
212 | INSERT INTO TIME_TBL (TIME) VALUES ('17:10:00');
213 | INSERT INTO TIME_TBL (TIME) VALUES ('17:15:00');
214 | INSERT INTO TIME_TBL (TIME) VALUES ('17:20:00');
215 | INSERT INTO TIME_TBL (TIME) VALUES ('17:25:00');
216 | INSERT INTO TIME_TBL (TIME) VALUES ('17:30:00');
217 | INSERT INTO TIME_TBL (TIME) VALUES ('17:35:00');
218 | INSERT INTO TIME_TBL (TIME) VALUES ('17:40:00');
219 | INSERT INTO TIME_TBL (TIME) VALUES ('17:45:00');
220 | INSERT INTO TIME_TBL (TIME) VALUES ('17:50:00');
221 | INSERT INTO TIME_TBL (TIME) VALUES ('17:55:00');
222 | INSERT INTO TIME_TBL (TIME) VALUES ('18:00:00');
223 | INSERT INTO TIME_TBL (TIME) VALUES ('18:05:00');
224 | INSERT INTO TIME_TBL (TIME) VALUES ('18:10:00');
225 | INSERT INTO TIME_TBL (TIME) VALUES ('18:15:00');
226 | INSERT INTO TIME_TBL (TIME) VALUES ('18:20:00');
227 | INSERT INTO TIME_TBL (TIME) VALUES ('18:25:00');
228 | INSERT INTO TIME_TBL (TIME) VALUES ('18:30:00');
229 | INSERT INTO TIME_TBL (TIME) VALUES ('18:35:00');
230 | INSERT INTO TIME_TBL (TIME) VALUES ('18:40:00');
231 | INSERT INTO TIME_TBL (TIME) VALUES ('18:45:00');
232 | INSERT INTO TIME_TBL (TIME) VALUES ('18:50:00');
233 | INSERT INTO TIME_TBL (TIME) VALUES ('18:55:00');
234 | INSERT INTO TIME_TBL (TIME) VALUES ('19:00:00');
235 | INSERT INTO TIME_TBL (TIME) VALUES ('19:05:00');
236 | INSERT INTO TIME_TBL (TIME) VALUES ('19:10:00');
237 | INSERT INTO TIME_TBL (TIME) VALUES ('19:15:00');
238 | INSERT INTO TIME_TBL (TIME) VALUES ('19:20:00');
239 | INSERT INTO TIME_TBL (TIME) VALUES ('19:25:00');
240 | INSERT INTO TIME_TBL (TIME) VALUES ('19:30:00');
241 | INSERT INTO TIME_TBL (TIME) VALUES ('19:35:00');
242 | INSERT INTO TIME_TBL (TIME) VALUES ('19:40:00');
243 | INSERT INTO TIME_TBL (TIME) VALUES ('19:45:00');
244 | INSERT INTO TIME_TBL (TIME) VALUES ('19:50:00');
245 | INSERT INTO TIME_TBL (TIME) VALUES ('19:55:00');
246 | INSERT INTO TIME_TBL (TIME) VALUES ('20:00:00');
247 | INSERT INTO TIME_TBL (TIME) VALUES ('20:05:00');
248 | INSERT INTO TIME_TBL (TIME) VALUES ('20:10:00');
249 | INSERT INTO TIME_TBL (TIME) VALUES ('20:15:00');
250 | INSERT INTO TIME_TBL (TIME) VALUES ('20:20:00');
251 | INSERT INTO TIME_TBL (TIME) VALUES ('20:25:00');
252 | INSERT INTO TIME_TBL (TIME) VALUES ('20:30:00');
253 | INSERT INTO TIME_TBL (TIME) VALUES ('20:35:00');
254 | INSERT INTO TIME_TBL (TIME) VALUES ('20:40:00');
255 | INSERT INTO TIME_TBL (TIME) VALUES ('20:45:00');
256 | INSERT INTO TIME_TBL (TIME) VALUES ('20:50:00');
257 | INSERT INTO TIME_TBL (TIME) VALUES ('20:55:00');
258 | INSERT INTO TIME_TBL (TIME) VALUES ('21:00:00');
259 | INSERT INTO TIME_TBL (TIME) VALUES ('21:05:00');
260 | INSERT INTO TIME_TBL (TIME) VALUES ('21:10:00');
261 | INSERT INTO TIME_TBL (TIME) VALUES ('21:15:00');
262 | INSERT INTO TIME_TBL (TIME) VALUES ('21:20:00');
263 | INSERT INTO TIME_TBL (TIME) VALUES ('21:25:00');
264 | INSERT INTO TIME_TBL (TIME) VALUES ('21:30:00');
265 | INSERT INTO TIME_TBL (TIME) VALUES ('21:35:00');
266 | INSERT INTO TIME_TBL (TIME) VALUES ('21:40:00');
267 | INSERT INTO TIME_TBL (TIME) VALUES ('21:45:00');
268 | INSERT INTO TIME_TBL (TIME) VALUES ('21:50:00');
269 | INSERT INTO TIME_TBL (TIME) VALUES ('21:55:00');
270 | INSERT INTO TIME_TBL (TIME) VALUES ('22:00:00');
271 | INSERT INTO TIME_TBL (TIME) VALUES ('22:05:00');
272 | INSERT INTO TIME_TBL (TIME) VALUES ('22:10:00');
273 | INSERT INTO TIME_TBL (TIME) VALUES ('22:15:00');
274 | INSERT INTO TIME_TBL (TIME) VALUES ('22:20:00');
275 | INSERT INTO TIME_TBL (TIME) VALUES ('22:25:00');
276 | INSERT INTO TIME_TBL (TIME) VALUES ('22:30:00');
277 | INSERT INTO TIME_TBL (TIME) VALUES ('22:35:00');
278 | INSERT INTO TIME_TBL (TIME) VALUES ('22:40:00');
279 | INSERT INTO TIME_TBL (TIME) VALUES ('22:45:00');
280 | INSERT INTO TIME_TBL (TIME) VALUES ('22:50:00');
281 | INSERT INTO TIME_TBL (TIME) VALUES ('22:55:00');
282 | INSERT INTO TIME_TBL (TIME) VALUES ('23:00:00');
283 | INSERT INTO TIME_TBL (TIME) VALUES ('23:05:00');
284 | INSERT INTO TIME_TBL (TIME) VALUES ('23:10:00');
285 | INSERT INTO TIME_TBL (TIME) VALUES ('23:15:00');
286 | INSERT INTO TIME_TBL (TIME) VALUES ('23:20:00');
287 | INSERT INTO TIME_TBL (TIME) VALUES ('23:25:00');
288 | INSERT INTO TIME_TBL (TIME) VALUES ('23:30:00');
289 | INSERT INTO TIME_TBL (TIME) VALUES ('23:35:00');
290 | INSERT INTO TIME_TBL (TIME) VALUES ('23:40:00');
291 | INSERT INTO TIME_TBL (TIME) VALUES ('23:45:00');
292 | INSERT INTO TIME_TBL (TIME) VALUES ('23:50:00');
293 | INSERT INTO TIME_TBL (TIME) VALUES ('23:55:00');
--------------------------------------------------------------------------------
/src/main/resources/mybatis-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------