• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServerPlugin类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中scouter.lang.plugin.annotation.ServerPlugin的典型用法代码示例。如果您正苦于以下问题:Java ServerPlugin类的具体用法?Java ServerPlugin怎么用?Java ServerPlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServerPlugin类属于scouter.lang.plugin.annotation包,在下文中一共展示了ServerPlugin类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: xlog

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_XLOG)
public void xlog(XLogPack pack) {
	if (conf.getBoolean("ext_plugin_teamup_xlog_enabled", true)) {
		println("[ext_plugin_teamup_xlog_enabled true]");
		if (pack.error != 0) {
			String date = DateUtil.yyyymmdd(pack.endTime);
			String service = TextRD.getString(date, TextTypes.SERVICE, pack.service);
			String patterns = conf.getValue("ext_plugin_teamup_error_escape_method_patterns").length()>0?conf.getValue("ext_plugin_teamup_error_escape_method_patterns"):"*";
			if (!PatternsUtil.isValid(patterns, service)) {
				AlertPack ap = new AlertPack();
				ap.level = AlertLevel.ERROR;
				ap.objHash = pack.objHash;
				ap.title = "Ultron Error";
				ap.message = service + " - " + TextRD.getString(date, TextTypes.ERROR, pack.error);
				ap.time = System.currentTimeMillis();
				ap.objType = "scouter";
				alert(ap);
			}else{
				println("escape service : " + service);
			}
		}
	}
}
 
开发者ID:kingbbode,项目名称:scouter-plugin-server-alert-teamup,代码行数:24,代码来源:TeamUpPlugin.java


示例2: xlog

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
/**
   * XLogPack 발생 시 처리
   * @param pack
   */
  @ServerPlugin(PluginConstants.PLUGIN_SERVER_XLOG)
  public void xlog(XLogPack pack) {
  	try {
   	if (serviceStatMap.get(pack.objHash) == null) {
   		serviceStatMap.put(pack.objHash, new ConcurrentHashMap<Integer, ServiceStat>());
   	}
   	
   	if (serviceStatMap.get(pack.objHash).get(pack.service) == null) {
   		serviceStatMap.get(pack.objHash).put(pack.service, new ServiceStat(pack.objHash, pack.service));
   	}

   	String serviceName = TextRD.getString(DateUtil.yyyymmdd(pack.endTime), TextTypes.SERVICE, pack.service);
  		InetAddress inetAddr = InetAddress.getByAddress(pack.ipaddr);
  		serviceStatMap.get(pack.objHash).get(pack.service).add(serviceName, pack.elapsed, pack.error != 0, inetAddr == null ? null : inetAddr.getHostAddress(), pack.userAgent, pack.sqlCount, pack.sqlTime);
} catch (Exception e) {
	Logger.printStackTrace(e);
}
  }
 
开发者ID:OpenSourceConsulting,项目名称:scouter-plugin-server-reporting,代码行数:23,代码来源:ReportingPlugin.java


示例3: xlog

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_XLOG)
  public void xlog(XLogPack pack) {
  	try {
  		int elapsedThreshold = conf.getInt("ext_plugin_elapsed_time_threshold", 0);
  		
  		if (elapsedThreshold != 0 && pack.elapsed > elapsedThreshold) {
  			String serviceName = TextRD.getString(DateUtil.yyyymmdd(pack.endTime), TextTypes.SERVICE, pack.service);
  			
  			AlertPack ap = new AlertPack();
  			
        ap.level = AlertLevel.WARN;
        ap.objHash = pack.objHash;
        ap.title = "Elapsed time exceed a threshold.";
        ap.message = "[" + AgentManager.getAgentName(pack.objHash) + "] " 
        				+ pack.service + "(" + serviceName + ") "
        				+ "elapsed time(" + pack.elapsed + " ms) exceed a threshold.";
        ap.time = System.currentTimeMillis();
        ap.objType = AgentManager.getAgent(pack.objHash).objType;
		
        alert(ap);
  		}
  		
} catch (Exception e) {
	Logger.printStackTrace(e);
}
  }
 
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-email,代码行数:27,代码来源:EmailPlugin.java


示例4: loadPlugins

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
public static void loadPlugins() {
    Set<String> classNames = new Scanner("scouter.plugin.server").process();

    Iterator<String> itr = classNames.iterator();

    while (itr.hasNext()) {
        try {
            Class c = Class.forName(itr.next());
            if (!Modifier.isPublic(c.getModifiers()))
                continue;

            Method[] m = c.getDeclaredMethods();
            for (int i = 0; i < m.length; i++) {
                ServerPlugin annotation = m[i].getAnnotation(ServerPlugin.class);
                if (annotation == null)
                    continue;

                String pluginPoint = annotation.value();
                List<PluginInvocation> pluginList = pluginMap.get(pluginPoint);

                if(pluginList == null) {
                    pluginList = new ArrayList<PluginInvocation>();
                    pluginMap.put(pluginPoint, pluginList);
                }

                Logger.println("[BuiltInPlugin]" + c.getName() + "=>" + m[i].getName());
                pluginList.add(new PluginInvocation(c.newInstance(), m[i]));
            }
        } catch (Throwable t) {
            Logger.println("Server Plugin Load Error");
            if(Configure.getInstance()._trace) {
                t.printStackTrace();
            }
        }
    }
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:37,代码来源:BuiltInPluginManager.java


示例5: alert

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_ALERT)
public void alert(final AlertPack pack) {
	if (conf.getBoolean("ext_plugin_teamup_send_alert", true)) {
		println("[ext_plugin_teamup_send_alert true]");
		// Get log level (0 : INFO, 1 : WARN, 2 : ERROR, 3 : FATAL)
		int level = conf.getInt("ext_plugin_teamup_level", 0);

		if (level <= pack.level) {
			new Thread() {
				public void run() {
					try {
						String roomId = conf.getValue("ext_plugin_teamup_room_id");
						assert roomId != null;
						println("[roomId ok]");
						//get access token
						String token = getAccessToken();							
						if(token != null){
							// Get the agent Name
							String name = AgentManager.getAgentName(pack.objHash) == null ? "N/A"
									: AgentManager.getAgentName(pack.objHash);

							if (name.equals("N/A") && pack.message.endsWith("connected.")) {
								int idx = pack.message.indexOf("connected");
								if (pack.message.indexOf("reconnected") > -1) {
									name = pack.message.substring(0, idx - 6);
								} else {
									name = pack.message.substring(0, idx - 4);
								}
							}

							String title = pack.title;
							String msg = pack.message;
							if (title.equals("INACTIVE_OBJECT")) {
								title = "An object has been inactivated.";
								msg = pack.message.substring(0, pack.message.indexOf("OBJECT") - 1);
							}

							// Make message contents
							String contents = "[TYPE] : " + pack.objType.toUpperCase() + "\n" + "[NAME] : " + name
									+ "\n" + "[LEVEL] : " + AlertLevel.getName(pack.level) + "\n" + "[TITLE] : " + title
									+ "\n" + "[MESSAGE] : " + msg;

							Message message = new Message(contents);
							String param = new Gson().toJson(message);
							HttpPost post = new HttpPost(MESSAGE_URL + roomId);
							post.addHeader("Authorization", token);
							post.addHeader("Content-Type", "application/json");
							post.setEntity(new StringEntity(param));

							CloseableHttpClient client = HttpClientBuilder.create().build();

							// send teamup message
							HttpResponse response = client.execute(post);
							if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
								println("teamup message sent to [" + roomId + "] successfully.");
							} else {
								println("teamup message sent failed. Verify below information.");
								println("[URL] : " + MESSAGE_URL + roomId);
								println("[StatusCode] : " + response.getStatusLine().getStatusCode());
								println("[Message] : " + param);
								println("[Reason] : " + EntityUtils.toString(response.getEntity(), "UTF-8"));
								println("[AccessToken] : " + token);									
							}							
						}else{
							println("[Error] : token null");
						}
					} catch (Exception e) {
						println("[Error] : " + e.getMessage());
						if (conf._trace) {
							e.printStackTrace();
						}
					}
				}
			}.start();
		}
	}
}
 
开发者ID:kingbbode,项目名称:scouter-plugin-server-alert-teamup,代码行数:78,代码来源:TeamUpPlugin.java


示例6: counter

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_COUNTER)
 public void counter(PerfCounterPack pack) {
     String objName = pack.objName;
     int objHash = HashUtil.hash(objName);
     String objType = null;
     String objFamily = null;

     if (AgentManager.getAgent(objHash) != null) {
     	objType = AgentManager.getAgent(objHash).objType;
     }
     
     if (objType != null) {
     	objFamily = CounterManager.getInstance().getCounterEngine().getObjectType(objType).getFamily().getName();
     }
     
     try {
      // in case of objFamily is javaee
      if (CounterConstants.FAMILY_JAVAEE.equals(objFamily)) {
      	// save javaee type's objHash
      	if (!javaeeObjHashList.contains(objHash)) {
      		javaeeObjHashList.add(objHash);
      	}
      	
      	if (pack.timetype == TimeTypeEnum.REALTIME) {
      		long gcTimeThreshold = conf.getLong("ext_plugin_gc_time_threshold", 0);
      		long gcTime = pack.data.getLong(CounterConstants.JAVA_GC_TIME);

      		if (gcTimeThreshold != 0 && gcTime > gcTimeThreshold) {
      			AlertPack ap = new AlertPack();
      			
  		        ap.level = AlertLevel.WARN;
  		        ap.objHash = objHash;
  		        ap.title = "GC time exceed a threshold.";
  		        ap.message = objName + "'s GC time(" + gcTime + " ms) exceed a threshold.";
  		        ap.time = System.currentTimeMillis();
  		        ap.objType = objType;
  				
  		        alert(ap);
      		}
      	}
  	}
     } catch (Exception e) {
Logger.printStackTrace(e);
     }
 }
 
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-line,代码行数:46,代码来源:LinePlugin.java


示例7: counter

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
/**
  * PerfCounterPack 발생 시 처리
  * @param pack
  */
 @ServerPlugin(PluginConstants.PLUGIN_SERVER_COUNTER)
 public void counter(PerfCounterPack pack) {
     String objName = pack.objName;
     int objHash = HashUtil.hash(objName);
     String objType = null;
     String objFamily = null;

     if (AgentManager.getAgent(objHash) != null) {
     	objType = AgentManager.getAgent(objHash).objType;
     }
     
     if (objType != null) {
try {
	objFamily = CounterManager.getInstance().getCounterEngine().getObjectType(objType).getFamily().getName();
} catch (Exception e) {
	objFamily = objType;
}
     }
     
     // objFamily가 host인 경우
     if (CounterConstants.FAMILY_HOST.equals(objFamily)) {
     	if (hostAgentStatMap.get(objHash) == null) {
     		hostAgentStatMap.put(objHash, new HostAgentStat(objHash));
     	}
     	
     	if (pack.timetype == TimeTypeEnum.REALTIME) {
         	hostAgentStatMap.get(objHash).addMax(pack.data.getFloat(CounterConstants.HOST_CPU), 
         			pack.data.getInt(CounterConstants.HOST_MEM_TOTAL), 
         			pack.data.getFloat(CounterConstants.HOST_MEM), 
         			pack.data.getInt(CounterConstants.HOST_MEM_USED), 
         			pack.data.getInt(CounterConstants.HOST_NET_TX_BYTES), 
         			pack.data.getInt(CounterConstants.HOST_NET_RX_BYTES), 
         			pack.data.getInt(CounterConstants.HOST_DISK_READ_BYTES), 
         			pack.data.getInt(CounterConstants.HOST_DISK_WRITE_BYTES));
     	} else if (pack.timetype == TimeTypeEnum.FIVE_MIN) {
     		// NET_TX, NET_RX, DISK_READ, DISK_WRITE 정보는 FIVE_MIN에 포함되지 않음.
         	hostAgentStatMap.get(objHash).addAvg(pack.data.getFloat(CounterConstants.HOST_CPU), 
         			pack.data.getFloat(CounterConstants.HOST_MEM), 
         			pack.data.getInt(CounterConstants.HOST_MEM_USED));
         }
     }
     
     // objFamily가 javaee인 경우
     if (CounterConstants.FAMILY_JAVAEE.equals(objFamily)) {
     	if (javaAgentStatMap.get(objHash) == null) {
     		javaAgentStatMap.put(objHash, new JavaAgentStat(objHash));
     	}
     	
     	if (pack.timetype == TimeTypeEnum.REALTIME) {
     		// JAVA_HEAP_TOT_USAGE 정보가 없는 PerfCounterPack은 host agent가 동작중에 PROC_CPU 정보를 보내주는 경우와, FIVE_MIN 밖에 없음.
     		// PROC_CPU 정보는 수집 대상이 아님.
         	ListValue lv = pack.data.getList(CounterConstants.JAVA_HEAP_TOT_USAGE);
         	
         	if (lv != null && lv.size() > 0) {
                 javaAgentStatMap.get(objHash).addMax(pack.data.getInt(CounterConstants.WAS_ACTIVE_SERVICE), 
                 		lv.getFloat(0), 
                 		pack.data.getFloat(CounterConstants.JAVA_HEAP_USED), 
                 		pack.data.getInt(CounterConstants.WAS_RECENT_USER), 
                 		pack.data.getInt(CounterConstants.WAS_SERVICE_COUNT), 
                 		pack.data.getFloat(CounterConstants.WAS_APICALL_TPS), 
                 		pack.data.getFloat(CounterConstants.WAS_SQL_TPS), 
                 		pack.data.getFloat(CounterConstants.WAS_TPS));
         	}
     	} else if (pack.timetype == TimeTypeEnum.FIVE_MIN) {
     		if (pack.data.toMap().get(CounterConstants.PROC_CPU) == null) {
              javaAgentStatMap.get(objHash).addAvg(pack.data.getInt(CounterConstants.WAS_ACTIVE_SERVICE), 
              		pack.data.getFloat(CounterConstants.JAVA_HEAP_USED), 
              		pack.data.getInt(CounterConstants.WAS_RECENT_USER), 
              		pack.data.getInt(CounterConstants.WAS_SERVICE_COUNT), 
                 		pack.data.getFloat(CounterConstants.WAS_APICALL_TPS), 
              		pack.data.getFloat(CounterConstants.WAS_SQL_TPS), 
              		pack.data.getFloat(CounterConstants.WAS_TPS));
     		}
     	}
 	}
 }
 
开发者ID:OpenSourceConsulting,项目名称:scouter-plugin-server-reporting,代码行数:81,代码来源:ReportingPlugin.java


示例8: object

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
/**
  * ObjectPack 발생 시 처리
  * @param pack
  */
 @ServerPlugin(PluginConstants.PLUGIN_SERVER_OBJECT)
 public void object(ObjectPack pack) {
     if (!pack.objType.equals(CounterConstants.REQUESTPROCESS)) {
      AgentInfo agentInfo = null;
ObjectPack op = AgentManager.getAgent(pack.objHash);
boolean isExist = true;
boolean isDownState = false;
      
// Plugin의 loading이 채 끝나기 전에 agent로부터 heartbeat 메시지가 수신되는 경우
// 해당 Agent의 구동 정보가 누락될 수 있기 때문에 매번 agent의 상태를 조회한다.

agentInfo = selectAgentInfo(pack.objHash);
if (agentInfo == null) {
	agentInfo = new AgentInfo();
	isExist = false;
} else {
	Date lastDownTime = agentInfo.getLast_down_time();
	Date lastUpTime = agentInfo.getLast_up_time();
	
	if (lastDownTime != null && lastUpTime != null) {
		if (lastDownTime.getTime() - lastUpTime.getTime() > 0) {
			isDownState = true;
		}
	}
}

if ((op == null && pack.wakeup == 0L) || op.alive == false || !isExist || isDownState) {
          println("[AgentInfo] : " + agentInfo);
	
	agentInfo.setObject_hash(pack.objHash);
	agentInfo.setObject_name(pack.objName);
	agentInfo.setObject_type(pack.objType);
	
	if (pack.objType != null) {
          	String object_family;
          	
		try {
			object_family = CounterManager.getInstance().getCounterEngine().getObjectType(pack.objType).getFamily().getName();
		} catch (Exception e) {
			object_family = pack.objType;
		}
		
          	agentInfo.setObject_family(object_family);
          }
	
	agentInfo.setIp_address(pack.address);
	agentInfo.setLast_up_time(new Date(System.currentTimeMillis()));
	
	if (isExist) {
		updateAgentInfo(agentInfo);
	} else {
		insertAgentInfo(agentInfo);
	}
  	}
     }
 }
 
开发者ID:OpenSourceConsulting,项目名称:scouter-plugin-server-reporting,代码行数:61,代码来源:ReportingPlugin.java


示例9: summary

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
/**
 * SummaryPack 발생 시 처리
 * @param pack
 */
@ServerPlugin(PluginConstants.PLUGIN_SERVER_SUMMARY)
public void summary(SummaryPack pack) {
	if (pack.stype == SummaryEnum.SQL) {
		ListValue idList = pack.table.getList("id");
		ListValue countList = pack.table.getList("count");
		ListValue errorList = pack.table.getList("error");
		ListValue elapsedList = pack.table.getList("elapsed");
		
		SqlInfo sqlInfo = null;
		Sql sql = null;
		int sqlHash = 0;
		String sqlStr = null;
		
		Iterator<Value> iter = idList.iterator();
		Value id, count, error, elapsed = null;
		int idx = 0;
		while (iter.hasNext()) {
			id = iter.next();
			count = countList.get(idx);
			error = errorList.get(idx);
			elapsed = elapsedList.get(idx++);

SqlSession session = sqlSessionFactory.openSession(true);
			try {
				sqlHash = ((Number) id.toJavaObject()).intValue();
				sqlStr = TextRD.getString(DateUtil.yyyymmdd(pack.time), TextTypes.SQL, sqlHash);
				
				if (sqlStr != null && sqlStr.length() > 32000) {
					Logger.println("SQL String is too long to insert SQL_INFO_TBL.");
					sqlStr = sqlStr.substring(0, 32000) + "...";
				}
						
				sqlInfo = session.selectOne("Scouter.selectSqlInfo", ((Number) id.toJavaObject()).intValue());
				if (sqlInfo == null) {
					sqlInfo = new SqlInfo();
					sqlInfo.setSql_hash(sqlHash);
					sqlInfo.setSql_str(sqlStr);
					session.insert("Scouter.insertSqlInfo", sqlInfo);
				} else {
					if (sqlInfo.getSql_str() == null) {
    					sqlInfo.setSql_str(sqlStr);
    					session.update("Scouter.updateSqlInfo", sqlInfo);
					} else if (!sqlInfo.getSql_str().equals(sqlStr)) {
    					sqlInfo.setSql_str(sqlStr);
    					session.update("Scouter.updateSqlInfo", sqlInfo);
					}
				}
				
	sql = new Sql();
	sql.setDate(pack.time);
	sql.setObject_hash(pack.objHash);
	sql.setSql_hash(((Number) id.toJavaObject()).intValue());
	sql.setLog_dt(new java.sql.Date(pack.time));
	sql.setLog_tm(new Time(pack.time));
	sql.setExecute_count(((Number) count.toJavaObject()).intValue());
	sql.setError_count(((Number) error.toJavaObject()).intValue());
	sql.setElapsed(((Number) elapsed.toJavaObject()).intValue());
	
	session.insert("Scouter.insertSql", sql);
} catch (Exception e) {
	Logger.printStackTrace(e);
} finally {
	if (session != null) {
		session.close();
	}
}
		}
	}
}
 
开发者ID:OpenSourceConsulting,项目名称:scouter-plugin-server-reporting,代码行数:74,代码来源:ReportingPlugin.java


示例10: alert

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_ALERT)
public void alert(final AlertPack pack){
	if (conf.getBoolean("ext_plugin_slack_send_alert", false)) {

		int level = conf.getInt("ext_plugin_slack_level", 0);
		// Get log level (0 : INFO, 1 : WARN, 2 : ERROR, 3 : FATAL)
		if(level <= pack.level){
			new Thread(){
				public void run(){
					try{
						String webhookURL = conf.getValue("ext_plugin_slack_webhook_url");
						String channel = conf.getValue("ext_plugin_slack_channel");
						String botName = conf.getValue("ext_plugin_slack_botName");
						String iconURL = conf.getValue("ext_plugin_slack_icon_url");
						String iconEmoji = conf.getValue("ext_plugin_slack_icon_emoji");

						assert webhookURL != null;

						// Get the agent Name
           	String name = AgentManager.getAgentName(pack.objHash) == null ? "N/A" : AgentManager.getAgentName(pack.objHash);

           	if (name.equals("N/A") && pack.message.endsWith("connected.")) {
       			int idx = pack.message.indexOf("connected");
           		if (pack.message.indexOf("reconnected") > -1) {
           			name = pack.message.substring(0, idx - 6);
           		} else {
           			name = pack.message.substring(0, idx - 4);
           		}
           	}

           	String title = pack.title;
               String msg = pack.message;
               if (title.equals("INACTIVE_OBJECT")) {
               	title = "An object has been inactivated.";
               	msg = pack.message.substring(0, pack.message.indexOf("OBJECT") - 1);
               }

           	// Make message contents
               String contents = "[TYPE] : " + pack.objType.toUpperCase() + "\n" +
                              	  "[NAME] : " + name + "\n" +
                                 "[LEVEL] : " + AlertLevel.getName(pack.level) + "\n" +
                                 "[TITLE] : " + title + "\n" +
                                 "[MESSAGE] : " + msg;

               Message message = new Message(contents, channel, botName, iconURL, iconEmoji);
               String payload = new Gson().toJson(message);

               if(conf.getBoolean("ext_plugin_slack_debug", false)){
               	println("WebHookURL : "+webhookURL);
               	println("param : "+payload);
               }

               HttpPost post = new HttpPost(webhookURL);
               post.addHeader("Content-Type","application/json");
							// charset set utf-8
							post.setEntity(new StringEntity(payload, "utf-8"));

               CloseableHttpClient client = HttpClientBuilder.create().build();

               // send the post request
               HttpResponse response = client.execute(post);

               if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                   println("Slack message sent to [" + channel + "] successfully.");
               } else {
                   println("Slack message sent failed. Verify below information.");
                   println("[WebHookURL] : " + webhookURL);
                   println("[Message] : " + payload);
                   println("[Reason] : " + EntityUtils.toString(response.getEntity(), "UTF-8"));
               }
					}catch(Exception e){
						println("[Error] : " + e.getMessage());
           	if(conf._trace) {
                   e.printStackTrace();
           	}
					}
				}
			}.start();
		}
	}
}
 
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-slack,代码行数:82,代码来源:SlackPlugin.java


示例11: counter

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_COUNTER)
public void counter(PerfCounterPack pack) {
    String objName = pack.objName;
    int objHash = HashUtil.hash(objName);
    String objType = null;
    String objFamily = null;

    if (AgentManager.getAgent(objHash) != null) {
    	objType = AgentManager.getAgent(objHash).objType;
    }

    if (objType != null) {
    	objFamily = CounterManager.getInstance().getCounterEngine().getObjectType(objType).getFamily().getName();
    }

    try {
      // in case of objFamily is javaee
      if (CounterConstants.FAMILY_JAVAEE.equals(objFamily)) {
      	// save javaee type's objHash
      	if (!javaeeObjHashList.contains(objHash)) {
      		javaeeObjHashList.add(objHash);
      	}

      	if (pack.timetype == TimeTypeEnum.REALTIME) {
      		long gcTimeThreshold = conf.getLong("ext_plugin_gc_time_threshold", 0);
      		long gcTime = pack.data.getLong(CounterConstants.JAVA_GC_TIME);

      		if (gcTimeThreshold != 0 && gcTime > gcTimeThreshold) {
      			AlertPack ap = new AlertPack();

  		        ap.level = AlertLevel.WARN;
  		        ap.objHash = objHash;
  		        ap.title = "GC time exceed a threshold.";
  		        ap.message = objName + "'s GC time(" + gcTime + " ms) exceed a threshold.";
  		        ap.time = System.currentTimeMillis();
  		        ap.objType = objType;

  		        alert(ap);
      		}
      	}
  	}
    } catch (Exception e) {
Logger.printStackTrace(e);
    }
}
 
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-slack,代码行数:46,代码来源:SlackPlugin.java


示例12: counter

import scouter.lang.plugin.annotation.ServerPlugin; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_COUNTER)
public void counter(final PerfCounterPack pack) {
    if (!enabled) {
        return;
    }

    if(pack.timetype != TimeTypeEnum.REALTIME) {
        return;
    }

    try {
        String objName = pack.objName;
        int objHash = HashUtil.hash(objName);
        String objType = AgentManager.getAgent(objHash).objType;
        String objFamily = CounterManager.getInstance().getCounterEngine().getObjectType(objType).getFamily().getName();
        Point.Builder builder = Point.measurement(measurementName)
                .time(pack.time, TimeUnit.MILLISECONDS)
                .tag(tagObjName, objName)
                .tag(tagObjType, objType)
                .tag(tagObjFamily, objFamily);

        Map<String, Value> dataMap = pack.data.toMap();
        for (Map.Entry<String, Value> field : dataMap.entrySet()) {
            Value valueOrigin = field.getValue();
            if (valueOrigin == null) {
                continue;
            }
            Object value = valueOrigin.toJavaObject();
            if(!(value instanceof Number)) {
                continue;
            }
            String key = field.getKey();
            if("time".equals(key)) {
                continue;
            }
            builder.addField(key, (Number)value);
        }
        Point point = builder.build();

        if (isUdp) {
            String line = point.lineProtocol();
            udpAgent.write(line);
            //System.out.println(line);
        } else { // http
            influx.write(dbName, retentionPolicy, point);
        }

    } catch (Exception e) {
        if (conf._trace) {
            Logger.printStackTrace("IFLX001", e);
        } else {
            Logger.println("IFLX002", e.getMessage());
        }
    }
}
 
开发者ID:scouter-project,项目名称:scouter-plugin-server-influxdb,代码行数:56,代码来源:InfluxdbPlugin.java



注:本文中的scouter.lang.plugin.annotation.ServerPlugin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RecordConsumer类代码示例发布时间:2022-05-23
下一篇:
Java DHParameter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap