本文整理汇总了Java中scouter.lang.pack.AlertPack类的典型用法代码示例。如果您正苦于以下问题:Java AlertPack类的具体用法?Java AlertPack怎么用?Java AlertPack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AlertPack类属于scouter.lang.pack包,在下文中一共展示了AlertPack类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: xlog
import scouter.lang.pack.AlertPack; //导入依赖的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.pack.AlertPack; //导入依赖的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
示例3: alert
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public static void alert(byte level, RealCounter c, String title, String message) {
long now = System.currentTimeMillis();
if (c.silentTime() > 0) {
if (now < c.lastAlertTime(level) + c.silentTime() * 1000)
return;
}
AlertPack p = new AlertPack();
p.time = now;
p.level = level;
p.objHash = c.objHash();
p.objType = c.objType();
p.title = title;
p.message = message;
c.setAlertTime(level, now);
AlertCore.add(p);
}
开发者ID:scouter-project,项目名称:scouter,代码行数:17,代码来源:AlertUtil.java
示例4: ariseAlert
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public void ariseAlert(final int serverId, final AlertPack alert) {
ExUtil.exec(table, new Runnable() {
public void run() {
while (table.getItemCount() > 500) {
table.remove(table.getItemCount() - 1);
}
AlertData data = new AlertData(serverId, alert);
TableItem t = new TableItem(table, SWT.NONE, 0);
t.setText(new String[] { //
FormatUtil.print(new Date(alert.time), "HH:mm:ss.SSS"),
AlertLevel.getName(alert.level), //
alert.title, //
alert.message,//
TextProxy.object.getLoadText(DateUtil.yyyymmdd(TimeUtil.getCurrentTime()), data.p.objHash, serverId),//
});
t.setData(data);
}
});
}
开发者ID:scouter-project,项目名称:scouter,代码行数:20,代码来源:AlertView.java
示例5: getColumnText
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public String getColumnText(Object element, int columnIndex) {
if (element instanceof AlertPack == false) {
return null;
}
AlertPack p = (AlertPack) element;
AlertColumnEnum column = columnList.get(columnIndex);
switch (column) {
case TIME :
return DateUtil.format(p.time, "HH:mm:ss.SSS");
case LEVEL :
return AlertLevel.getName(p.level);
case OBJECT :
return TextProxy.object.getLoadText(yyyymmdd, p.objHash, serverId);
case TITLE :
return p.title;
case MESSAGE :
return p.message;
case TAGS :
return p.tags.toString();
}
return null;
}
开发者ID:scouter-project,项目名称:scouter,代码行数:23,代码来源:AlertTableComposite.java
示例6: endPut
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public static void endPut(Map map) {
int size = map.size();
if(size > 0 && size % conf._hook_map_impl_warning_size == 0) {
TraceContext ctx = TraceContextManager.getContext();
if(ctx == null) return;
if(ctx.error != 0) return;
MapValue mv = new MapValue();
mv.put(AlertPack.HASH_FLAG + TextTypes.SERVICE + "_service-name", ctx.serviceHash);
String message = "Too many Map entries!\n" + ThreadUtil.getStackTrace(Thread.currentThread().getStackTrace(), 2);
HashedMessageStep step = new HashedMessageStep();
step.hash = DataProxy.sendHashedMessage(message);
step.value = size;
step.start_time = (int) (System.currentTimeMillis() - ctx.startTime);
ctx.profile.add(step);
mv.put(AlertPack.HASH_FLAG + TextTypes.HASH_MSG + "_full-stack", step.hash);
DataProxy.sendAlert(AlertLevel.WARN, "TOO_MANY_MAP_ENTRIES", "too many Map entries, over #" + size, mv);
int errorMessageHash = DataProxy.sendError("too many Map entries, over #" + size);
if (ctx.error == 0) {
ctx.error = errorMessageHash;
}
ctx.offerErrorEntity(ErrorEntity.of(tooManyCollectionMemebers, errorMessageHash, 0, 0));
}
}
开发者ID:scouter-project,项目名称:scouter,代码行数:27,代码来源:TraceCollection.java
示例7: alert
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
@Test
public void alert() throws Exception {
when(conf.getValue("ext_plugin_line_access_token")).thenReturn(lineAccessToken);
when(conf.getValue("ext_plugin_line_group_id")).thenReturn(lineGroupId);
when(conf.getBoolean(eq("ext_plugin_line_send_alert"), anyBoolean())).thenReturn(true);
AlertPack ap = genAlertPack();
plugin.alert(ap);
Thread.sleep(10000);
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-line,代码行数:12,代码来源:LinePluginTest.java
示例8: genAlertPack
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
private static AlertPack genAlertPack() {
AlertPack ap = new AlertPack();
ap.level = AlertLevel.WARN;
ap.objHash = 100;
ap.title = "Elapsed time exceed a threshold.";
ap.message = "[100 agent] exceed a threshold";
ap.time = System.currentTimeMillis();
ap.objType = "someObjecttype";
return ap;
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-line,代码行数:13,代码来源:LinePluginTest.java
示例9: alert
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
@Internal
public void alert(byte level, int objHash, String objType, String title, String message) {
AlertPack p = new AlertPack();
p.time = System.currentTimeMillis();
p.level = level;
p.objHash = objHash;
p.objType = objType;
p.title = title;
p.message = message;
AlertCore.add(p);
}
开发者ID:scouter-project,项目名称:scouter,代码行数:12,代码来源:PluginHelper.java
示例10: alert
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public static void alert(AlertPack p) {
BuiltInPluginManager.invokeAllPlugins(PluginConstants.PLUGIN_SERVER_ALERT, p);
if (alerts != null) {
try {
alerts.process(p);
} catch (Throwable t) {
Logger.printStackTrace("PL005", t);
}
}
}
开发者ID:scouter-project,项目名称:scouter,代码行数:12,代码来源:PlugInManager.java
示例11: toPack
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public AlertPack toPack() {
AlertPack pack = new AlertPack();
pack.level = AlertLevel.getValue(level);
pack.message = message;
pack.objHash = object == null ? 0 : HashUtil.hash(object);
pack.objType = objType;
pack.tags = tags;
pack.time = time;
pack.title = title;
return pack;
}
开发者ID:scouter-project,项目名称:scouter,代码行数:12,代码来源:AlertDetailListView.java
示例12: initLayout
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
private void initLayout() {
parent.setLayout(new FillLayout());
Composite comp = new Composite(parent, SWT.NONE);
tableColumnLayout = new TableColumnLayout();
comp.setLayout(tableColumnLayout);
viewer = new TableViewer(comp, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
createColumns();
final Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setComparator(new TableLabelSorter(viewer));
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent e) {
StructuredSelection sel = (StructuredSelection) viewer.getSelection();
Object o = sel.getFirstElement();
if (o instanceof AlertPack) {
String objName = TextProxy.object.getLoadText(yyyymmdd, ((AlertPack) o).objHash, serverId);
AlertNotifierDialog alertDialog = new AlertNotifierDialog(parent.getDisplay(), serverId);
alertDialog.setObjName(objName);
alertDialog.setPack((AlertPack) o);
alertDialog.show(parent.getBounds());
} else {
System.out.println(o);
}
}
});
}
开发者ID:scouter-project,项目名称:scouter,代码行数:29,代码来源:AlertTableComposite.java
示例13: of
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public static SAlert of(AlertPack p) {
Map<String, Object> tagMap = p.tags.toMap().entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().toJavaObject()));
return SAlert.builder()
.time(p.time)
.objType(p.objType)
.objHash(p.objHash)
.objName(AgentModelThread.getInstance().getAgentObject(p.objHash).getObjName())
.level(AlertLevelEnum.of(p.level))
.title(p.title)
.message(p.message)
.tagMap(tagMap)
.build();
}
开发者ID:scouter-project,项目名称:scouter,代码行数:16,代码来源:SAlert.java
示例14: retrieveRealTimeAlert
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public RealTimeAlertView retrieveRealTimeAlert(final RealTimeAlertRequest request) {
MapPack paramPack = new MapPack();
paramPack.put(ParamConstant.OFFSET_LOOP, request.getLoop());
paramPack.put(ParamConstant.OFFSET_INDEX, request.getIndex());
paramPack.put(ParamConstant.OBJ_TYPE, request.getObjType());
RealTimeAlertView alertView = new RealTimeAlertView();
List<SAlert> alertList = new ArrayList<>();
alertView.setAlerts(alertList);
try (TcpProxy tcpProxy = TcpProxy.getTcpProxy(request.getServerId())) {
tcpProxy.process(RequestCmd.ALERT_REAL_TIME, paramPack, in -> {
Pack packet = in.readPack();
if (packet instanceof MapPack) {
MapPack metaPack = (MapPack) packet;
alertView.setOffset1(metaPack.getLong(ParamConstant.OFFSET_LOOP));
alertView.setOffset1(metaPack.getInt(ParamConstant.OFFSET_INDEX));
} else {
AlertPack alertPack = (AlertPack) packet;
alertList.add(SAlert.of(alertPack));
}
});
}
return alertView;
}
开发者ID:scouter-project,项目名称:scouter,代码行数:28,代码来源:AlertConsumer.java
示例15: checkDelayedService
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public void checkDelayedService(XLogPack pack, String serviceName) {
if (stopChecking) {
Logger.println("SA-2003", "Pass delayed checking... " + Hexa32.toString32(pack.txid));
return;
}
DelayedCondition condition = conditionMap.get(pack.service);
if (condition != null && pack.elapsed > condition.time) {
StringBuilder msg = new StringBuilder();
msg.append(serviceName + System.getProperty("line.separator"));
msg.append(pack.elapsed + " ms (SET:" + condition.time + " ms)" + System.getProperty("line.separator"));
msg.append("ID = " + Hexa32.toString32(pack.txid));
MapValue tags = null;
if (pack.error != 0) {
tags = new MapValue();
tags.put(AlertPack.HASH_FLAG + TextTypes.ERROR + "_error", pack.error);
}
StringBuilder titleSb = new StringBuilder();
titleSb.append("DELAYED_SERVICE");
if (serviceName != null && serviceName.length() > 15) {
titleSb.append("(...");
titleSb.append(serviceName.substring(serviceName.length() - 10));
titleSb.append(")");
} else {
titleSb.append("(");
titleSb.append(serviceName);
titleSb.append(")");
}
AlertProxy.sendAlert(AlertLevel.WARN, titleSb.toString(), msg.toString(), tags);
}
}
开发者ID:scouter-project,项目名称:scouter,代码行数:31,代码来源:DelayedServiceManager.java
示例16: sendAlert
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public static void sendAlert(byte level, String title, String message, MapValue tags) {
AlertPack p = new AlertPack();
p.objType = conf.obj_type;
p.objHash = conf.getObjHash();
p.level = level;
p.title = title;
p.message = message;
if (tags != null) {
p.tags = tags;
}
sendDirect(p);
}
开发者ID:scouter-project,项目名称:scouter,代码行数:14,代码来源:DataProxy.java
示例17: alert
import scouter.lang.pack.AlertPack; //导入依赖的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
示例18: counter
import scouter.lang.pack.AlertPack; //导入依赖的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
示例19: EmailPlugin
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public EmailPlugin() {
if (ai.incrementAndGet() == 1) {
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
// thread count check
executor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
for (int objHash : javaeeObjHashList) {
try {
if (AgentManager.isActive(objHash)) {
ObjectPack objectPack = AgentManager.getAgent(objHash);
MapPack mapPack = new MapPack();
mapPack.put("objHash", objHash);
mapPack = AgentCall.call(objectPack, RequestCmd.OBJECT_THREAD_LIST, mapPack);
int threadCountThreshold = conf.getInt("ext_plugin_thread_count_threshold", 0);
int threadCount = mapPack.getList("name").size();
if (threadCountThreshold != 0 && threadCount > threadCountThreshold) {
AlertPack ap = new AlertPack();
ap.level = AlertLevel.WARN;
ap.objHash = objHash;
ap.title = "Thread count exceed a threshold.";
ap.message = objectPack.objName + "'s Thread count(" + threadCount + ") exceed a threshold.";
ap.time = System.currentTimeMillis();
ap.objType = objectPack.objType;
alert(ap);
}
}
} catch (Exception e) {
// ignore
}
}
}
},
0, 5, TimeUnit.SECONDS);
}
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-email,代码行数:43,代码来源:EmailPlugin.java
示例20: SlackPlugin
import scouter.lang.pack.AlertPack; //导入依赖的package包/类
public SlackPlugin() {
if (ai.incrementAndGet() == 1) {
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
// thread count check
executor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
for (int objHash : javaeeObjHashList) {
try {
if (AgentManager.isActive(objHash)) {
ObjectPack objectPack = AgentManager.getAgent(objHash);
MapPack mapPack = new MapPack();
mapPack.put("objHash", objHash);
mapPack = AgentCall.call(objectPack, RequestCmd.OBJECT_THREAD_LIST, mapPack);
int threadCountThreshold = conf.getInt("ext_plugin_thread_count_threshold", 0);
int threadCount = mapPack.getList("name").size();
if (threadCountThreshold != 0 && threadCount > threadCountThreshold) {
AlertPack ap = new AlertPack();
ap.level = AlertLevel.WARN;
ap.objHash = objHash;
ap.title = "Thread count exceed a threshold.";
ap.message = objectPack.objName + "'s Thread count(" + threadCount + ") exceed a threshold.";
ap.time = System.currentTimeMillis();
ap.objType = objectPack.objType;
alert(ap);
}
}
} catch (Exception e) {
// ignore
}
}
}
},
0, 5, TimeUnit.SECONDS);
}
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-slack,代码行数:43,代码来源:SlackPlugin.java
注:本文中的scouter.lang.pack.AlertPack类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论