Support dedicated lparstat output
This commit is contained in:
parent
3a4a4bdb8a
commit
a5ae0f2700
13
doc/AIX.md
Normal file
13
doc/AIX.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# AIX Notes
|
||||
|
||||
## Installation
|
||||
|
||||
```shell
|
||||
rpm -i --ignoreos sysmon-client.rpm sysmon-plugins.rpm
|
||||
```
|
||||
|
||||
## Run automatically at boot
|
||||
|
||||
```shell
|
||||
mkitab 'sysmon:2:respawn:env JAVA_HOME=/usr/java8_64 /opt/sysmon/client/bin/client -s http://10.20.30.40:9925/metrics >/tmp/sysmon.log 2>&1'
|
||||
```
|
10
doc/sysmon-client.service
Normal file
10
doc/sysmon-client.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Sysmon Client Service
|
||||
|
||||
[Service]
|
||||
TimeoutStartSec=0
|
||||
Restart=always
|
||||
ExecStart=/opt/sysmon/client/bin/client -s http://10.20.30.40:9925/metrics
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
10
doc/sysmon-server.service
Normal file
10
doc/sysmon-server.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Sysmon Server Service
|
||||
|
||||
[Service]
|
||||
TimeoutStartSec=0
|
||||
Restart=always
|
||||
ExecStart=/opt/sysmon/server/bin/server
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
12
doc/systemd.md
Normal file
12
doc/systemd.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# SystemD Notes
|
||||
|
||||
Edit the *sysmon-client.service* file and change the sysmon-server URL accordingly to your environment.
|
||||
|
||||
Setup as systemd service to start automatically at boot:
|
||||
|
||||
```shell
|
||||
cp sysmon-client.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable sysmon-client
|
||||
systemctl restart sysmon-client
|
||||
```
|
|
@ -12,6 +12,7 @@ subprojects {
|
|||
dependencies {
|
||||
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
|
||||
testImplementation "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
testImplementation "org.slf4j:slf4j-simple:${slf4jVersion}"
|
||||
testImplementation project(':shared')
|
||||
|
||||
implementation project(':shared')
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package sysmon.plugins.os_aix;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -8,8 +11,13 @@ import java.util.regex.Pattern;
|
|||
|
||||
public class AixProcessorStat {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AixProcessorStat.class);
|
||||
|
||||
// System configuration: type=Shared mode=Uncapped smt=8 lcpu=8 mem=4096MB psize=19 ent=0.50
|
||||
private final Pattern patternAix = Pattern.compile("^System configuration: type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+)MB psize=(\\d+) ent=(\\d+\\.?\\d*)");
|
||||
private 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=Donating smt=8 lcpu=16 mem=4096MB
|
||||
private 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
|
||||
private final Pattern patternLinux = Pattern.compile("^type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+) kB cpus=(\\d+) ent=(\\d+\\.?\\d*)");
|
||||
|
@ -36,7 +44,7 @@ public class AixProcessorStat {
|
|||
for (String line : lines) {
|
||||
|
||||
if (line.startsWith("System configuration:")) {
|
||||
Matcher matcher = patternAix.matcher(line);
|
||||
Matcher matcher = patternAixShared.matcher(line);
|
||||
if (matcher.find() && matcher.groupCount() == 7) {
|
||||
type = matcher.group(1);
|
||||
mode = matcher.group(2);
|
||||
|
@ -45,6 +53,13 @@ public class AixProcessorStat {
|
|||
psize = Integer.parseInt(matcher.group(5));
|
||||
ent = Float.parseFloat(matcher.group(7));
|
||||
}
|
||||
matcher = patternAixDedicated.matcher(line);
|
||||
if (matcher.find() && matcher.groupCount() == 5) {
|
||||
type = matcher.group(1);
|
||||
mode = matcher.group(2);
|
||||
smt = Integer.parseInt(matcher.group(3));
|
||||
lcpu = Integer.parseInt(matcher.group(4));
|
||||
}
|
||||
}
|
||||
|
||||
if (line.startsWith("type=")) {
|
||||
|
@ -64,7 +79,8 @@ public class AixProcessorStat {
|
|||
|
||||
String lparstat = lines.get(lines.size() -1);
|
||||
String[] splitStr = lparstat.trim().split("\\s+");
|
||||
if(splitStr.length < 9) {
|
||||
if(type.equalsIgnoreCase("shared") && splitStr.length < 9 ||
|
||||
type.equalsIgnoreCase("dedicated") && splitStr.length < 8) {
|
||||
throw new UnsupportedOperationException("lparstat string error: " + lparstat);
|
||||
}
|
||||
|
||||
|
@ -73,9 +89,13 @@ public class AixProcessorStat {
|
|||
this.wait = Float.parseFloat(splitStr[2]);
|
||||
this.idle = Float.parseFloat(splitStr[3]);
|
||||
this.physc = Float.parseFloat(splitStr[4]);
|
||||
this.entc = Float.parseFloat(splitStr[5]);
|
||||
this.lbusy = Float.parseFloat(splitStr[6]);
|
||||
|
||||
if(type.equalsIgnoreCase("shared")) {
|
||||
this.entc = Float.parseFloat(splitStr[5]);
|
||||
this.lbusy = Float.parseFloat(splitStr[6]);
|
||||
} else {
|
||||
this.entc = 0f;
|
||||
this.lbusy = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float getUser() {
|
||||
|
|
|
@ -4,10 +4,10 @@ import spock.lang.Specification
|
|||
|
||||
class AixProcessorTest extends Specification {
|
||||
|
||||
void "test AIX lparstat output processing"() {
|
||||
void "test AIX lparstat shared output processing"() {
|
||||
|
||||
setup:
|
||||
def testFile = new File(getClass().getResource('/lparstat-aix.txt').toURI())
|
||||
def testFile = new File(getClass().getResource('/lparstat-aix-shared.txt').toURI())
|
||||
List<String> lines = testFile.readLines("UTF-8")
|
||||
|
||||
when:
|
||||
|
@ -20,9 +20,29 @@ class AixProcessorTest extends Specification {
|
|||
stats.getWait() == 0.0f
|
||||
stats.getIdle() == 13.0f
|
||||
stats.getFields().get("ent") == 0.50f
|
||||
stats.getFields().get("type") == "Shared"
|
||||
|
||||
}
|
||||
|
||||
void "test AIX lparstat dedicated output processing"() {
|
||||
|
||||
setup:
|
||||
def testFile = new File(getClass().getResource('/lparstat-aix-dedicated.txt').toURI())
|
||||
List<String> lines = testFile.readLines("UTF-8")
|
||||
|
||||
when:
|
||||
AixProcessorExtension extension = new AixProcessorExtension()
|
||||
AixProcessorStat stats = extension.processCommandOutput(lines)
|
||||
|
||||
then:
|
||||
stats.getUser() == 0.1f
|
||||
stats.getSys() == 0.2f
|
||||
stats.getWait() == 0.0f
|
||||
stats.getIdle() == 99.7f
|
||||
stats.getFields().get("physc") == 0.07f
|
||||
stats.getFields().get("type") == "Dedicated"
|
||||
|
||||
}
|
||||
|
||||
void "test Linux lparstat output processing"() {
|
||||
|
||||
|
@ -45,4 +65,6 @@ class AixProcessorTest extends Specification {
|
|||
|
||||
}
|
||||
|
||||
// java.lang.UnsupportedOperationException: lparstat string error: 2.2 1.2 0.0 96.6 0.28 1100 132 24.23
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
System configuration: type=Dedicated mode=Donating smt=8 lcpu=16 mem=4096MB
|
||||
|
||||
%user %sys %wait %idle physc vcsw %nsp %utcyc
|
||||
----- ----- ------ ------ ----- ----- ----- ------
|
||||
0.1 0.2 0.0 99.7 0.07 1014627468 132 24.21
|
|
@ -0,0 +1,44 @@
|
|||
package sysmon.plugins.os_ibmi;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sysmon.shared.MetricExtension;
|
||||
import sysmon.shared.MetricResult;
|
||||
|
||||
public class TestExtension implements MetricExtension {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TestExtension.class);
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
|
||||
String osArch = System.getProperty("os.arch").toLowerCase();
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
|
||||
System.err.println("OS Arch: " + osArch);
|
||||
System.err.println("OS Name: " + osName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ibmi-test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProvides() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "IBM i Test Extension";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetricResult getMetrics() {
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue