1717
1818package 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-
3020import scouter .Version ;
3121import scouter .agent .netio .data .DataProxy ;
3222import scouter .lang .conf .ConfObserver ;
3525import scouter .lang .value .ListValue ;
3626import scouter .lang .value .MapValue ;
3727import 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
4936public 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}
0 commit comments