Improve AIX lparstat parsing
Bump version 0.1.10 Update dependencies
This commit is contained in:
parent
16525059aa
commit
484834ff35
|
@ -30,6 +30,7 @@ dependencies {
|
||||||
implementation group: 'org.apache.camel', name: 'camel-bean', version: camelVersion
|
implementation group: 'org.apache.camel', name: 'camel-bean', version: camelVersion
|
||||||
implementation group: 'org.apache.camel', name: 'camel-timer', version: camelVersion
|
implementation group: 'org.apache.camel', name: 'camel-timer', version: camelVersion
|
||||||
implementation group: 'org.apache.camel', name: 'camel-stream', version: camelVersion
|
implementation group: 'org.apache.camel', name: 'camel-stream', version: camelVersion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def projectName = "sysmon-client"
|
def projectName = "sysmon-client"
|
||||||
|
|
|
@ -13,4 +13,9 @@ rpm -i --ignoreos sysmon-client.rpm sysmon-plugins.rpm
|
||||||
|
|
||||||
## Run automatically at boot
|
## Run automatically at boot
|
||||||
|
|
||||||
See the [sysv-init.md](sysv-init.md) file for instructions.
|
See the [sysv-init.md](sysv-init.md) file for instructions, or run from inittab:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mkitab "sysmon:2:respawn:env JAVA_HOME=/usr/java8_64 /opt/sysmon/client/bin/client -s http://10.x.y.z:9925/metrics"
|
||||||
|
init q
|
||||||
|
```
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
version = 0.1.9
|
version = 0.1.10
|
||||||
pf4jVersion = 3.6.0
|
pf4jVersion = 3.6.0
|
||||||
slf4jVersion = 1.7.33
|
slf4jVersion = 1.7.36
|
||||||
camelVersion = 3.14.1
|
camelVersion = 3.14.1
|
||||||
picocliVersion = 4.6.2
|
picocliVersion = 4.6.3
|
||||||
oshiVersion = 6.1.2
|
oshiVersion = 6.1.3
|
|
@ -26,9 +26,12 @@ subprojects {
|
||||||
exclude(group: "org.slf4j")
|
exclude(group: "org.slf4j")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task uberJar(type: Jar) {
|
task uberJar(type: Jar) {
|
||||||
|
duplicatesStrategy DuplicatesStrategy.EXCLUDE
|
||||||
from sourceSets.main.output
|
from sourceSets.main.output
|
||||||
dependsOn configurations.runtimeClasspath
|
dependsOn configurations.runtimeClasspath
|
||||||
from {
|
from {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -19,13 +20,16 @@ public class AixProcessorStat {
|
||||||
// System configuration: type=Shared mode=Uncapped smt=8 lcpu=8 mem=4096MB psize=19 ent=0.50
|
// System configuration: type=Shared mode=Uncapped smt=8 lcpu=8 mem=4096MB psize=19 ent=0.50
|
||||||
private static final Pattern patternAixShared = Pattern.compile("^System configuration: type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+)MB psize=(\\d+) ent=(\\d+\\.?\\d*)");
|
private static final Pattern patternAixShared = Pattern.compile("^System configuration: type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+)MB psize=(\\d+) ent=(\\d+\\.?\\d*)");
|
||||||
|
|
||||||
|
// System configuration: type=Dedicated mode=Capped smt=4 lcpu=12 mem=24576MB
|
||||||
// System configuration: type=Dedicated mode=Donating smt=8 lcpu=16 mem=4096MB
|
// System configuration: type=Dedicated mode=Donating smt=8 lcpu=16 mem=4096MB
|
||||||
private static final Pattern patternAixDedicated = Pattern.compile("^System configuration: type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+)MB");
|
private static final Pattern patternAixDedicated = Pattern.compile("^System configuration: type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+)MB");
|
||||||
|
|
||||||
|
|
||||||
// type=Shared mode=Uncapped smt=8 lcpu=4 mem=4101120 kB cpus=24 ent=4.00
|
// type=Shared mode=Uncapped smt=8 lcpu=4 mem=4101120 kB cpus=24 ent=4.00
|
||||||
private static final Pattern patternLinux = Pattern.compile("^type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+) kB cpus=(\\d+) ent=(\\d+\\.?\\d*)");
|
private static final Pattern patternLinux = Pattern.compile("^type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+) kB cpus=(\\d+) ent=(\\d+\\.?\\d*)");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String type; // Indicates the partition type. The value can be either dedicated or shared.
|
private String type; // Indicates the partition type. The value can be either dedicated or shared.
|
||||||
private String mode; // Indicates whether the partition processor capacity is capped uncapped.
|
private String mode; // Indicates whether the partition processor capacity is capped uncapped.
|
||||||
private int smt; // Indicates whether simultaneous multithreading is enabled or disabled in the partition.
|
private int smt; // Indicates whether simultaneous multithreading is enabled or disabled in the partition.
|
||||||
|
@ -86,17 +90,27 @@ public class AixProcessorStat {
|
||||||
|
|
||||||
//String lparstat = lines.get(lines.size() -1);
|
//String lparstat = lines.get(lines.size() -1);
|
||||||
String[] splitStr = Objects.requireNonNull(lastLine).trim().split("\\s+");
|
String[] splitStr = Objects.requireNonNull(lastLine).trim().split("\\s+");
|
||||||
if(type == null || (type.equalsIgnoreCase("shared") && splitStr.length < 9) ||
|
if(type == null ||
|
||||||
(type.equalsIgnoreCase("dedicated") && splitStr.length < 8) ) {
|
(mode.equalsIgnoreCase("Capped") && splitStr.length < 4) ||
|
||||||
throw new UnsupportedOperationException("lparstat string error: " + lastLine);
|
(type.equalsIgnoreCase("Shared") && splitStr.length < 9) ||
|
||||||
|
(type.equalsIgnoreCase("Dedicated") && mode.equalsIgnoreCase("Donating") && splitStr.length < 8)
|
||||||
|
) {
|
||||||
|
log.error("lparstat parse error - mode: {}, type: {}, content: {}", mode, type, Arrays.toString(splitStr));
|
||||||
|
throw new UnsupportedOperationException("lparstat parse error.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.user = Float.parseFloat(splitStr[0]);
|
this.user = Float.parseFloat(splitStr[0]);
|
||||||
this.sys = Float.parseFloat(splitStr[1]);
|
this.sys = Float.parseFloat(splitStr[1]);
|
||||||
this.wait = Float.parseFloat(splitStr[2]);
|
this.wait = Float.parseFloat(splitStr[2]);
|
||||||
this.idle = Float.parseFloat(splitStr[3]);
|
this.idle = Float.parseFloat(splitStr[3]);
|
||||||
|
|
||||||
|
if(mode.equalsIgnoreCase("Uncapped") || mode.equalsIgnoreCase("Donating")) {
|
||||||
this.physc = Float.parseFloat(splitStr[4]);
|
this.physc = Float.parseFloat(splitStr[4]);
|
||||||
if(type.equalsIgnoreCase("shared")) {
|
} else {
|
||||||
|
this.physc = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type.equalsIgnoreCase("Shared")) {
|
||||||
this.entc = Float.parseFloat(splitStr[5]);
|
this.entc = Float.parseFloat(splitStr[5]);
|
||||||
this.lbusy = Float.parseFloat(splitStr[6]);
|
this.lbusy = Float.parseFloat(splitStr[6]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,10 +24,10 @@ class AixProcessorTest extends Specification {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void "test AIX lparstat dedicated output processing"() {
|
void "test AIX lparstat dedicated-donating output processing"() {
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
InputStream inputStream = getClass().getResourceAsStream('/lparstat-aix-dedicated.txt')
|
InputStream inputStream = getClass().getResourceAsStream('/lparstat-aix-dedicated-donating.txt')
|
||||||
|
|
||||||
when:
|
when:
|
||||||
AixProcessorExtension extension = new AixProcessorExtension()
|
AixProcessorExtension extension = new AixProcessorExtension()
|
||||||
|
@ -41,6 +41,27 @@ class AixProcessorTest extends Specification {
|
||||||
stats.getFields().get("smt") == 8
|
stats.getFields().get("smt") == 8
|
||||||
stats.getFields().get("physc") == 0.07f
|
stats.getFields().get("physc") == 0.07f
|
||||||
stats.getFields().get("type") == "Dedicated"
|
stats.getFields().get("type") == "Dedicated"
|
||||||
|
stats.getFields().get("mode") == "Donating"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void "test AIX lparstat dedicated-capped output processing"() {
|
||||||
|
|
||||||
|
setup:
|
||||||
|
InputStream inputStream = getClass().getResourceAsStream('/lparstat-aix-dedicated-capped.txt')
|
||||||
|
|
||||||
|
when:
|
||||||
|
AixProcessorExtension extension = new AixProcessorExtension()
|
||||||
|
AixProcessorStat stats = extension.processCommandOutput(inputStream)
|
||||||
|
|
||||||
|
then:
|
||||||
|
stats.getUser() == 0.0f
|
||||||
|
stats.getSys() == 0.1f
|
||||||
|
stats.getWait() == 0.0f
|
||||||
|
stats.getIdle() == 99.9f
|
||||||
|
stats.getFields().get("smt") == 4
|
||||||
|
stats.getFields().get("type") == "Dedicated"
|
||||||
|
stats.getFields().get("mode") == "Capped"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
System configuration: type=Dedicated mode=Capped smt=4 lcpu=12 mem=24576MB
|
||||||
|
|
||||||
|
%user %sys %wait %idle %nsp
|
||||||
|
----- ----- ------ ------ -----
|
||||||
|
0.0 0.1 0.0 99.9 76
|
|
@ -17,7 +17,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation 'org.codehaus.groovy:groovy:3.0.8'
|
testImplementation 'org.codehaus.groovy:groovy:3.0.9'
|
||||||
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
|
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
testImplementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||||
|
|
Loading…
Reference in a new issue