From 88d6f9530edaf97f0cf83b8d0b2497dc16ec5eac Mon Sep 17 00:00:00 2001 From: Avinash Niyas Date: Thu, 1 Jan 2026 08:03:22 +0530 Subject: [PATCH] Capture Interface type, motherboard model Signed-off-by: Avinash Niyas --- src/jdiskmark/App.java | 5 +- src/jdiskmark/MainFrame.java | 4 ++ src/jdiskmark/Util.java | 89 +++++++++++++++++++++++++++++++++++- 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/src/jdiskmark/App.java b/src/jdiskmark/App.java index d0b80a6..b98b578 100644 --- a/src/jdiskmark/App.java +++ b/src/jdiskmark/App.java @@ -63,6 +63,7 @@ public enum Mode { CLI, GUI } public static String os; public static String arch; public static String processorName; + public static String motherBoardName; public static String jdk; // elevated priviledges public static boolean isRoot = false; @@ -167,6 +168,7 @@ public static void init() { os = System.getProperty("os.name"); arch = System.getProperty("os.arch"); processorName = Util.getProcessorName(); + motherBoardName=Util.getMotherBoardName(); jdk = Util.getJvmInfo(); checkPermission(); @@ -576,6 +578,7 @@ static public String getDriveInfo() { if (locationDir == null) { return LOCATION_NOT_SELECTED_ERROR; } + String interFaceType=Util.getInterfaceType(); String driveModel = Util.getDriveModel(locationDir); String partitionId = Util.getPartitionId(locationDir.toPath()); DiskUsageInfo usageInfo; @@ -585,7 +588,7 @@ static public String getDriveInfo() { usageInfo = new DiskUsageInfo(); Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } - return driveModel + " - " + partitionId + ": " + usageInfo.getUsageTitleDisplay(); + return interFaceType + " - " + driveModel + " - " + partitionId + ": " + usageInfo.getUsageTitleDisplay(); } static public String getDriveModel() { diff --git a/src/jdiskmark/MainFrame.java b/src/jdiskmark/MainFrame.java index 1de875f..e058271 100644 --- a/src/jdiskmark/MainFrame.java +++ b/src/jdiskmark/MainFrame.java @@ -68,6 +68,10 @@ public MainFrame() { if (App.processorName != null && !App.processorName.isEmpty()) { titleSb.append(" - ").append(App.processorName); } + + if (App.motherBoardName != null && !App.motherBoardName.isEmpty()) { + titleSb.append(" | ").append(App.motherBoardName); + } // permission indicator if (App.isAdmin) titleSb.append(" [Admin]"); diff --git a/src/jdiskmark/Util.java b/src/jdiskmark/Util.java index 45dcdd6..d84fc10 100644 --- a/src/jdiskmark/Util.java +++ b/src/jdiskmark/Util.java @@ -11,6 +11,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.filechooser.FileSystemView; /** @@ -49,7 +51,7 @@ static public boolean deleteDirectory(File path) { * @param min Minimum value * @param max Maximum value. Must be greater than min. * @return Integer between min and max, inclusive. - * @see java.util.Random#nextInt(int) + * @see Random#nextInt(int) */ public static int randInt(int min, int max) { @@ -273,4 +275,89 @@ public static String getProcessorName() { } return "processor name unknown"; } + + public static String getMotherBoardName() { + + Process process = null; + + try { + if (App.os.startsWith("Windows")) { + process = new ProcessBuilder("wmic", "baseboard", "get", "Product").start(); + } else if (App.os.contains("Linux")) { + process = new ProcessBuilder("cat", "/sys/devices/virtual/dmi/id/board_name").start(); + } else if (App.os.startsWith("Mac OS")) { + process = new ProcessBuilder("system_profiler", "SPHardwareDataType").start(); + } + } catch (IOException e) { + Logger.getLogger(Util.class.getName()) + .log(Level.FINE, "Unable to get Motherboard Name", e); + return null; + } + + // If no command was set (unsupported OS) + if (process == null) { return null; } + + try (BufferedReader reader = + new BufferedReader(new InputStreamReader(process.getInputStream()))) { + + StringBuilder builder = new StringBuilder(); + String line; + + while ((line = reader.readLine()) != null) { + builder.append(line).append(" "); + } + + return builder.toString().trim(); + + } catch (IOException e) { + Logger.getLogger(Util.class.getName()) + .log(Level.FINE, "Unable to read Motherboard Name", e); + return null; + } + } + + public static String getInterfaceType(){ + Process process = null; + + try { + if (App.os.startsWith("Windows")) { + process = new ProcessBuilder("wmic", "diskdrive", "get", "InterfaceType").start(); + } else if (App.os.contains("Linux")) { + process = new ProcessBuilder("lsblk", "-d", "-o", "tran").start(); + } else if (App.os.startsWith("Mac OS")) { + process = new ProcessBuilder("diskutil", "info", "disk0").start(); + } + } catch (IOException e) { + Logger.getLogger(Util.class.getName()) + .log(Level.FINE, "Unable to get Interface Type", e); + return "OS not supported"; + } + + if (process == null) { return "OS not supported"; } + + try (BufferedReader reader = + new BufferedReader(new InputStreamReader(process.getInputStream()))) { + + String line; + + while ((line = reader.readLine()) != null) { + + line=line.trim(); + + if(line.isEmpty()) { continue;} + + if(line.equalsIgnoreCase("InterfaceType") || line.equalsIgnoreCase("TRAN")|| line.equalsIgnoreCase("NAME")) { continue;} + + return line; + } + + } catch (IOException e) { + Logger.getLogger(Util.class.getName()) + .log(Level.FINE, "Unable to read Interface Type", e); + return "OS not supported"; + } + + return "OS not supported"; + } + }