Skip to content

Commit

Permalink
Merge branch 'master' into feat-collector-alarm
Browse files Browse the repository at this point in the history
  • Loading branch information
Aias00 authored Oct 26, 2024
2 parents 3ec4a79 + bb0a22c commit e59e1f3
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public Map<String, MetricFamily> textToMetric(String resp) {

private void parseLine(Map<String, MetricFamily> metricMap, StrBuffer buffer) {
buffer.skipBlankTabs();
if (buffer.isEmpty()) return;
if (buffer.isEmpty()) {
return;
}
switch (buffer.charAt(0)) {
case '#' -> {
buffer.read();
Expand Down Expand Up @@ -231,7 +233,9 @@ private void startReadLabelValue(MetricFamily.Metric metric, MetricFamily.Label

private void readLabelValue(MetricFamily.Metric metric, MetricFamily.Label label, StrBuffer buffer) {
buffer.skipBlankTabs();
if (buffer.isEmpty()) return;
if (buffer.isEmpty()) {
return;
}
switch (this.currentMetricFamily.getMetricType()) {
case INFO -> {
MetricFamily.Info info = new MetricFamily.Info();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public static Map<String, MetricFamily> textToMetricFamilies(String resp) {

private static void parseLine(Map<String, MetricFamily> metricMap, StrBuffer buffer) {
buffer.skipBlankTabs();
if (buffer.isEmpty()) return;
if (buffer.isEmpty()) {
return;
}
switch (buffer.charAt(0)) {
case '#':
case ENTER:
Expand Down Expand Up @@ -95,7 +97,9 @@ private static void parseMetric(Map<String, MetricFamily> metricMap, StrBuffer b

private static void readLabels(MetricFamily.Metric metric, StrBuffer buffer) {
buffer.skipBlankTabs();
if (buffer.isEmpty()) return;
if (buffer.isEmpty()) {
return;
}
metric.setLabels(new LinkedList<>());
if (buffer.charAt(0) == LEFT_CURLY_BRACKET) {
buffer.read();
Expand All @@ -107,11 +111,15 @@ private static void readLabels(MetricFamily.Metric metric, StrBuffer buffer) {

private static void startReadLabelName(MetricFamily.Metric metric, StrBuffer buffer) {
buffer.skipBlankTabs();
if (buffer.isEmpty()) return;
if (buffer.isEmpty()) {
return;
}
if (buffer.charAt(0) == RIGHT_CURLY_BRACKET) {
buffer.read();
buffer.skipBlankTabs();
if (buffer.isEmpty()) return;
if (buffer.isEmpty()) {
return;
}
readLabelValue(metric, buffer);
return;
}
Expand All @@ -129,7 +137,9 @@ private static void startReadLabelName(MetricFamily.Metric metric, StrBuffer buf

private static void startReadLabelValue(MetricFamily.Metric metric, MetricFamily.Label label, StrBuffer buffer) {
buffer.skipBlankTabs();
if (buffer.isEmpty()) return;
if (buffer.isEmpty()) {
return;
}
char c = buffer.read();
if (c != QUOTES) {
throw new ParseException("expected '\"' at start of label value, line: " + buffer.toStr());
Expand All @@ -140,7 +150,9 @@ private static void startReadLabelValue(MetricFamily.Metric metric, MetricFamily
throw new ParseException("no valid label value: " + labelValue);
}
metric.getLabels().add(label);
if (buffer.isEmpty()) return;
if (buffer.isEmpty()) {
return;
}
c = buffer.read();
switch (c) {
case COMMA -> startReadLabelName(metric, buffer);
Expand All @@ -151,7 +163,9 @@ private static void startReadLabelValue(MetricFamily.Metric metric, MetricFamily

private static void readLabelValue(MetricFamily.Metric metric, StrBuffer buffer) {
buffer.skipBlankTabs();
if (buffer.isEmpty()) return;
if (buffer.isEmpty()) {
return;
}
metric.setValue(buffer.toDouble());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,23 @@ private void snmpClose(Snmp snmp, int version) throws IOException {
}

private TargetBuilder.PrivProtocol getPrivPasswordEncryption(String privPasswordEncryption) {
if (privPasswordEncryption == null) return TargetBuilder.PrivProtocol.des;
else if (AES128.equals(privPasswordEncryption)) {
if (privPasswordEncryption == null) {
return TargetBuilder.PrivProtocol.des;
} else if (AES128.equals(privPasswordEncryption)) {
return TargetBuilder.PrivProtocol.aes128;
} else return TargetBuilder.PrivProtocol.des;
} else {
return TargetBuilder.PrivProtocol.des;
}
}

private TargetBuilder.AuthProtocol getAuthPasswordEncryption(String authPasswordEncryption) {
if (authPasswordEncryption == null) return TargetBuilder.AuthProtocol.md5;
else if (SHA1.equals(authPasswordEncryption)) return TargetBuilder.AuthProtocol.sha1;
else return TargetBuilder.AuthProtocol.md5;
if (authPasswordEncryption == null) {
return TargetBuilder.AuthProtocol.md5;
} else if (SHA1.equals(authPasswordEncryption)) {
return TargetBuilder.AuthProtocol.sha1;
} else {
return TargetBuilder.AuthProtocol.md5;
}
}

private String getContextName(String contextName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void closeConnection() throws Exception {
}
}

@Override
public ClientSession getConnection() {
return clientSession;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public void sendMetricsData(CollectRep.MetricsData metricsData) {
}
}

@Override
public void destroy() {

connection.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public byte type() {
return 1;
}

@Override
@EventListener(SystemConfigChangeEvent.class)
public void onEvent(SystemConfigChangeEvent event) {
log.info("{} receive system config change event: {}.", this.getClass().getName(), event.getSource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public abstract class AbstractHistoryDataStorage implements HistoryDataReader, H
/**
* @return data storage available
*/
@Override
public boolean isServerAvailable() {
return serverAvailable;
}
Expand Down

0 comments on commit e59e1f3

Please sign in to comment.