Improve AIX lparstat parsing
Bump version 0.1.10 Update dependencies
This commit is contained in:
parent
484834ff35
commit
be233d52b9
20
CHANGELOG.md
Normal file
20
CHANGELOG.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [0.1.10] - 2022-03-01
|
||||||
|
### Added
|
||||||
|
- (client) More debug options.
|
||||||
|
- (plugins/linux) Re-enabled network socket-statistics extension.
|
||||||
|
### Changed
|
||||||
|
- Updated the oshi dependency to v. 6.1.4.
|
||||||
|
- (plugins/aix) Improved AIX lparstat parsing.
|
||||||
|
- (plugins/aix) More debug output from (Power) processor extension.
|
||||||
|
- (plugins/base) More debug output from plugins-base disk extension.
|
||||||
|
|
||||||
|
## [0.1.9] - 2022-02-15
|
||||||
|
### Changed
|
||||||
|
- Updated 3rd party dependencies.
|
||||||
|
|
||||||
|
[0.1.10]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v0.1.10%0Dv0.1.9
|
||||||
|
[0.1.9]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v0.1.9%0Dv0.1.8
|
|
@ -1,6 +1,6 @@
|
||||||
# Client / Agent
|
# Client / Agent
|
||||||
|
|
||||||
This is the client component of SysMon. Install on the hosts where you want to collect metrics.
|
This is the client/agent component of SysMon, which you install (together with sysmon-plugins) on the hosts where you want to collect metrics.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,11 @@ public class Application implements Callable<Integer> {
|
||||||
@CommandLine.Option(names = { "-c", "--conf" }, description = "Configuration file [default: '/etc/sysmon-client.toml'].", paramLabel = "<file>", defaultValue = "/etc/sysmon-client.toml")
|
@CommandLine.Option(names = { "-c", "--conf" }, description = "Configuration file [default: '/etc/sysmon-client.toml'].", paramLabel = "<file>", defaultValue = "/etc/sysmon-client.toml")
|
||||||
private File configurationFile;
|
private File configurationFile;
|
||||||
|
|
||||||
@CommandLine.Option(names = { "-d", "--debug" }, description = "Enable debugging (default: ${DEFAULT_VALUE}).")
|
//@CommandLine.Option(names = { "-d", "--debug" }, description = "Enable debugging (default: ${DEFAULT_VALUE}).")
|
||||||
private boolean enableDebug = false;
|
//private boolean enableDebug = false;
|
||||||
|
|
||||||
|
@CommandLine.Option(names = { "-d", "--debug" }, description = "Enable debugging (default: ${DEFAULT_VALUE}).")
|
||||||
|
private boolean[] enableDebug = new boolean[0];
|
||||||
|
|
||||||
public static void main(String... args) {
|
public static void main(String... args) {
|
||||||
int exitCode = new CommandLine(new Application()).execute(args);
|
int exitCode = new CommandLine(new Application()).execute(args);
|
||||||
|
@ -42,10 +44,22 @@ public class Application implements Callable<Integer> {
|
||||||
public Integer call() {
|
public Integer call() {
|
||||||
|
|
||||||
String sysmonDebug = System.getProperty("sysmon.debug");
|
String sysmonDebug = System.getProperty("sysmon.debug");
|
||||||
if(sysmonDebug != null || enableDebug) {
|
if(sysmonDebug != null) {
|
||||||
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "INFO");
|
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "INFO");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (enableDebug.length) {
|
||||||
|
case 1:
|
||||||
|
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "INFO");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
String sysmonCfgFile = System.getProperty("sysmon.cfgFile");
|
String sysmonCfgFile = System.getProperty("sysmon.cfgFile");
|
||||||
if(sysmonCfgFile != null) {
|
if(sysmonCfgFile != null) {
|
||||||
configurationFile = new File(sysmonCfgFile);
|
configurationFile = new File(sysmonCfgFile);
|
||||||
|
|
|
@ -3,4 +3,4 @@ pf4jVersion = 3.6.0
|
||||||
slf4jVersion = 1.7.36
|
slf4jVersion = 1.7.36
|
||||||
camelVersion = 3.14.1
|
camelVersion = 3.14.1
|
||||||
picocliVersion = 4.6.3
|
picocliVersion = 4.6.3
|
||||||
oshiVersion = 6.1.3
|
oshiVersion = 6.1.4
|
|
@ -94,6 +94,7 @@ public class AixProcessorExtension implements MetricExtension {
|
||||||
log.error("lparstat error", e);
|
log.error("lparstat error", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.debug("getMetrics() - tags: {}, fields: {}", tagsMap, fieldsMap);
|
||||||
return new MetricResult(name, new Measurement(tagsMap, fieldsMap));
|
return new MetricResult(name, new Measurement(tagsMap, fieldsMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class AixProcessorStat {
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
while(reader.ready()) {
|
while(reader.ready()) {
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
|
log.trace("AixProcessorStat() - {}", line);
|
||||||
|
|
||||||
if (line.startsWith("System configuration:")) {
|
if (line.startsWith("System configuration:")) {
|
||||||
Matcher matcher = patternAixShared.matcher(line);
|
Matcher matcher = patternAixShared.matcher(line);
|
||||||
|
|
|
@ -94,6 +94,7 @@ public class BaseDiskExtension implements MetricExtension {
|
||||||
put("queue", store.getCurrentQueueLength());
|
put("queue", store.getCurrentQueueLength());
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
log.debug("getMetrics() - tags: {}, fields: {}", tagsMap, fieldsMap);
|
||||||
measurementList.add(new Measurement(tagsMap, fieldsMap));
|
measurementList.add(new Measurement(tagsMap, fieldsMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,10 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
// Disabled
|
@Extension
|
||||||
//@Extension
|
public class LinuxSocketExtension implements MetricExtension {
|
||||||
public class LinuxSockstatExtension implements MetricExtension {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(LinuxSockstatExtension.class);
|
private static final Logger log = LoggerFactory.getLogger(LinuxSocketExtension.class);
|
||||||
|
|
||||||
// Extension details
|
// Extension details
|
||||||
private final String name = "linux_network_sockets";
|
private final String name = "linux_network_sockets";
|
||||||
|
@ -77,16 +76,17 @@ public class LinuxSockstatExtension implements MetricExtension {
|
||||||
@Override
|
@Override
|
||||||
public MetricResult getMetrics() {
|
public MetricResult getMetrics() {
|
||||||
|
|
||||||
LinuxNetworkSockStat sockStat = processSockOutput(PluginHelper.readFile("/proc/net/sockstat"));
|
LinuxSocketStat sockStat = processSockOutput(PluginHelper.readFile("/proc/net/sockstat"));
|
||||||
|
|
||||||
HashMap<String, String> tagsMap = sockStat.getTags();
|
HashMap<String, String> tagsMap = sockStat.getTags();
|
||||||
HashMap<String, Object> fieldsMap = sockStat.getFields();
|
HashMap<String, Object> fieldsMap = sockStat.getFields();
|
||||||
|
|
||||||
|
log.debug("getMetrics() - tags: {}, fields: {}", tagsMap, fieldsMap);
|
||||||
return new MetricResult(name, new Measurement(tagsMap, fieldsMap));
|
return new MetricResult(name, new Measurement(tagsMap, fieldsMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LinuxNetworkSockStat processSockOutput(List<String> inputLines) {
|
protected LinuxSocketStat processSockOutput(List<String> inputLines) {
|
||||||
return new LinuxNetworkSockStat(inputLines);
|
return new LinuxSocketStat(inputLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,9 +8,9 @@ import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class LinuxNetworkSockStat {
|
public class LinuxSocketStat {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(LinuxNetworkSockStat.class);
|
private static final Logger log = LoggerFactory.getLogger(LinuxSocketStat.class);
|
||||||
|
|
||||||
private static final Pattern pattern1 = Pattern.compile("^sockets: used (\\d+)");
|
private static final Pattern pattern1 = Pattern.compile("^sockets: used (\\d+)");
|
||||||
private static final Pattern pattern2 = Pattern.compile("^TCP: inuse (\\d+) orphan (\\d+) tw (\\d+) alloc (\\d+) mem (\\d+)");
|
private static final Pattern pattern2 = Pattern.compile("^TCP: inuse (\\d+) orphan (\\d+) tw (\\d+) alloc (\\d+) mem (\\d+)");
|
||||||
|
@ -35,7 +35,7 @@ public class LinuxNetworkSockStat {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
LinuxNetworkSockStat(List<String> lines) {
|
LinuxSocketStat(List<String> lines) {
|
||||||
|
|
||||||
Matcher matcher;
|
Matcher matcher;
|
||||||
for(String line : lines) {
|
for(String line : lines) {
|
|
@ -1,6 +1,6 @@
|
||||||
import spock.lang.Specification
|
import spock.lang.Specification
|
||||||
import sysmon.plugins.os_linux.LinuxSockstatExtension
|
import sysmon.plugins.os_linux.LinuxSocketExtension
|
||||||
import sysmon.plugins.os_linux.LinuxNetworkSockStat
|
import sysmon.plugins.os_linux.LinuxSocketStat
|
||||||
|
|
||||||
class LinuxNetworkTest extends Specification {
|
class LinuxNetworkTest extends Specification {
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ class LinuxNetworkTest extends Specification {
|
||||||
List<String> lines = testFile.readLines("UTF-8")
|
List<String> lines = testFile.readLines("UTF-8")
|
||||||
|
|
||||||
when:
|
when:
|
||||||
LinuxSockstatExtension extension = new LinuxSockstatExtension()
|
LinuxSocketExtension extension = new LinuxSocketExtension()
|
||||||
LinuxNetworkSockStat stats = extension.processSockOutput(lines)
|
LinuxSocketStat stats = extension.processSockOutput(lines)
|
||||||
|
|
||||||
then:
|
then:
|
||||||
stats.getFields().get("sockets") == 1238L
|
stats.getFields().get("sockets") == 1238L
|
||||||
|
|
|
@ -53,13 +53,6 @@ public class Application implements Callable<Integer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
InfluxDB influxDB = InfluxDBFactory.connect(influxUrl.toString(), influxUser, influxPass);
|
InfluxDB influxDB = InfluxDBFactory.connect(influxUrl.toString(), influxUser, influxPass);
|
||||||
/*
|
|
||||||
try {
|
|
||||||
influxDB.query(new Query("CREATE DATABASE " + influxName));
|
|
||||||
} catch (InfluxDBException e) {
|
|
||||||
System.err.println(e.getMessage());
|
|
||||||
return -1;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
Main main = new Main();
|
Main main = new Main();
|
||||||
main.bind("myInfluxConnection", influxDB);
|
main.bind("myInfluxConnection", influxDB);
|
||||||
|
|
Loading…
Reference in a new issue