Skip to content

Commit

Permalink
[collecto] bugfix 1.CollectUtil.extractDoubleAndUnitFromStr bug eg:%M…
Browse files Browse the repository at this point in the history
…EM return null. 2.multiple definition of postgresql.shared_buffers (#869)

Co-authored-by: shenyumin <s_43011024>
  • Loading branch information
shenyumin authored Apr 14, 2023
1 parent 2343428 commit ca3ca5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
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

0 comments on commit ca3ca5e

Please sign in to comment.