Changes to reflect updated deps.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
91c604e765
commit
7b9d27a124
|
@ -3,7 +3,6 @@ package sysmon.plugins.base;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.pf4j.Plugin;
|
import org.pf4j.Plugin;
|
||||||
import org.pf4j.PluginWrapper;
|
|
||||||
import oshi.SystemInfo;
|
import oshi.SystemInfo;
|
||||||
import oshi.hardware.HardwareAbstractionLayer;
|
import oshi.hardware.HardwareAbstractionLayer;
|
||||||
|
|
||||||
|
@ -15,9 +14,6 @@ public class BasePlugin extends Plugin {
|
||||||
private static SystemInfo systemInfo;
|
private static SystemInfo systemInfo;
|
||||||
private static HardwareAbstractionLayer hardwareAbstractionLayer;
|
private static HardwareAbstractionLayer hardwareAbstractionLayer;
|
||||||
|
|
||||||
public BasePlugin(PluginWrapper wrapper) {
|
|
||||||
super(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HardwareAbstractionLayer getHardwareAbstractionLayer() {
|
public static HardwareAbstractionLayer getHardwareAbstractionLayer() {
|
||||||
|
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
package sysmon.plugins.base;
|
|
||||||
|
|
||||||
import org.pf4j.Extension;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import oshi.hardware.HardwareAbstractionLayer;
|
|
||||||
import oshi.hardware.PowerSource;
|
|
||||||
import sysmon.shared.Measurement;
|
|
||||||
import sysmon.shared.MetricExtension;
|
|
||||||
import sysmon.shared.MetricResult;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
@Extension
|
|
||||||
public class BasePowerExtension implements MetricExtension {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(BasePowerExtension.class);
|
|
||||||
|
|
||||||
// Extension details
|
|
||||||
private final String name = "base_power";
|
|
||||||
private final String description = "Base Power Metrics";
|
|
||||||
|
|
||||||
// Configuration / Options
|
|
||||||
private boolean enabled = true;
|
|
||||||
private boolean threaded = false;
|
|
||||||
private String interval = "30s";
|
|
||||||
|
|
||||||
private HardwareAbstractionLayer hardwareAbstractionLayer;
|
|
||||||
private List<PowerSource> powerSources;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isThreaded() {
|
|
||||||
return threaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSupported() {
|
|
||||||
hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer();
|
|
||||||
return hardwareAbstractionLayer != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInterval() {
|
|
||||||
return interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setConfiguration(Map<String, Object> map) {
|
|
||||||
if (map.containsKey("enabled")) {
|
|
||||||
enabled = (boolean) map.get("enabled");
|
|
||||||
}
|
|
||||||
if (map.containsKey("threaded")) {
|
|
||||||
threaded = (boolean) map.get("threaded");
|
|
||||||
}
|
|
||||||
if (map.containsKey("interval")) {
|
|
||||||
interval = (String) map.get("interval");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MetricResult getMetrics() {
|
|
||||||
|
|
||||||
if(powerSources == null) {
|
|
||||||
powerSources = hardwareAbstractionLayer.getPowerSources();
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<Measurement> measurementList = new ArrayList<>();
|
|
||||||
powerSources.forEach((source) -> {
|
|
||||||
log.info("name: {}", source.getName());
|
|
||||||
log.info("amp: {}", source.getAmperage());
|
|
||||||
log.info("voltage: {}", source.getVoltage());
|
|
||||||
|
|
||||||
TreeMap<String, String> tagsMap = new TreeMap<String, String>() {
|
|
||||||
{
|
|
||||||
put("name", source.getName());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TreeMap<String, Object> fieldsMap = new TreeMap<String, Object>() {
|
|
||||||
{
|
|
||||||
put("amperage", source.getAmperage());
|
|
||||||
put("voltage", source.getVoltage());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
log.debug("getMetrics() - tags: {}, fields: {}", tagsMap, fieldsMap);
|
|
||||||
measurementList.add(new Measurement(tagsMap, fieldsMap));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return new MetricResult(name, measurementList);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,16 +1,7 @@
|
||||||
package sysmon.plugins.power;
|
package sysmon.plugins.power;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.pf4j.Plugin;
|
import org.pf4j.Plugin;
|
||||||
import org.pf4j.PluginWrapper;
|
|
||||||
|
|
||||||
public class PowerPlugin extends Plugin {
|
public class PowerPlugin extends Plugin {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(PowerPlugin.class);
|
|
||||||
|
|
||||||
public PowerPlugin(PluginWrapper wrapper) {
|
|
||||||
super(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue