Add os details from base (oshi)

Add netstat from base (oshi)
Update 3rd party dependencies
Bump version
This commit is contained in:
Mark Nellemann 2021-11-06 20:32:54 +01:00
parent c755c964e0
commit 132619bb51
18 changed files with 318 additions and 6 deletions

View file

@ -60,8 +60,8 @@ public class ClientRouteBuilder extends RouteBuilder {
// Setup Camel route for this extension // Setup Camel route for this extension
// a unique timer name gives the timer it's own thread, otherwise it's a shared thread for other timers with same name. // a unique timer name gives the timer it's own thread, otherwise it's a shared thread for other timers with same name.
//from("timer:extensions?fixedRate=true&period=30s") String timerName = ext.isThreaded() ? ext.getProvides() : "default";
from("timer:"+provides+"?fixedRate=true&period=30s") from("timer:"+timerName+"?fixedRate=true&period=30s")
.bean(ext, "getMetrics") .bean(ext, "getMetrics")
.outputType(MetricResult.class) .outputType(MetricResult.class)
.process(new MetricEnrichProcessor(registry)) .process(new MetricEnrichProcessor(registry))

View file

@ -1,6 +1,6 @@
version=0.1.5 version=0.1.6
pf4jVersion=3.6.0 pf4jVersion=3.6.0
slf4jVersion=1.7.32 slf4jVersion=1.7.32
camelVersion=3.11.2 camelVersion=3.11.3
picocliVersion=4.6.1 picocliVersion=4.6.1
oshiVersion=5.8.2 oshiVersion=5.8.3

View file

@ -26,6 +26,7 @@ public class AixNetstatExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
@Override @Override
@ -33,6 +34,11 @@ public class AixNetstatExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
@ -69,6 +75,9 @@ public class AixNetstatExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -25,6 +25,7 @@ public class AixProcessorExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = true;
@Override @Override
@ -32,6 +33,11 @@ public class AixProcessorExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
@ -69,6 +75,9 @@ public class AixProcessorExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -18,6 +18,7 @@ class AixProcessorTest extends Specification {
stats.getSys() == 3.3f stats.getSys() == 3.3f
stats.getWait() == 0.0f stats.getWait() == 0.0f
stats.getIdle() == 13.0f stats.getIdle() == 13.0f
stats.getFields().get("smt") == 8
stats.getFields().get("ent") == 0.50f stats.getFields().get("ent") == 0.50f
stats.getFields().get("type") == "Shared" stats.getFields().get("type") == "Shared"
@ -37,6 +38,7 @@ class AixProcessorTest extends Specification {
stats.getSys() == 0.2f stats.getSys() == 0.2f
stats.getWait() == 0.0f stats.getWait() == 0.0f
stats.getIdle() == 99.7f stats.getIdle() == 99.7f
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"
@ -56,6 +58,7 @@ class AixProcessorTest extends Specification {
stats.getSys() == 0.0f stats.getSys() == 0.0f
stats.getWait() == 0.0f stats.getWait() == 0.0f
stats.getIdle() == 99.97f stats.getIdle() == 99.97f
stats.getFields().get("smt") == 8
stats.getFields().get("ent") == 4.00f stats.getFields().get("ent") == 4.00f
stats.getFields().get("mode") == "Uncapped" stats.getFields().get("mode") == "Uncapped"
stats.getFields().get("type") == "Shared" stats.getFields().get("type") == "Shared"

View file

@ -0,0 +1,92 @@
package sysmon.plugins.os_base;
import org.pf4j.Extension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import oshi.SystemInfo;
import oshi.hardware.HWDiskStore;
import oshi.hardware.HardwareAbstractionLayer;
import sysmon.shared.Measurement;
import sysmon.shared.MetricExtension;
import sysmon.shared.MetricResult;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Extension
public class BaseDetailsExtension implements MetricExtension {
private static final Logger log = LoggerFactory.getLogger(BaseDetailsExtension.class);
// Extension details
private final String name = "base_details";
private final String provides = "details";
private final String description = "Base Details Metrics";
// Configuration / Options
private boolean enabled = true;
private boolean threaded = false;
private SystemInfo systemInfo;
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public boolean isThreaded() {
return threaded;
}
@Override
public boolean isSupported() {
systemInfo = BasePlugin.getSystemInfo();
return systemInfo != 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");
}
if (map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
}
@Override
public MetricResult getMetrics() {
HashMap<String, Object> fieldsMap = new HashMap<String, Object>() {{
put("family", systemInfo.getOperatingSystem().getFamily()); // Freedesktop.org / AIX
put("manufacturer", systemInfo.getOperatingSystem().getManufacturer()); // GNU/Linux / IBM
put("os_codename", systemInfo.getOperatingSystem().getVersionInfo().getCodeName()); // Flatpak runtime / ppc64
put("os_version", systemInfo.getOperatingSystem().getVersionInfo().getVersion()); // 21.08.4 / 7.2
put("os_build", systemInfo.getOperatingSystem().getVersionInfo().getBuildNumber()); // 5.13.0-7620-generic / 2045B_72V
put("uptime", systemInfo.getOperatingSystem().getSystemUptime());
put("threads", systemInfo.getOperatingSystem().getThreadCount());
}};
return new MetricResult(name, new Measurement(new HashMap<>(), fieldsMap));
}
}

View file

@ -26,6 +26,7 @@ public class BaseDiskExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
private HardwareAbstractionLayer hardwareAbstractionLayer; private HardwareAbstractionLayer hardwareAbstractionLayer;
@ -35,6 +36,11 @@ public class BaseDiskExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer(); hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer();
@ -61,6 +67,9 @@ public class BaseDiskExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -27,6 +27,7 @@ public class BaseFilesystemExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
private List<?> excludeType = new ArrayList<String>() {{ private List<?> excludeType = new ArrayList<String>() {{
add("tmpfs"); add("tmpfs");
add("ahafs"); add("ahafs");
@ -44,6 +45,11 @@ public class BaseFilesystemExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
systemInfo = BasePlugin.getSystemInfo(); systemInfo = BasePlugin.getSystemInfo();
@ -72,6 +78,10 @@ public class BaseFilesystemExtension implements MetricExtension {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
if(map.containsKey("exclude_type")) { if(map.containsKey("exclude_type")) {
excludeType = (List<?>) map.get("exclude_type"); excludeType = (List<?>) map.get("exclude_type");
} }

View file

@ -23,6 +23,7 @@ public class BaseLoadExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
private HardwareAbstractionLayer hardwareAbstractionLayer; private HardwareAbstractionLayer hardwareAbstractionLayer;
@ -31,6 +32,11 @@ public class BaseLoadExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer(); hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer();
@ -57,6 +63,9 @@ public class BaseLoadExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -23,6 +23,7 @@ public class BaseMemoryExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
private HardwareAbstractionLayer hardwareAbstractionLayer; private HardwareAbstractionLayer hardwareAbstractionLayer;
@ -32,6 +33,11 @@ public class BaseMemoryExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer(); hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer();
@ -58,6 +64,9 @@ public class BaseMemoryExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -0,0 +1,106 @@
package sysmon.plugins.os_base;
import org.pf4j.Extension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import oshi.SystemInfo;
import oshi.hardware.HWDiskStore;
import oshi.hardware.HardwareAbstractionLayer;
import sysmon.shared.Measurement;
import sysmon.shared.MetricExtension;
import sysmon.shared.MetricResult;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Extension
public class BaseNetstatExtension implements MetricExtension {
private static final Logger log = LoggerFactory.getLogger(BaseNetstatExtension.class);
// Extension details
private final String name = "base_netstat";
private final String provides = "netstat";
private final String description = "Base Netstat Metrics";
// Configuration / Options
private boolean enabled = true;
private boolean threaded = false;
private SystemInfo systemInfo;
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public boolean isThreaded() {
return threaded;
}
@Override
public boolean isSupported() {
systemInfo = BasePlugin.getSystemInfo();
return systemInfo != 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");
}
if (map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
}
@Override
public MetricResult getMetrics() {
HashMap<String, Object> fieldsMap = new HashMap<String, Object>() {{
put("tcp4_conn_active", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv4Stats().getConnectionsActive());
put("tcp4_conn_passive", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv4Stats().getConnectionsPassive());
put("tcp4_conn_established", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv4Stats().getConnectionsEstablished());
put("tcp4_conn_failures", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv4Stats().getConnectionFailures());
put("tcp4_conn_reset", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv4Stats().getConnectionsReset());
put("tcp6_conn_active", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv6Stats().getConnectionsActive());
put("tcp6_conn_passive", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv6Stats().getConnectionsPassive());
put("tcp6_conn_established", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv6Stats().getConnectionsEstablished());
put("tcp6_conn_failures", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv6Stats().getConnectionFailures());
put("tcp6_conn_reset", systemInfo.getOperatingSystem().getInternetProtocolStats().getTCPv6Stats().getConnectionsReset());
put("udp4_data_sent", systemInfo.getOperatingSystem().getInternetProtocolStats().getUDPv4Stats().getDatagramsSent());
put("udp4_data_recv", systemInfo.getOperatingSystem().getInternetProtocolStats().getUDPv4Stats().getDatagramsReceived());
put("udp4_data_recv_error", systemInfo.getOperatingSystem().getInternetProtocolStats().getUDPv4Stats().getDatagramsReceivedErrors());
put("udp6_data_sent", systemInfo.getOperatingSystem().getInternetProtocolStats().getUDPv6Stats().getDatagramsSent());
put("udp6_data_recv", systemInfo.getOperatingSystem().getInternetProtocolStats().getUDPv6Stats().getDatagramsReceived());
put("udp6_data_recv_error", systemInfo.getOperatingSystem().getInternetProtocolStats().getUDPv6Stats().getDatagramsReceivedErrors());
}};
return new MetricResult(name, new Measurement(new HashMap<>(), fieldsMap));
}
}

View file

@ -26,6 +26,7 @@ public class BaseNetworkExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
private HardwareAbstractionLayer hardwareAbstractionLayer; private HardwareAbstractionLayer hardwareAbstractionLayer;
@ -35,6 +36,11 @@ public class BaseNetworkExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer(); hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer();
@ -61,6 +67,9 @@ public class BaseNetworkExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -23,6 +23,7 @@ public class BaseProcessExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
private List<?> includeList = new ArrayList<Object>() {{ private List<?> includeList = new ArrayList<Object>() {{
add("java"); add("java");
add("mysqld"); add("mysqld");
@ -39,6 +40,11 @@ public class BaseProcessExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
systemInfo = BasePlugin.getSystemInfo(); systemInfo = BasePlugin.getSystemInfo();
@ -65,6 +71,9 @@ public class BaseProcessExtension implements MetricExtension {
if(map.containsKey("enabled")) { if(map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
if(map.containsKey("include")) { if(map.containsKey("include")) {
includeList = (List<?>) map.get("include"); includeList = (List<?>) map.get("include");
} }

View file

@ -24,6 +24,7 @@ public class BaseProcessorExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
private HardwareAbstractionLayer hardwareAbstractionLayer; private HardwareAbstractionLayer hardwareAbstractionLayer;
private long[] oldTicks; private long[] oldTicks;
@ -33,6 +34,11 @@ public class BaseProcessorExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer(); hardwareAbstractionLayer = BasePlugin.getHardwareAbstractionLayer();
@ -59,6 +65,9 @@ public class BaseProcessorExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -23,6 +23,7 @@ public class TestExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
private AS400 as400; private AS400 as400;
private SystemStatus systemStatus; private SystemStatus systemStatus;
@ -33,6 +34,11 @@ public class TestExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
@ -80,6 +86,9 @@ public class TestExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -26,6 +26,7 @@ public class LinuxNetstatExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
@Override @Override
@ -33,6 +34,11 @@ public class LinuxNetstatExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
@ -69,6 +75,9 @@ public class LinuxNetstatExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -12,7 +12,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Extension // Disabled
//@Extension
public class LinuxSockstatExtension implements MetricExtension { public class LinuxSockstatExtension implements MetricExtension {
private static final Logger log = LoggerFactory.getLogger(LinuxSockstatExtension.class); private static final Logger log = LoggerFactory.getLogger(LinuxSockstatExtension.class);
@ -24,6 +25,7 @@ public class LinuxSockstatExtension implements MetricExtension {
// Configuration / Options // Configuration / Options
private boolean enabled = true; private boolean enabled = true;
private boolean threaded = false;
@Override @Override
@ -31,6 +33,11 @@ public class LinuxSockstatExtension implements MetricExtension {
return enabled; return enabled;
} }
@Override
public boolean isThreaded() {
return threaded;
}
@Override @Override
public boolean isSupported() { public boolean isSupported() {
@ -62,6 +69,9 @@ public class LinuxSockstatExtension implements MetricExtension {
if (map.containsKey("enabled")) { if (map.containsKey("enabled")) {
enabled = (boolean) map.get("enabled"); enabled = (boolean) map.get("enabled");
} }
if(map.containsKey("threaded")) {
threaded = (boolean) map.get("threaded");
}
} }
@Override @Override

View file

@ -7,6 +7,7 @@ import java.util.Map;
public interface MetricExtension extends ExtensionPoint { public interface MetricExtension extends ExtensionPoint {
boolean isEnabled(); boolean isEnabled();
boolean isThreaded();
boolean isSupported(); boolean isSupported();
String getName(); String getName();