mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-21 22:08:48 +00:00
feat: 调整lag判断条件 减少高峰期误报
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
6a75d33e85
commit
632ee1f20c
3
pom.xml
3
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>Yum</artifactId>
|
||||
<version>2.7.2</version>
|
||||
<version>2.7.3</version>
|
||||
<name>Yum</name>
|
||||
<description>Minecraft 服务器插件管理系统</description>
|
||||
<build>
|
||||
@ -66,6 +66,7 @@
|
||||
<update.description>§a全新 2.X 版本 更多守护与优化</update.description>
|
||||
<update.changes>
|
||||
§c注意 §6- §aYum更新需要§d重启服务器!§c重启服务器!§4重启服务器!;
|
||||
§b2.7.3 §6- §a调整lag判断条件 减少高峰期误报...;
|
||||
§b2.7.2 §6- §c修复mi lag命令参数错误报错 §d百分比显示能耗...;
|
||||
§b2.7.1 §6- §c修复部分BUG(load可直接载入文件)...;
|
||||
</update.changes>
|
||||
|
@ -23,7 +23,7 @@ import pw.yumc.Yum.managers.MonitorManager;
|
||||
|
||||
public class CommandInjector implements TabExecutor {
|
||||
private final static String prefix = "§6[§bYum §a命令监控§6] ";
|
||||
private final static String warn = "§c注意! §6玩家 §a%s §6执行 §b%s §6插件 §d%s %s §6命令 §c耗时 §4%sms!";
|
||||
private final static String warn = "§c注意! §6玩家 §a%s §6执行 §b%s §6插件 §d%s %s §6命令 §c耗时 §4%sms §c平均耗时 §4%sms!";
|
||||
private final static String err = prefix + "§6玩家 §a%s §6执行 §b%s §6插件 §d%s %s §6命令时发生异常!";
|
||||
private final static String inject_error = prefix + "§6插件 §b%s §c注入能耗监控失败!";
|
||||
private final static String plugin_is_null = "插件不得为NULL!";
|
||||
@ -109,11 +109,13 @@ public class CommandInjector implements TabExecutor {
|
||||
final boolean result = originalExecutor.onCommand(sender, command, label, args);
|
||||
final long end = System.nanoTime();
|
||||
final long lag = end - start;
|
||||
if (Bukkit.isPrimaryThread() && lag / 1000000 > MonitorManager.lagTime) {
|
||||
MonitorManager.lagTip(String.format(warn, sender.getName(), plugin.getName(), label, StrKit.join(args, " "), lag / 1000000));
|
||||
}
|
||||
totalTime += lag;
|
||||
count++;
|
||||
final long lagms = lag / MonitorManager.um;
|
||||
final long avglagms = totalTime / count / MonitorManager.um;
|
||||
if (Bukkit.isPrimaryThread() && lagms > MonitorManager.lagTime && avglagms > MonitorManager.lagTime) {
|
||||
MonitorManager.lagTip(String.format(warn, sender.getName(), plugin.getName(), label, StrKit.join(args, " "), lagms, avglagms));
|
||||
}
|
||||
MonitorManager.addCmd(plugin.getName(), lag);
|
||||
return result;
|
||||
} catch (Throwable e) {
|
||||
|
@ -22,7 +22,7 @@ import pw.yumc.Yum.managers.MonitorManager;
|
||||
|
||||
public class ListenerInjector implements EventExecutor {
|
||||
private final static String prefix = "§6[§bYum §a事件监控§6] ";
|
||||
private final static String warn = "§c注意! §6插件 §b%s §6处理 §d%s §6事件 §c耗时 §4%sms!";
|
||||
private final static String warn = "§c注意! §6插件 §b%s §6处理 §d%s §6事件 §c耗时 §4%sms §c平均耗时 §4%sms!";
|
||||
private final static String err = prefix + "§6插件 §b%s §6处理 §d%s §6事件时发生异常!";
|
||||
private final static String inject_error = prefix + "§6插件 §b%s §c注入能耗监控失败 §6注入类: §3%s!";
|
||||
private final static String plugin_is_null = "插件不得为NULL!";
|
||||
@ -97,9 +97,6 @@ public class ListenerInjector implements EventExecutor {
|
||||
final long end = System.nanoTime();
|
||||
final String en = event.getEventName();
|
||||
final long lag = end - start;
|
||||
if (lag / 1000000 > MonitorManager.lagTime && !ConfigManager.i().getMonitorIgnoreList().contains(plugin.getName())) {
|
||||
MonitorManager.lagTip(String.format(warn, plugin.getName(), event.getEventName(), lag / 1000000));
|
||||
}
|
||||
if (eventTotalTime.containsKey(en)) {
|
||||
eventTotalTime.put(en, eventTotalTime.get(en) + lag);
|
||||
eventCount.put(en, eventCount.get(en) + 1);
|
||||
@ -107,6 +104,11 @@ public class ListenerInjector implements EventExecutor {
|
||||
eventTotalTime.put(en, end - start);
|
||||
eventCount.put(en, 1);
|
||||
}
|
||||
final long lagms = lag / MonitorManager.um;
|
||||
final long avglagms = eventTotalTime.get(en) / eventCount.get(en) / MonitorManager.um;
|
||||
if (avglagms > MonitorManager.lagTime && lagms > MonitorManager.lagTime && !ConfigManager.i().getMonitorIgnoreList().contains(plugin.getName())) {
|
||||
MonitorManager.lagTip(String.format(warn, plugin.getName(), event.getEventName(), lagms, avglagms));
|
||||
}
|
||||
MonitorManager.addEvent(plugin.getName(), lag);
|
||||
} else {
|
||||
originalExecutor.execute(listener, event);
|
||||
|
@ -15,7 +15,7 @@ import pw.yumc.Yum.managers.MonitorManager;
|
||||
|
||||
public class TaskInjector implements Runnable {
|
||||
private final static String prefix = "§6[§bYum §a任务监控§6] ";
|
||||
private final static String warn = "§c注意! §6插件 §b%s §6处理 §d%s §6任务 §c耗时 §4%sms!";
|
||||
private final static String warn = "§c注意! §6插件 §b%s §6处理 §d%s §6任务 §c耗时 §4%sms §c平均耗时 §4%sms!";
|
||||
private final static String err = prefix + "§6插件 §b%s §6处理 §d%s §6任务时发生异常!";
|
||||
private final static String inject_error = prefix + "§6插件 §b%s §c注入能耗监控失败!";
|
||||
private final static String plugin_is_null = "插件不得为NULL!";
|
||||
@ -86,11 +86,13 @@ public class TaskInjector implements Runnable {
|
||||
originalTask.run();
|
||||
final long end = System.nanoTime();
|
||||
final long lag = end - start;
|
||||
if (Bukkit.isPrimaryThread() && lag / 1000000 > MonitorManager.lagTime) {
|
||||
MonitorManager.lagTip(String.format(warn, plugin.getName(), taskName, lag / 1000000));
|
||||
}
|
||||
totalTime += lag;
|
||||
count++;
|
||||
final long lagms = lag / MonitorManager.um;
|
||||
final long avglagms = totalTime / count / MonitorManager.um;
|
||||
if (Bukkit.isPrimaryThread() && lagms > MonitorManager.lagTime && avglagms > MonitorManager.lagTime) {
|
||||
MonitorManager.lagTip(String.format(warn, plugin.getName(), taskName, lagms, avglagms));
|
||||
}
|
||||
MonitorManager.addTask(plugin.getName(), lag);
|
||||
} catch (Throwable e) {
|
||||
while (e.getCause() != null) {
|
||||
|
@ -34,6 +34,7 @@ public class MonitorManager {
|
||||
private final static String devInfo = "§c开发人员调试信息如下:";
|
||||
|
||||
public final static int lagTime = 20;
|
||||
public final static int um = 1000000;
|
||||
public final static boolean debug = ConfigManager.i().isMonitorDebug();
|
||||
public final static boolean log_to_file = ConfigManager.i().isLogToFile();
|
||||
|
||||
@ -44,8 +45,6 @@ public class MonitorManager {
|
||||
private final static Map<String, Long> event = new ConcurrentHashMap<>();
|
||||
private final static Map<String, Long> cmd = new ConcurrentHashMap<>();
|
||||
|
||||
private final static double um = 1000000.00;
|
||||
|
||||
private final static LogKit mlog = new LogKit("monitor.log");
|
||||
private final static LogKit elog = new LogKit("error.log");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user