Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[collector] bugfix 1.CollectUtil.extractDoubleAndUnitFromStr bug eg:%M… #869

Merged
merged 2 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class CollectUtil {
private static final String CRYING_PLACEHOLDER_REX = "\\^o\\^";
private static final String CRYING_PLACEHOLDER_REGEX = "(\\^o\\^)(\\w|-|$|\\.)+(\\^o\\^)";
private static final Pattern CRYING_PLACEHOLDER_REGEX_PATTERN = Pattern.compile(CRYING_PLACEHOLDER_REGEX);
private static final List<String> UNIT_SYMBOLS = Arrays.asList("G", "g", "M", "m", "K", "k", "B", "b", "%");
private static final List<String> UNIT_SYMBOLS = Arrays.asList("%","G", "g", "M", "m", "K", "k", "B", "b");

/**
* 关键字匹配计数
Expand Down Expand Up @@ -89,16 +89,16 @@ public static DoubleAndUnit extractDoubleAndUnitFromStr(String str) {
// B KB MB GB % ....
for (String unitSymbol : UNIT_SYMBOLS) {
int index = str.indexOf(unitSymbol);
if (index > 0) {
Double doubleValue = Double.parseDouble(str.substring(0, index));
String unit = str.substring(index).trim();
if (index == 0) {
Double doubleValue = 0d;
String unit = str.trim();
doubleAndUnit.setValue(doubleValue);
doubleAndUnit.setUnit(unit);
return doubleAndUnit;
}
if (index == 0) {
Double doubleValue = 0d;
String unit = str.trim();
if (index > 0) {
Double doubleValue = Double.parseDouble(str.substring(0, index));
String unit = str.substring(index).trim();
doubleAndUnit.setValue(doubleValue);
doubleAndUnit.setUnit(unit);
return doubleAndUnit;
Expand Down
3 changes: 0 additions & 3 deletions manager/src/main/resources/define/app-postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ metrics:
priority: 1
fields:
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
- field: shared_buffers
type: 0
unit: MB
- field: work_mem
type: 0
unit: MB
Expand Down