...
|
...
|
@@ -11,6 +11,8 @@ import org.influxdb.dto.Point; |
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
...
|
...
|
@@ -59,7 +61,7 @@ public class PointBuilder { |
|
|
return point;
|
|
|
}
|
|
|
|
|
|
private static String findValueByKey(String key, List<ItemResponse.Item> items, List<HistoryResponse.HistoryItem> historyItems) {
|
|
|
private static Double findValueByKey(String key, List<ItemResponse.Item> items, List<HistoryResponse.HistoryItem> historyItems) {
|
|
|
|
|
|
String itemId = StringUtils.EMPTY;
|
|
|
|
...
|
...
|
@@ -107,6 +109,28 @@ public class PointBuilder { |
|
|
|
|
|
DEBUG.info("Find zabbix item key {} id {} value {}", key, itemId, itemValue);
|
|
|
|
|
|
return itemValue;
|
|
|
Double value = Double.parseDouble(itemValue);
|
|
|
|
|
|
return format(key, value);
|
|
|
}
|
|
|
|
|
|
|
|
|
public static Double format(String key, Double value) {
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
|
|
|
if (StringUtils.startsWith(key, "system.cpu")) {
|
|
|
//%
|
|
|
return new Double(decimalFormat.format(value));
|
|
|
} else if (StringUtils.startsWith(key, "net.if")) {
|
|
|
//kBps
|
|
|
return new Double(decimalFormat.format((value / 8192)));
|
|
|
} else if (StringUtils.startsWith(key, "vm.memory")) {
|
|
|
//MB
|
|
|
return new Double(decimalFormat.format((value / (1024 * 1024))));
|
|
|
} else {
|
|
|
return new Double(0.00);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
} |
...
|
...
|
|