Merged in development (pull request #14)

Development
This commit is contained in:
Mark Nellemann 2021-10-14 15:35:24 +00:00
commit 0dfd307f2a
5 changed files with 744 additions and 461 deletions

View file

@ -43,5 +43,4 @@ tasks.create("packages") {
dependsOn ":plugins:buildDeb"
dependsOn ":plugins:buildRpm"
}

View file

@ -1,4 +1,4 @@
version=0.1.3
version=0.1.5
pf4jVersion=3.6.0
slf4jVersion=1.7.32
camelVersion=3.11.2

View file

@ -26,12 +26,12 @@ public class AixProcessorStat {
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;
private String mode;
private int smt;
private int lcpu;
private int psize;
private float ent;
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 int smt; // Indicates whether simultaneous multithreading is enabled or disabled in the partition.
private int lcpu; // Indicates the number of online logical processors.
//private int psize; // Indicates the number of online physical processors in the pool.
private float ent; // Indicates the entitled processing capacity in processor units (shared mode only).
private final float user; // Indicates the percentage of the entitled processing capacity used while executing at the user level (application).
private final float sys; // Indicates the percentage of the entitled processing capacity used while executing at the system level (kernel).
@ -56,7 +56,7 @@ public class AixProcessorStat {
mode = matcher.group(2);
smt = Integer.parseInt(matcher.group(3));
lcpu = Integer.parseInt(matcher.group(4));
psize = Integer.parseInt(matcher.group(5));
//psize = Integer.parseInt(matcher.group(6));
ent = Float.parseFloat(matcher.group(7));
}
matcher = patternAixDedicated.matcher(line);
@ -75,8 +75,8 @@ public class AixProcessorStat {
type = matcher.group(1);
mode = matcher.group(2);
smt = Integer.parseInt(matcher.group(3));
//psize = Integer.parseInt(matcher.group(4));
lcpu = Integer.parseInt(matcher.group(4));
psize = Integer.parseInt(matcher.group(6));
ent = Float.parseFloat(matcher.group(7));
}
}
@ -156,6 +156,7 @@ public class AixProcessorStat {
put("lbusy", lbusy);
put("mode", mode);
put("type", type);
put("smt", smt);
}};
}
}

View file

@ -0,0 +1,76 @@
package sysmon.plugins.os_base;
import org.pf4j.Extension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import oshi.hardware.HardwareAbstractionLayer;
import sysmon.shared.Measurement;
import sysmon.shared.MetricExtension;
import sysmon.shared.MetricResult;
import java.util.HashMap;
import java.util.Map;
@Extension
public class BaseLoadExtension implements MetricExtension {
private static final Logger log = LoggerFactory.getLogger(BaseLoadExtension.class);
// Extension details
private final String name = "base_load";
private final String provides = "load";
private final String description = "Base Load Average Metrics";
// Configuration / Options
private boolean enabled = true;
private HardwareAbstractionLayer hardwareAbstractionLayer;
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public boolean isSupported() {
hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer();
return hardwareAbstractionLayer != null;
}
@Override
public String getName() {
return name;
}
@Override
public String getProvides() {
return provides;
}
@Override
public String getDescription() {
return description;
}
@Override
public void setConfiguration(Map<String, Object> map) {
if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled");
}
}
@Override
public MetricResult getMetrics() {
double[] loadAvg = hardwareAbstractionLayer.getProcessor().getSystemLoadAverage(3);
HashMap<String, Object> fieldsMap = new HashMap<String, Object>() {{
put("1min", loadAvg[0]);
put("5min", loadAvg[1]);
put("15min", loadAvg[2]);
}};
log.debug(fieldsMap.toString());
return new MetricResult(name, new Measurement(new HashMap<String, String>(), fieldsMap));
}
}