mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-11 03:13:51 +00:00
docs: Translate the Chinese comments in the event module into English.
This commit is contained in:
1 parent
000691db86
commit
8460fd7d15
11 files changed
+46
-61
No files matched your search
@@ -43,7 +43,7 @@ public class DiskFileSystem implements Comparable<DiskFileSystem> {
|
||||
var usage = usage();
|
||||
if (usage >= 0.8) {
|
||||
var temp = this.toGB();
|
||||
return StringUtils.format("df - 磁盘[name:{}]空间过高[size:{}GB][available:{}GB][usage:{}][{}]"
|
||||
return StringUtils.format("df - disk[name:{}] space too high[size:{}GB][available:{}GB][usage:{}][{}]"
|
||||
, name, temp.getSize(), temp.getAvailable(), OSUtils.toPercent(usage), TimeUtils.timeToString(timestamp));
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
|
||||
@@ -19,16 +19,16 @@ public class DiskStorage implements Comparable<DiskStorage> {
|
||||
|
||||
private String device;
|
||||
|
||||
// 每秒实际读取需求的数量
|
||||
// Number of actual read requests per second
|
||||
private long rs;
|
||||
|
||||
// 每秒实际读取的大小,单位为KB
|
||||
// Actual read throughput per second in KB
|
||||
private long rKBs;
|
||||
|
||||
// 每秒实际写入需求的数量
|
||||
// Number of actual write requests per second
|
||||
private long ws;
|
||||
|
||||
// 每秒实际写入的大小,单位为KB
|
||||
// Actual write throughput per second in KB
|
||||
private long wKBs;
|
||||
|
||||
public static DiskStorage valueOf(String device, long rs, long rKBs, long ws, long wKBs)
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Memory implements Comparable<Memory> {
|
||||
var usage = 1D * (total - available) / total;
|
||||
if (usage >= 0.8) {
|
||||
var temp = this.toGB();
|
||||
return StringUtils.format("free - 内存占用过高[total:{}GB][available:{}GB][usage:{}][{}]"
|
||||
return StringUtils.format("free - memory usage too high[total:{}GB][available:{}GB][usage:{}][{}]"
|
||||
, temp.getTotal(), temp.getAvailable(), OSUtils.toPercent(usage), TimeUtils.timeToString(timestamp));
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
|
||||
@@ -58,11 +58,11 @@ public class Sar implements Comparable<Sar> {
|
||||
|
||||
public String pressure() {
|
||||
if (rxpck >= 5_0000) {
|
||||
return StringUtils.format("sar - 网卡流量[interface:{}] [rxpck:{}] [txpck:{}] [rxBytes:{}] [txBytes:{}] [inErrors:{}] [outErrors:{}] [inDrops:{}] [collisions:{}] [{}],性能影响:危险"
|
||||
return StringUtils.format("sar - NIC traffic[interface:{}] [rxpck:{}] [txpck:{}] [rxBytes:{}] [txBytes:{}] [inErrors:{}] [outErrors:{}] [inDrops:{}] [collisions:{}] [{}]", performance impact: CRITICAL"
|
||||
, name, rxpck, txpck, rxBytes, txBytes, inErrors, outErrors, inDrops, collisions, TimeUtils.timeToString(timestamp));
|
||||
}
|
||||
if (inErrors > 0 || outErrors > 0 || inDrops > 0 || collisions > 0) {
|
||||
return StringUtils.format("sar - 网卡流量[interface:{}] [rxpck:{}] [txpck:{}] [rxBytes:{}] [txBytes:{}] [inErrors:{}] [outErrors:{}] [inDrops:{}] [collisions:{}] [{}],性能影响:低"
|
||||
return StringUtils.format("sar - NIC traffic[interface:{}] [rxpck:{}] [txpck:{}] [rxBytes:{}] [txBytes:{}] [inErrors:{}] [outErrors:{}] [inDrops:{}] [collisions:{}] [{}]", performance impact: LOW"
|
||||
, name, rxpck, txpck, rxBytes, txBytes, inErrors, outErrors, inDrops, collisions, TimeUtils.timeToString(timestamp));
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
|
||||
@@ -15,27 +15,27 @@ package com.zfoo.monitor;
|
||||
public class SystemInfo {
|
||||
|
||||
/**
|
||||
* host名称
|
||||
* hostname
|
||||
*/
|
||||
private String hostname;
|
||||
|
||||
/**
|
||||
* 系统版本信息
|
||||
* OS version info
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 系统版本详细信息
|
||||
* OS version detail info
|
||||
*/
|
||||
private String versionDetail;
|
||||
|
||||
/**
|
||||
* core的逻辑核心个数
|
||||
* number of logical CPU cores
|
||||
*/
|
||||
private int cpuLogicCore;
|
||||
|
||||
/**
|
||||
* CPU型号信息
|
||||
* CPU model info
|
||||
*/
|
||||
private String cpuName;
|
||||
|
||||
|
||||
@@ -48,22 +48,22 @@ public class Uptime implements Comparable<Uptime> {
|
||||
var fifty = fiftyMinute / processors;
|
||||
|
||||
if (usage >= 0.8) {
|
||||
return StringUtils.format("uptime - cpu负载[{}][{}][{}][usage:{}][{}]过大,性能影响:危险"
|
||||
return StringUtils.format("uptime - cpu load[{}][{}][{}][usage:{}][{}] too high, performance impact: CRITICAL"
|
||||
, oneMinute, fiveMinute, fiftyMinute, OSUtils.toPercent(usage), TimeUtils.timeToString(timestamp));
|
||||
}
|
||||
|
||||
if (one > 5 || five > 5 || fifty > 5) {
|
||||
return StringUtils.format("uptime - cpu负载[{}][{}][{}][usage:{}][{}]过大,性能影响:警告"
|
||||
return StringUtils.format("uptime - cpu load[{}][{}][{}][usage:{}][{}] too high, performance impact: WARNING"
|
||||
, oneMinute, fiveMinute, fiftyMinute, OSUtils.toPercent(usage), TimeUtils.timeToString(timestamp));
|
||||
}
|
||||
|
||||
if (one > 4 || five > 4 || fifty > 4) {
|
||||
return StringUtils.format("uptime - cpu负载[{}][{}][{}][usage:{}][{}],性能影响:高"
|
||||
return StringUtils.format("uptime - cpu load[{}][{}][{}][usage:{}][{}], performance impact: HIGH"
|
||||
, oneMinute, fiveMinute, fiftyMinute, OSUtils.toPercent(usage), TimeUtils.timeToString(timestamp));
|
||||
}
|
||||
|
||||
if (one > 3 || five > 3 || fifty > 3) {
|
||||
return StringUtils.format("uptime - cpu负载[{}][{}][{}][usage:{}][{}],性能影响:中,考虑优化"
|
||||
return StringUtils.format("uptime - cpu load[{}][{}][{}][usage:{}][{}], performance impact: MEDIUM, consider optimizing"
|
||||
, oneMinute, fiveMinute, fiftyMinute, OSUtils.toPercent(usage), TimeUtils.timeToString(timestamp));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@ public class JvmUtils {
|
||||
|
||||
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
|
||||
|
||||
//堆内存
|
||||
// Heap memory
|
||||
MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||
list.add(new JvmMemory("heap", heapMemoryUsage));
|
||||
|
||||
List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
|
||||
for (MemoryPoolMXBean mxBean : memoryPoolMXBeans) {
|
||||
//获取堆内存明细
|
||||
// Get heap memory details
|
||||
if (MemoryType.HEAP.equals(mxBean.getType())) {
|
||||
MemoryUsage usage = mxBean.getUsage();
|
||||
list.add(new JvmMemory(mxBean.getName(), usage));
|
||||
|
||||
@@ -14,32 +14,17 @@
|
||||
package com.zfoo.monitor.util;
|
||||
|
||||
import com.zfoo.monitor.*;
|
||||
import com.zfoo.net.util.NetUtils;
|
||||
import com.zfoo.protocol.exception.RunException;
|
||||
import com.zfoo.protocol.util.FileUtils;
|
||||
import com.zfoo.protocol.util.IOUtils;
|
||||
import com.zfoo.protocol.util.StringUtils;
|
||||
import com.zfoo.protocol.util.UuidUtils;
|
||||
import com.zfoo.scheduler.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import oshi.hardware.HWDiskStore;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.hardware.NetworkIF;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 监控工具类
|
||||
* Monitoring utility class
|
||||
*
|
||||
* @author godotg
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Oshi库封装的工具类,通过此工具类,可获取系统、硬件相关信息
|
||||
* Utility class wrapping the OSHI library for retrieving system and hardware information
|
||||
*
|
||||
* @author godotg
|
||||
*/
|
||||
@@ -46,37 +46,37 @@ public abstract class OSUtils {
|
||||
private static final Logger logger = LoggerFactory.getLogger(OSUtils.class);
|
||||
|
||||
/**
|
||||
* cpu的数量
|
||||
* CPU count
|
||||
*/
|
||||
private static final int processors = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
/**
|
||||
* 系统信息
|
||||
* System info
|
||||
*/
|
||||
private static final oshi.SystemInfo systemInfo = new oshi.SystemInfo();
|
||||
|
||||
/**
|
||||
* 硬件信息
|
||||
* Hardware info
|
||||
*/
|
||||
private static final HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
||||
|
||||
/**
|
||||
* 操作系统信息
|
||||
* OS info
|
||||
*/
|
||||
private static final OperatingSystem os = systemInfo.getOperatingSystem();
|
||||
|
||||
/**
|
||||
* 磁盘io
|
||||
* Disk I/O
|
||||
*/
|
||||
private static final List<HWDiskStore> hwDiskStores = hardware.getDiskStores();
|
||||
|
||||
/**
|
||||
* 网络信息
|
||||
* Network info
|
||||
*/
|
||||
private static final List<NetworkIF> networkIFs = hardware.getNetworkIFs();
|
||||
|
||||
/**
|
||||
* cpu的tick次数信息
|
||||
* CPU tick counts
|
||||
*/
|
||||
private static long[] ticks = hardware.getProcessor().getSystemCpuLoadTicks();
|
||||
|
||||
@@ -85,25 +85,25 @@ public abstract class OSUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将小于0的num转为百分比,舍弃的部分将会做四舍五入
|
||||
* Convert a value <= 1.0 to a percentage string; fractional part is rounded
|
||||
*/
|
||||
public static String toPercent(double num) {
|
||||
if (num > 1) {
|
||||
throw new RuntimeException("转为百分比的num必须小于1");
|
||||
throw new RuntimeException("num must be less than 1 to convert to percentage");
|
||||
}
|
||||
var percentFormat = NumberFormat.getPercentInstance();
|
||||
// 最大小数位数
|
||||
// Maximum decimal digits
|
||||
percentFormat.setMaximumFractionDigits(2);
|
||||
// 最大整数位数
|
||||
// Maximum integer digits
|
||||
percentFormat.setMaximumIntegerDigits(3);
|
||||
// 最小小数位数
|
||||
// Minimum decimal digits
|
||||
percentFormat.setMinimumFractionDigits(2);
|
||||
// 自动转换成百分比显示
|
||||
// Automatically convert to percentage format
|
||||
return percentFormat.format(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应于Linux中的uptime命令,windows中无法统计,所以在windows返回的结果默认是-1
|
||||
* Equivalent to the Linux 'uptime' command; returns -1 by default on Windows as it cannot be measured there
|
||||
*/
|
||||
public static Uptime uptime() {
|
||||
var processor = hardware.getProcessor();
|
||||
@@ -120,7 +120,7 @@ public abstract class OSUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应于Linux中的df -h命令,兼容windows
|
||||
* Equivalent to the Linux 'df -h' command, compatible with Windows
|
||||
*/
|
||||
public static List<DiskFileSystem> df() {
|
||||
var fileSystems = os.getFileSystem().getFileStores();
|
||||
@@ -153,7 +153,7 @@ public abstract class OSUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应于Linux中的free命令,兼容windows
|
||||
* Equivalent of Linux 'free' command; compatible with Windows
|
||||
*/
|
||||
public static Memory free() {
|
||||
var memory = hardware.getMemory();
|
||||
@@ -194,7 +194,7 @@ public abstract class OSUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应于Linux中的sar -n DEV 1命令,兼容windows
|
||||
* Equivalent of Linux 'sar -n DEV 1' command; compatible with Windows
|
||||
*/
|
||||
public static List<Sar> sar() {
|
||||
var nameSarMap = new HashMap<String, List<Sar>>();
|
||||
@@ -299,7 +299,7 @@ public abstract class OSUtils {
|
||||
.directory(wd)
|
||||
.start();
|
||||
|
||||
// 异步读取输出,避免缓冲区阻塞
|
||||
// Asynchronously read output to avoid blocking due to buffer overflow
|
||||
var stdoutFuture = executors.submit(ThreadUtils.safeCallable(() -> StringUtils.bytesToString(IOUtils.toByteArray(process.getInputStream()))));
|
||||
var stderrFuture = executors.submit(ThreadUtils.safeCallable(() -> StringUtils.bytesToString(IOUtils.toByteArray(process.getErrorStream()))));
|
||||
|
||||
@@ -313,7 +313,7 @@ public abstract class OSUtils {
|
||||
var stdout = stdoutFuture.get(timeoutMillis, TimeUnit.MILLISECONDS);
|
||||
var stderr = stderrFuture.get(timeoutMillis, TimeUnit.MILLISECONDS);
|
||||
|
||||
// 获取线程的退出值,0代表正常退出,非0代表异常中止
|
||||
// Get the process exit value; 0 means normal exit, non-zero means abnormal termination
|
||||
int exitValue = process.exitValue();
|
||||
if (exitValue != 0 || !stderr.isEmpty()) {
|
||||
logger.error("doExecCommand error executing command exitValue:[{}] stdout:[{}] stderr:[{}]", exitValue, stdout, stderr);
|
||||
|
||||
@@ -28,7 +28,7 @@ import oshi.SystemInfo;
|
||||
public class ApplicationTest {
|
||||
|
||||
/**
|
||||
* 仿Linux的uptime指令,可以用来监控cpu的负载,windows中无法统计,所以在windows返回的结果默认是-1
|
||||
* Emulates Linux's 'uptime' command for monitoring CPU load; returns -1 on Windows
|
||||
*/
|
||||
@Test
|
||||
public void uptimeTest() {
|
||||
@@ -38,7 +38,7 @@ public class ApplicationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* 仿Linux的df指令,可以用来监控硬盘容量
|
||||
* Emulates Linux's 'df' command for monitoring disk usage
|
||||
*/
|
||||
@Test
|
||||
public void dfTest() {
|
||||
@@ -50,7 +50,7 @@ public class ApplicationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* 仿Linux的free指令,可以用来监控内存占用
|
||||
* Emulates Linux's 'free' command for monitoring memory usage
|
||||
*/
|
||||
@Test
|
||||
public void freeTest() {
|
||||
@@ -60,7 +60,7 @@ public class ApplicationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* 仿Linux的sar指令,可以用来监控网络IO
|
||||
* Emulates Linux's 'sar' command for monitoring network I/O
|
||||
*/
|
||||
@Test
|
||||
public void sarTest() {
|
||||
@@ -72,7 +72,7 @@ public class ApplicationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* cpu的tick大小测试
|
||||
* Test CPU tick size
|
||||
*/
|
||||
@Test
|
||||
public void cpuTest() {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Gcc {
|
||||
.collect(Collectors.joining(StringUtils.SPACE));
|
||||
|
||||
|
||||
// 链接windows的网络库
|
||||
// Link Windows network library (ws2_32)
|
||||
var libraryLink = new StringBuilder();
|
||||
if (Platform.isWindows()) {
|
||||
libraryLink.append("-lws2_32");
|
||||
|
||||
Reference in new issue
Block a user