Skip to content

Commit a7d8d99

Browse files
committed
Merge pull request #69 from scouter-project/master
merge for release
2 parents 715f7ed + 8aa057e commit a7d8d99

File tree

198 files changed

+4370
-2416
lines changed

Some content is hidden

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

198 files changed

+4370
-2416
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
scouter.agent.java/bin/*
22
scouter.client/bin/*
33
scouter.common/bin/*
4+
scouter.common/bin-test/*
45
scouter.server/bin/*
6+
scouter.server/bin-test/*
57
scouter.deploy/out
68
*/.cache
79
*/.svn
@@ -29,6 +31,8 @@ scouter.server/database/
2931
scouter.client.product/plugin_customization.ini
3032
scouter.client/plugin_customization.ini
3133

34+
*/*.scouter
35+
3236
### Vim template
3337
[._]*.s[a-w][a-z]
3438
[._]s[a-w][a-z]

scouter.agent.host/scripts/host.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
mkdir logs > /dev/null 2>&1
2-
cp nohup.out ./logs/nohup.$(date '+%Y%m%d%H%M%S').out > /dev/null 2>&1
1+
#!/usr/bin/env bash
2+
33
nohup java -classpath ./scouter.host.jar scouter.boot.Boot ./lib > nohup.out &
4-
echo "Scouter host agent launching..."
5-
echo "See the nohup.out."
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
mkdir logs > /dev/null 2>&1
3+
cp nohup.out ./logs/nohup.$(date '+%Y%m%d%H%M%S').out > /dev/null 2>&1
4+
nohup java -classpath ./scouter.host.jar scouter.boot.Boot ./lib > nohup.out &
5+
echo "Scouter host agent launching..."
6+
echo "See the nohup.out."

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

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@
1717

1818
package scouter.agent;
1919

20-
import java.io.File;
21-
import java.io.FileInputStream;
22-
import java.io.FileOutputStream;
23-
import java.io.InputStream;
24-
import java.io.OutputStream;
25-
import java.util.HashMap;
26-
import java.util.HashSet;
27-
import java.util.Map;
28-
import java.util.Properties;
29-
3020
import scouter.Version;
3121
import scouter.agent.netio.data.DataProxy;
3222
import scouter.lang.conf.ConfObserver;
@@ -35,20 +25,16 @@
3525
import scouter.lang.value.ListValue;
3626
import scouter.lang.value.MapValue;
3727
import scouter.net.NetConstants;
38-
import scouter.util.DateUtil;
39-
import scouter.util.FileUtil;
40-
import scouter.util.HashUtil;
41-
import scouter.util.StringEnumer;
42-
import scouter.util.StringKeyLinkedMap;
43-
import scouter.util.StringSet;
44-
import scouter.util.StringUtil;
45-
import scouter.util.SysJMX;
46-
import scouter.util.SystemUtil;
47-
import scouter.util.ThreadUtil;
28+
import scouter.util.*;
29+
30+
import java.io.*;
31+
import java.util.HashMap;
32+
import java.util.HashSet;
33+
import java.util.Map;
34+
import java.util.Properties;
4835

4936
public class Configure extends Thread {
5037

51-
public static boolean JDBC_REDEFINED = false;
5238
private static Configure instance = null;
5339
public final static String CONF_DIR = "./conf/";
5440

@@ -62,53 +48,59 @@ public final static synchronized Configure getInstance() {
6248
return instance;
6349
}
6450

65-
public String local_udp_addr = null;
66-
public int local_udp_port;
67-
68-
public String server_addr = "127.0.0.1";
69-
public int server_udp_port = NetConstants.SERVER_UDP_PORT;
70-
public int server_tcp_port = NetConstants.SERVER_TCP_PORT;
71-
public int server_tcp_session_count = 1;
72-
public int server_tcp_so_timeout = 60000;
73-
public int server_tcp_connection_timeout = 3000;
74-
75-
public String scouter_type = "";
76-
public String scouter_name = "";
77-
78-
public int objHash;
79-
public String objName;
80-
81-
public int udp_packet_max = 60000;
82-
public StringSet log_ignore = new StringSet();
83-
public int max_concurrent_server_request = 10;
84-
85-
public boolean enable_counter_task = true;
86-
public boolean debug_udp_object = false;
87-
88-
public boolean log_rotation = true;
89-
public String logs_dir = "./logs";
90-
public int log_keep_dates = 365;
91-
92-
public String object_registry = "/tmp/scouter";
93-
51+
//Network
52+
public String net_local_udp_ip = null;
53+
public int net_local_udp_port;
54+
public String net_collector_ip = "127.0.0.1";
55+
public int net_collector_udp_port = NetConstants.SERVER_UDP_PORT;
56+
public int net_collector_tcp_port = NetConstants.SERVER_TCP_PORT;
57+
public int net_collector_tcp_session_count = 1;
58+
public int net_collector_tcp_so_timeout_ms = 60000;
59+
public int net_collector_tcp_connection_timeout_ms = 3000;
60+
public int net_udp_packet_max_bytes = 60000;
61+
62+
//Object
63+
public String obj_type = "";
64+
public String obj_name = "";
65+
66+
//Manager
67+
public StringSet mgr_log_ignore_ids = new StringSet();
68+
69+
//Counter
70+
public boolean counter_enabled = true;
71+
public String counter_object_registry_path = "/tmp/scouter";
72+
73+
//Log
74+
public boolean log_udp_object = false;
75+
public boolean log_rotation_enalbed = true;
76+
public String log_dir = "./logs";
77+
public int log_keep_days = 365;
78+
79+
//Disk
9480
public boolean disk_alert_enabled = true;
9581
public int disk_warning_pct = 70;
9682
public int disk_fatal_pct = 90;
97-
public StringSet disk_ignore = new StringSet();
83+
public StringSet disk_ignore_names = new StringSet();
9884

85+
//Cpu
9986
public boolean cpu_alert_enabled = true;
100-
public long cpu_check_period = 300000;
101-
public long cpu_alert_interval = 30000;
87+
public long cpu_check_period_ms = 300000;
88+
public long cpu_alert_interval_ms = 30000;
10289
public int cpu_warning_pct = 70;
10390
public int cpu_fatal_pct = 90;
10491
public int cpu_warning_history = 3;
10592
public int cpu_fatal_history = 3;
10693

94+
//Memory
10795
public boolean mem_alert_enabled = true;
108-
public long mem_alert_interval = 30000;
96+
public long mem_alert_interval_ms = 30000;
10997
public int mem_warning_pct = 80;
11098
public int mem_fatal_pct = 90;
11199

100+
//internal variables
101+
private int objHash;
102+
private String objName;
103+
112104
private Configure() {
113105
Properties p = new Properties();
114106
Map args = new HashMap();
@@ -189,44 +181,43 @@ public synchronized boolean reload(boolean force) {
189181

190182
private void apply() {
191183

192-
this.udp_packet_max = getInt("udp_packet_max", getInt("udp.packet.max", 60000));
193-
this.log_ignore = getStringSet("log_ignore", ",");
184+
this.net_udp_packet_max_bytes = getInt("net_udp_packet_max_bytes", getInt("udp.packet.max", 60000));
185+
this.mgr_log_ignore_ids = getStringSet("mgr_log_ignore_ids", ",");
194186

195-
this.local_udp_addr = getValue("local_udp_addr");
196-
this.local_udp_port = getInt("local_udp_port", 0);
187+
this.net_local_udp_ip = getValue("net_local_udp_ip");
188+
this.net_local_udp_port = getInt("net_local_udp_port", 0);
197189

198-
this.server_addr = getValue("server_addr", getValue("server.addr", "127.0.0.1"));
199-
this.server_udp_port = getInt("server_udp_port", getInt("server.port", NetConstants.SERVER_UDP_PORT));
200-
this.server_tcp_port = getInt("server_tcp_port", getInt("server.port", NetConstants.SERVER_TCP_PORT));
201-
this.server_tcp_session_count = getInt("server_tcp_session_count", 1, 1);
202-
this.server_tcp_connection_timeout = getInt("server_tcp_connection_timeout", 3000);
203-
this.server_tcp_so_timeout = getInt("server_tcp_so_timeout", 60000);
190+
this.net_collector_ip = getValue("net_collector_ip", getValue("server.addr", "127.0.0.1"));
191+
this.net_collector_udp_port = getInt("net_collector_udp_port", getInt("server.port", NetConstants.SERVER_UDP_PORT));
192+
this.net_collector_tcp_port = getInt("net_collector_tcp_port", getInt("server.port", NetConstants.SERVER_TCP_PORT));
193+
this.net_collector_tcp_session_count = getInt("net_collector_tcp_session_count", 1, 1);
194+
this.net_collector_tcp_connection_timeout_ms = getInt("net_collector_tcp_connection_timeout_ms", 3000);
195+
this.net_collector_tcp_so_timeout_ms = getInt("net_collector_tcp_so_timeout_ms", 60000);
204196

205-
this.max_concurrent_server_request = getInt("max_concurrent_server_request", 10);
206-
this.enable_counter_task = getBoolean("enable_counter_task", true);
207-
this.debug_udp_object = getBoolean("debug_udp_object", false);
197+
this.counter_enabled = getBoolean("counter_enabled", true);
198+
this.log_udp_object = getBoolean("log_udp_object", false);
208199

209-
this.logs_dir = getValue("logs_dir", "./logs");
210-
this.log_rotation = getBoolean("log_rotation", true);
211-
this.log_keep_dates = getInt("log_keep_dates", 365);
200+
this.log_dir = getValue("log_dir", "./logs");
201+
this.log_rotation_enalbed = getBoolean("log_rotation_enalbed", true);
202+
this.log_keep_days = getInt("log_keep_days", 365);
212203

213-
this.object_registry = getValue("object_registry", "/tmp/scouter");
204+
this.counter_object_registry_path = getValue("counter_object_registry_path", "/tmp/scouter");
214205

215206
this.disk_alert_enabled = getBoolean("disk_alert_enablee", true);
216207
this.disk_warning_pct = getInt("disk_warning_pct", 70);
217208
this.disk_fatal_pct = getInt("disk_fatal_pct", 90);
218-
this.disk_ignore = getStringSet("disk_ignore", ",");
209+
this.disk_ignore_names = getStringSet("disk_ignore_names", ",");
219210

220211
this.cpu_alert_enabled = getBoolean("cpu_alert_enabled", true);
221-
this.cpu_check_period = getLong("cpu_check_period", 300000);
222-
this.cpu_alert_interval = getLong("cpu_alert_interval", 30000);
212+
this.cpu_check_period_ms = getLong("cpu_check_period_ms", 300000);
213+
this.cpu_alert_interval_ms = getLong("cpu_alert_interval_ms", 30000);
223214
this.cpu_warning_pct = getInt("cpu_warning_pct", 70);
224215
this.cpu_fatal_pct = getInt("cpu_fatal_pct", 90);
225216
this.cpu_warning_history = getInt("cpu_warning_history", 3);
226217
this.cpu_fatal_history = getInt("cpu_fatal_history", 3);
227218

228219
this.mem_alert_enabled = getBoolean("mem_alert_enabled", true);
229-
this.mem_alert_interval = getLong("mem_alert_interval", 30000);
220+
this.mem_alert_interval_ms = getLong("mem_alert_interval_ms", 30000);
230221
this.mem_warning_pct = getInt("mem_warning_pct", 80);
231222
this.mem_fatal_pct = getInt("mem_fatal_pct", 90);
232223

@@ -261,10 +252,10 @@ public synchronized void resetObjInfo() {
261252
} else if (SystemUtil.IS_HP_UX) {
262253
detected = CounterConstants.HPUX;
263254
}
264-
this.scouter_type = getValue("scouter_type", detected);
265-
this.scouter_name = getValue("scouter_name", SysJMX.getHostName());
255+
this.obj_type = getValue("obj_type", detected);
256+
this.obj_name = getValue("obj_name", SysJMX.getHostName());
266257

267-
this.objName = "/" + this.scouter_name;
258+
this.objName = "/" + this.obj_name;
268259
this.objHash = HashUtil.hash(objName);
269260

270261
}
@@ -318,6 +309,14 @@ public boolean getBoolean(String key, boolean def) {
318309
return def;
319310
}
320311

312+
public int getObjHash() {
313+
return this.objHash;
314+
}
315+
316+
public String getObjName() {
317+
return this.objName;
318+
}
319+
321320
public String loadText() {
322321
File file = getPropertyFile();
323322
InputStream fin = null;
@@ -354,9 +353,6 @@ public void printConfig() {
354353

355354
static {
356355
ignoreSet.add("property");
357-
ignoreSet.add("objHash");
358-
ignoreSet.add("objName");
359-
ignoreSet.add("objType");
360356
}
361357

362358
public MapValue getKeyValueInfo() {
@@ -381,6 +377,13 @@ public MapValue getKeyValueInfo() {
381377
}
382378

383379
public static void main(String[] args) {
384-
System.out.println(Configure.getInstance().getKeyValueInfo().toString().replace(',', '\n'));
380+
StringKeyLinkedMap<Object> defMap = ConfigValueUtil.getConfigDefault(new Configure(true));
381+
StringEnumer enu = defMap.keys();
382+
while (enu.hasMoreElements()) {
383+
String key = enu.nextString();
384+
if (ignoreSet.contains(key))
385+
continue;
386+
System.out.println(key + " : " + ConfigValueUtil.toValue(defMap.get(key)));
387+
}
385388
}
386389
}

scouter.agent.host/src/scouter/agent/Logger.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static String getCallStack(Throwable t) {
7878
}
7979

8080
private static boolean checkOk(String id, int sec) {
81-
if (Configure.getInstance().log_ignore.hasKey(id))
81+
if (Configure.getInstance().mgr_log_ignore_ids.hasKey(id))
8282
return false;
8383
if (sec > 0) {
8484
long last = lastLog.get(id);
@@ -138,10 +138,10 @@ public void run() {
138138
static {
139139
ConfObserver.add(Logger.class.getName(), new Runnable() {
140140
public void run() {
141-
if (CompareUtil.equals(lastDir, conf.logs_dir) == false || lastFileRotation != conf.log_rotation) {
141+
if (CompareUtil.equals(lastDir, conf.log_dir) == false || lastFileRotation != conf.log_rotation_enalbed) {
142142
pw = (PrintWriter) FileUtil.close(pw);
143-
lastDir = conf.logs_dir;
144-
lastFileRotation = conf.log_rotation;
143+
lastDir = conf.log_dir;
144+
lastFileRotation = conf.log_rotation_enalbed;
145145
}
146146
}
147147
});
@@ -153,27 +153,27 @@ public void run() {
153153
private static synchronized void openFile() throws IOException {
154154
if (pw == null) {
155155
lastDataUnit = DateUtil.getDateUnit();
156-
lastDir = conf.logs_dir;
157-
lastFileRotation = conf.log_rotation;
156+
lastDir = conf.log_dir;
157+
lastFileRotation = conf.log_rotation_enalbed;
158158

159159
new File(lastDir).mkdirs();
160-
if (conf.log_rotation) {
161-
FileWriter fw = new FileWriter(new File(conf.logs_dir, "agent-" + DateUtil.yyyymmdd() + ".log"), true);
160+
if (conf.log_rotation_enalbed) {
161+
FileWriter fw = new FileWriter(new File(conf.log_dir, "agent-" + DateUtil.yyyymmdd() + ".log"), true);
162162
pw = new PrintWriter(fw);
163163
} else {
164-
pw = new PrintWriter(new File(conf.logs_dir, "agent.log"));
164+
pw = new PrintWriter(new File(conf.log_dir, "agent.log"));
165165
}
166166
lastDataUnit = DateUtil.getDateUnit();
167167
}
168168
}
169169

170170
protected static void clearOldLog() {
171-
if (conf.log_rotation == false)
171+
if (conf.log_rotation_enalbed == false)
172172
return;
173-
if (conf.log_keep_dates <= 0)
173+
if (conf.log_keep_days <= 0)
174174
return;
175175
long nowUnit = DateUtil.getDateUnit();
176-
File dir = new File(conf.logs_dir);
176+
File dir = new File(conf.log_dir);
177177
File[] files = dir.listFiles();
178178
for (int i = 0; i < files.length; i++) {
179179
if (files[i].isDirectory())
@@ -191,7 +191,7 @@ protected static void clearOldLog() {
191191
try {
192192
long d = DateUtil.yyyymmdd(date);
193193
long fileUnit = DateUtil.getDateUnit(d);
194-
if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_dates) {
194+
if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_days) {
195195
files[i].delete();
196196
}
197197
} catch (Exception e) {

0 commit comments

Comments
 (0)