or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

file-system.mdhardware.mdindex.mdnetwork.mdoperating-system.mdprocess-management.mdsystem-info.md
tile.json

tessl/maven-com-github-oshi--oshi-core

JNA-based operating system and hardware information library for Java providing cross-platform access to system metrics

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/com.github.oshi/oshi-core@6.8.x

To install, run

npx @tessl/cli install tessl/maven-com-github-oshi--oshi-core@6.8.0

index.mddocs/

OSHI (Operating System & Hardware Information)

OSHI is a comprehensive Java library that provides cross-platform access to operating system and hardware information without requiring additional native library installations. Built on JNA (Java Native Access), it enables developers to retrieve detailed system metrics including OS version, process information, memory and CPU usage, disk and partition data, hardware devices, and sensor readings across Windows, macOS, and Linux platforms.

Package Information

  • Package Name: oshi-core
  • Package Type: Maven
  • Language: Java
  • Group ID: com.github.oshi
  • Artifact ID: oshi-core
  • Installation: <dependency><groupId>com.github.oshi</groupId><artifactId>oshi-core</artifactId><version>6.8.0</version></dependency>

Core Imports

import oshi.SystemInfo;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.software.os.OperatingSystem;

For specific components:

import oshi.hardware.CentralProcessor;
import oshi.hardware.GlobalMemory;
import oshi.software.os.OSProcess;
import oshi.software.os.FileSystem;

Basic Usage

import oshi.SystemInfo;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.software.os.OperatingSystem;

// Create SystemInfo instance - main entry point
SystemInfo si = new SystemInfo();

// Get hardware information
HardwareAbstractionLayer hal = si.getHardware();
long totalMemory = hal.getMemory().getTotal();
String cpuName = hal.getProcessor().getProcessorIdentifier().getName();

// Get operating system information
OperatingSystem os = si.getOperatingSystem();
String osFamily = os.getFamily();
int processCount = os.getProcessCount();

System.out.println("OS: " + osFamily);
System.out.println("CPU: " + cpuName);
System.out.println("Memory: " + totalMemory / 1024 / 1024 + " MB");
System.out.println("Processes: " + processCount);

Architecture

OSHI is built around several key components:

  • SystemInfo: Main entry point providing access to hardware and operating system abstractions
  • Hardware Abstraction Layer: Unified interface to hardware components (CPU, memory, disks, network, sensors)
  • Operating System Interface: Access to OS-specific information (processes, file systems, network configuration)
  • Platform Detection: Automatic detection and instantiation of platform-specific implementations
  • Cross-Platform Compatibility: Single API works across Windows, macOS, Linux, FreeBSD, Solaris, and AIX

Capabilities

System Information

Core entry point and platform detection for accessing system information across different operating systems.

class SystemInfo {
    SystemInfo();
    OperatingSystem getOperatingSystem();
    HardwareAbstractionLayer getHardware();
    static PlatformEnum getCurrentPlatform();
}

enum PlatformEnum {
    MACOS, LINUX, WINDOWS, SOLARIS, FREEBSD, OPENBSD, WINDOWSCE, AIX, ANDROID, GNU, KFREEBSD, NETBSD, UNKNOWN;
    String getName();
    static PlatformEnum getValue(int osType);
}

System Information

Hardware Information

Comprehensive hardware component access including CPU, memory, storage, network interfaces, and sensors with detailed performance metrics.

interface HardwareAbstractionLayer {
    CentralProcessor getProcessor();
    GlobalMemory getMemory();
    List<HWDiskStore> getDiskStores();
    List<NetworkIF> getNetworkIFs();
    List<PowerSource> getPowerSources();
    ComputerSystem getComputerSystem();
    List<Display> getDisplays();
    Sensors getSensors();
    List<UsbDevice> getUsbDevices(boolean tree);
    List<SoundCard> getSoundCards();
    List<GraphicsCard> getGraphicsCards();
}

Hardware Information

Operating System Information

Operating system details, process management, file system access, and network configuration with comprehensive process monitoring capabilities.

interface OperatingSystem {
    String getFamily();
    String getManufacturer();
    OSVersionInfo getVersionInfo();
    FileSystem getFileSystem();
    List<OSProcess> getProcesses();
    OSProcess getProcess(int pid);
    int getProcessCount();
    int getBitness();
    long getSystemUptime();
    NetworkParams getNetworkParams();
    List<OSSession> getSessions();
    List<OSService> getServices();
}

Operating System Information

Process Management

Detailed process and thread information including CPU usage, memory consumption, and process relationships with filtering and sorting capabilities.

interface OSProcess {
    String getName();
    String getPath();
    String getCommandLine();
    int getProcessID();
    int getParentProcessID();
    long getVirtualSize();
    long getResidentSetSize();
    double getProcessCpuLoadCumulative();
    List<OSThread> getThreadDetails();
    State getState();
}

Process Management

File System Access

File system information, mount points, disk usage statistics, and file store details with comprehensive storage metrics.

interface FileSystem {
    List<OSFileStore> getFileStores();
    long getOpenFileDescriptors();
    long getMaxFileDescriptors();
}

interface OSFileStore {
    String getName();
    String getType();
    long getTotalSpace();
    long getFreeSpace();
    long getUsableSpace();
    String getMount();
}

File System Access

Network Information

Network interface details, IP configuration, and network statistics including bandwidth usage and connection information.

interface NetworkIF {
    String getName();
    String getDisplayName();
    String getMacaddr();
    String[] getIPv4addr();
    String[] getIPv6addr();
    long getBytesRecv();
    long getBytesSent();
    long getSpeed();
}

Network Information

Types

Core Types

class SystemInfo {
    // Main entry point - no-arg constructor
}

enum PlatformEnum {
    MACOS("macOS"),
    LINUX("Linux"), 
    WINDOWS("Windows"),
    SOLARIS("Solaris"),
    FREEBSD("FreeBSD"),
    OPENBSD("OpenBSD"),
    AIX("AIX"),
    ANDROID("Android"),
    UNKNOWN("Unknown");
}

Hardware Types

interface HardwareAbstractionLayer {
    // Hardware component access methods
}

interface CentralProcessor {
    ProcessorIdentifier getProcessorIdentifier();
    long getMaxFreq();
    long[] getCurrentFreq();
    List<LogicalProcessor> getLogicalProcessors();
    int getLogicalProcessorCount();
    int getPhysicalProcessorCount();
}

interface GlobalMemory {
    long getTotal();
    long getAvailable();
    long getPageSize();
    VirtualMemory getVirtualMemory();
    List<PhysicalMemory> getPhysicalMemory();
}

interface ComputerSystem {
    String getManufacturer();
    String getModel();
    String getSerialNumber();
    String getHardwareUUID();
    Firmware getFirmware();
    Baseboard getBaseboard();
}

Operating System Types

interface OperatingSystem {
    // OS information and process management methods
}

class OSVersionInfo {
    String getVersion();
    String getCodeName();
    String getBuildNumber();
}

interface OSProcess {
    enum State {
        NEW, RUNNING, SLEEPING, WAITING, ZOMBIE, STOPPED, OTHER, INVALID, SUSPENDED
    }
}

interface OSThread {
    String getName();
    int getThreadId();
    OSProcess.State getState();
    long getStartTime();
    int getPriority();
}

Process Filtering and Sorting

class ProcessFiltering {
    static final Predicate<OSProcess> ALL_PROCESSES;
    static final Predicate<OSProcess> VALID_PROCESS;
    static final Predicate<OSProcess> NO_PARENT;
    static final Predicate<OSProcess> BITNESS_64;
    static final Predicate<OSProcess> BITNESS_32;
}

class ProcessSorting {
    static final Comparator<OSProcess> NO_SORTING;
    static final Comparator<OSProcess> CPU_DESC;
    static final Comparator<OSProcess> RSS_DESC;
    static final Comparator<OSProcess> UPTIME_ASC;
    static final Comparator<OSProcess> UPTIME_DESC;
    static final Comparator<OSProcess> PID_ASC;
    static final Comparator<OSProcess> PARENTPID_ASC;
    static final Comparator<OSProcess> NAME_ASC;
}