this.net_udp_packet_max_bytes = getInt("net_udp_packet_max_bytes", getInt("udp.packet.max", 60000)); this.mgr_log_ignore_ids = getStringSet("mgr_log_ignore_ids", ","); this.net_local_udp_ip = getValue("net_local_udp_ip"); this.net_local_udp_port = getInt("net_local_udp_port", 0); this.net_collector_ip = getValue("net_collector_ip", getValue("server.addr", "127.0.0.1")); this.net_collector_udp_port = getInt("net_collector_udp_port", getInt("server.port", NetConstants.SERVER_UDP_PORT)); this.net_collector_tcp_port = getInt("net_collector_tcp_port", getInt("server.port", NetConstants.SERVER_TCP_PORT)); this.net_collector_tcp_session_count = getInt("net_collector_tcp_session_count", 1, 1); this.net_collector_tcp_connection_timeout_ms = getInt("net_collector_tcp_connection_timeout_ms", 3000); this.net_collector_tcp_so_timeout_ms = getInt("net_collector_tcp_so_timeout_ms", 60000); this.counter_enabled = getBoolean("counter_enabled", true); this.log_udp_object = getBoolean("log_udp_object", false); this.counter_netstat_enabled = getBoolean("counter_netstat_enabled", true); this.log_dir = getValue("log_dir", "./logs"); this.log_rotation_enalbed = getBoolean("log_rotation_enalbed", true); this.log_keep_days = getInt("log_keep_days", 365); this.counter_object_registry_path = getValue("counter_object_registry_path", "/tmp/scouter"); this.disk_alert_enabled = getBoolean("disk_alert_enabled", true); this.disk_warning_pct = getInt("disk_warning_pct", 70); this.disk_fatal_pct = getInt("disk_fatal_pct", 90); this.disk_ignore_names = getStringSet("disk_ignore_names", ","); this.cpu_alert_enabled = getBoolean("cpu_alert_enabled", true);
private ObjectPack getMainObject() { Configure conf = Configure.getInstance(); ObjectPack p = new ObjectPack(); p.objType = conf.obj_type; p.objHash = conf.getObjHash(); p.objName = conf.getObjName(); p.version = Version.getAgentFullVersion(); p.address = TcpWorker.localAddr; if(StringUtil.isNotEmpty(conf.getObjDetectedType())){ p.tags.put(TAG_OBJ_DETECTED_TYPE, conf.getObjDetectedType()); } return p; }
public static boolean isStaticContents(String serviceName) { int x = serviceName.lastIndexOf('.'); if (x <= 0) return false; try { String ext = serviceName.substring(x + 1); return Configure.getInstance().isStaticContents(ext); } catch (Exception e) { return false; } }
public void process(CounterBasket pw) throws IOException { Configure conf = Configure.getInstance(); boolean redisEnabled = conf.getBoolean("redis_enabled", false); if (redisEnabled) { String serverIp = conf.getValue("redis_server_ip", "127.0.0.1"); int serverPort = conf.getInt("redis_server_port", 6379); String perfInfo = getRedisPerfInfo(serverIp, serverPort); String[] lines = perfInfo.split("\n"); PerfCounterPack p = pw.getPack(conf.getObjName(), TimeTypeEnum.REALTIME); for (String line : lines) { String key = line.substring(0, line.indexOf(':')); String value = line.substring(line.indexOf(':') + 1); if (floatSet.contains(key)) { p.put(key, new FloatValue(Float.valueOf(value.trim()))); } if (decimalSet.contains(key)) { p.put(key, new DecimalValue(Long.valueOf(value.trim()))); } } } }
private String getReqProcType() { if (Configure.getInstance().obj_type_inherit_to_child_enabled) { return Configure.getInstance().obj_type + "_req"; } return CounterConstants.REQUESTPROCESS; } private String getDataSourceType() {
@RequestHandler(RequestCmd.GET_CONFIGURE_WAS) public Pack getAgentConfigure(Pack param) { MapPack p = new MapPack(); p.put("configKey", Configure.getInstance().getKeyValueInfo().getList("key")); String config = Configure.getInstance().loadText(); if (config == null) { //config = getEmptyConfiguration(); config = ""; } p.put("agentConfig", config); return p; }
@RequestHandler(RequestCmd.SET_CONFIGURE_WAS) public Pack setAgentConfigure(Pack param) { final String setConfig = ((MapPack) param).getText("setConfig"); boolean success = Configure.getInstance().saveText(setConfig); if (success) { Configure.getInstance().reload(true); } MapPack p = new MapPack(); p.put("result", String.valueOf(success)); return p; }
@RequestHandler(RequestCmd.CONFIGURE_VALUE_TYPE) public Pack getConfigureValueType(Pack param) { StringKeyLinkedMap<ValueType> valueTypeMap = Configure.getInstance().getConfigureValueType(); MapPack pack = new MapPack(); Enumeration<StringKeyLinkedEntry<ValueType>> entries = valueTypeMap.entries(); while (entries.hasMoreElements()) { StringKeyLinkedEntry<ValueType> entry = entries.nextElement(); pack.put(entry.getKey(), entry.getValue().getType()); } return pack; } }
@RequestHandler(RequestCmd.LIST_CONFIGURE_WAS) public Pack listConfigure(Pack param) { MapValue m = Configure.getInstance().getKeyValueInfo(); MapPack pack = new MapPack(); pack.put("key", m.getList("key")); pack.put("value", m.getList("value")); pack.put("default", m.getList("default")); return pack; }
@RequestHandler(RequestCmd.CONFIGURE_DESC) public Pack getConfigureDesc(Pack param) { StringKeyLinkedMap<String> descMap = Configure.getInstance().getConfigureDesc(); MapPack pack = new MapPack(); Enumeration<StringKeyLinkedEntry<String>> entries = descMap.entries(); while (entries.hasMoreElements()) { StringKeyLinkedEntry<String> entry = entries.nextElement(); pack.put(entry.getKey(), entry.getValue()); } return pack; }
public synchronized boolean reload(boolean force) { long now = System.currentTimeMillis(); if (force == false && now < last_check + 3000) return false; last_check = now; File file = getPropertyFile(); if (file.lastModified() == last_load_time) { return false; } last_load_time = file.lastModified(); Properties temp = new Properties(); if (file.canRead()) { FileInputStream in = null; try { in = new FileInputStream(file); temp.load(in); } catch (Exception e) { e.printStackTrace(); } finally { FileUtil.close(in); } } property = ConfigValueUtil.replaceSysProp(temp); apply(); ConfObserver.run(); return true; }
public synchronized static void boot() { if (booted) return; booted = true; TcpRequestMgr.getInstance(); CounterExecutingManager.load(); ReqestHandlingProxy.load(); Configure.getInstance().printConfig(); long seed =System.currentTimeMillis() ^ (((long)SysJMX.getProcessPID())<<32); KeyGen.setSeed(seed); Logger.println("A10", "host agent boot seed="+Hexa32.toString32(seed)); } public static void main(String[] args) {
this.monitoring_group_type = getValue("monitoring_group_type"); this.obj_type = StringUtil.isEmpty(this.monitoring_group_type) ? getValue("obj_type", detected) : this.monitoring_group_type; this.objExtType = ObjTypeDetector.objExtType; detected = CounterConstants.HPUX; this.obj_host_type = getValue("obj_host_type", detected); this.obj_host_name = getValue("obj_host_name", SysJMX.getHostName()); this.objHostName = "/" + this.obj_host_name; this.objHostHash = HashUtil.hash(objHostName); this.obj_name_auto_pid_enabled = getBoolean("obj_name_auto_pid_enabled", false); String defaultName; if (this.obj_name_auto_pid_enabled == true) { defaultName = this.obj_type + "1"; this.obj_name = getValue("obj_name", System.getProperty("jvmRoute", defaultName)); this.objName = objHostName + "/" + this.obj_name; this.objHash = HashUtil.hash(objName);
public static void main(String[] args) { Configure o = new Configure(true); StringKeyLinkedMap<Object> defMap = ConfigValueUtil.getConfigDefault(o); StringKeyLinkedMap<String> descMap = ConfigValueUtil.getConfigDescMap(o); StringEnumer enu = defMap.keys(); while (enu.hasMoreElements()) { String key = enu.nextString(); if (ignoreSet.contains(key)) continue; System.out.println(key + " : " + ConfigValueUtil.toValue(defMap.get(key)) + (descMap.containsKey(key) ? " (" + descMap.get(key) + ")" : "")); } } }
private static boolean checkOk(String id, int sec) { if (Configure.getInstance().isIgnoreLog(id)) return false; if (sec > 0) { long last = lastLog.get(id); long now = System.currentTimeMillis(); if (now < last + sec * 1000) return false; lastLog.put(id, now); } return true; }
long now = DateUtil.getMinUnit(time) / 5; if(conf.getBoolean("_dev_summary_test", false)) { now = time / 1000 / 15;
private String getDataSourceType() { if (Configure.getInstance().obj_type_inherit_to_child_enabled) { return Configure.getInstance().obj_type + "_ds"; } return CounterConstants.DATASOURCE; } private void add(String objName, ObjectName mbean, String type, byte decimal, String attrName, String counterName) {
@RequestHandler(RequestCmd.GET_CONFIGURE_WAS) public Pack getAgentConfigure(Pack param) { MapPack p = new MapPack(); p.put("configKey", Configure.getInstance().getKeyValueInfo().getList("key")); String config = Configure.getInstance().loadText(); if (config == null) { //config = getEmptyConfiguration(); config = ""; } p.put("agentConfig", config); return p; }
@RequestHandler(RequestCmd.SET_CONFIGURE_WAS) public Pack setAgentConfigure(Pack param) { final String setConfig = ((MapPack) param).getText("setConfig"); boolean success = Configure.getInstance().saveText(setConfig); if (success) { Configure.getInstance().reload(true); } MapPack p = new MapPack(); p.put("result", String.valueOf(success)); return p; }