mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-26 00:31:07 -06:00
log client hardware specs at startup
This commit is contained in:
parent
f50ac41978
commit
806f5380ae
@ -20,6 +20,7 @@ import io.nosqlbench.engine.core.script.Scenario;
|
||||
import io.nosqlbench.engine.core.script.ScenariosExecutor;
|
||||
import io.nosqlbench.engine.core.script.ScriptParams;
|
||||
import io.nosqlbench.engine.docker.DockerMetricsManager;
|
||||
import io.nosqlbench.nb.api.SystemId;
|
||||
import io.nosqlbench.nb.api.annotations.Annotation;
|
||||
import io.nosqlbench.nb.api.annotations.Layer;
|
||||
import io.nosqlbench.nb.api.content.Content;
|
||||
@ -285,15 +286,19 @@ public class NBCLI {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
logger.info("Running NoSQLBench Version " + new VersionInfo().getVersion());
|
||||
|
||||
logger.info("client-hardware: " + SystemId.getHostSummary());
|
||||
|
||||
logger.debug("initializing annotators with config:'" + annotatorsConfig + "'");
|
||||
Annotators.init(annotatorsConfig);
|
||||
Annotators.recordAnnotation(
|
||||
Annotation.newBuilder()
|
||||
.session(sessionName)
|
||||
.now()
|
||||
.layer(Layer.CLI)
|
||||
.detail("cli", Strings.join(args, "\n"))
|
||||
.build()
|
||||
Annotation.newBuilder()
|
||||
.session(sessionName)
|
||||
.now()
|
||||
.layer(Layer.CLI)
|
||||
.detail("cli", Strings.join(args, "\n"))
|
||||
.build()
|
||||
);
|
||||
|
||||
if (reportGraphiteTo != null || options.wantsReportCsvTo() != null) {
|
||||
|
@ -1,16 +1,21 @@
|
||||
package io.nosqlbench.nb.api;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.hardware.NetworkIF;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SystemId {
|
||||
|
||||
public static String getNodeId() {
|
||||
SystemInfo sysinfo = new SystemInfo();
|
||||
HardwareAbstractionLayer hal = sysinfo.getHardware();
|
||||
List<NetworkIF> interfaces = hal.getNetworkIFs();
|
||||
|
||||
Optional<String> first = interfaces.stream()
|
||||
.filter(i -> !i.getName().startsWith("docker" ))
|
||||
.filter(i -> !i.getName().equals("lo" ))
|
||||
@ -26,11 +31,45 @@ public class SystemId {
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
.flatMap(iface -> Arrays.stream(iface.getIPv4addr().clone()))
|
||||
.filter(addr -> !(addr.startsWith("127." )))
|
||||
.findFirst();
|
||||
String systemID = first.orElse("UNKNOWN_SYSTEM_ID" );
|
||||
.flatMap(iface -> Arrays.stream(iface.getIPv4addr().clone()))
|
||||
.filter(addr -> !(addr.startsWith("127.")))
|
||||
.findFirst();
|
||||
String systemID = first.orElse("UNKNOWN_SYSTEM_ID");
|
||||
return systemID;
|
||||
}
|
||||
|
||||
public static String getHostSummary() {
|
||||
SystemInfo sysinfo = new SystemInfo();
|
||||
HardwareAbstractionLayer hal = sysinfo.getHardware();
|
||||
CentralProcessor p = hal.getProcessor();
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
Set<String> ifspeeds = new HashSet<>();
|
||||
hal.getNetworkIFs().forEach(
|
||||
x -> {
|
||||
long spd = x.getSpeed();
|
||||
if (spd < (1024 * 1024 * 1000)) {
|
||||
ifspeeds.add(String.format("%.0fMib", (double) (spd / (1024 * 1024))));
|
||||
} else {
|
||||
ifspeeds.add(String.format("%.0fGib", (double) (spd / (1024 * 1024 * 1000))));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Map<String, Object> details = Map.of(
|
||||
"physical-cores", String.valueOf(p.getPhysicalProcessorCount()),
|
||||
"logical-cores", String.valueOf(p.getLogicalProcessors().size()),
|
||||
"max-frequency-ghz", String.format("%.2f", (p.getMaxFreq() / 1_000_000_000_000.0d)),
|
||||
"sockets", String.valueOf(p.getPhysicalPackageCount()),
|
||||
"processor-name", String.valueOf(p.getProcessorIdentifier().getName()),
|
||||
"memory-GiB", String.format("%.2f", hal.getMemory().getTotal() / (1024.0 * 1024.0 * 1024.0)),
|
||||
"heap-max-GiB", String.format("%.2f", Runtime.getRuntime().maxMemory() / (1024.0 * 1024.0 * 1024.0)),
|
||||
"if-speeds", ifspeeds
|
||||
|
||||
);
|
||||
|
||||
return gson.toJson(details);
|
||||
|
||||
}
|
||||
}
|
||||
|
12
nb-api/src/test/java/io/nosqlbench/nb/api/SystemIdTest.java
Normal file
12
nb-api/src/test/java/io/nosqlbench/nb/api/SystemIdTest.java
Normal file
@ -0,0 +1,12 @@
|
||||
package io.nosqlbench.nb.api;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class SystemIdTest {
|
||||
|
||||
@Test
|
||||
public void testHostInfo() {
|
||||
String info = SystemId.getHostSummary();
|
||||
System.out.println(info);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user