Skip to content
/ oshi Public
forked from oshi/oshi

Native Operating System and Hardware Information

License

Notifications You must be signed in to change notification settings

kaweesi/oshi

 
 

Repository files navigation

OSHI

Join the chat at https://gitter.im/dblock/oshi Maven central Eclipse Public License Build Status Dependency Status

OSHI is a free JNA-based (native) operating system and hardware information library for Java. It doesn't require any additional native DLLs and aims to provide a cross-platform implementation to retrieve system information, such as version, memory, CPU, disk, battery, displays, etc.

About This Fork

  • I forked OSHI to use it in OpenMRS System Monitor Module
  • I needed to support lower java version starting from 1.6 which i have done in this fork

Essentials

Currently supported platforms

  • Windows
  • Linux
  • Mac OS X

Currently supported features

  • Operating System and Version/Build
  • Physical (core) and Logical (hyperthreaded) CPUs
  • System and per-processor load % and tick counters
  • CPU uptime, processes, and threads
  • Process uptime, cpu, memory usage
  • Physical and virtual memory used/available
  • Network interfaces (IPs, bandwidth in/out)
  • Battery state (% capacity, time remaining)
  • Disk drives (model, serial, size)
  • File stores (usable and total space)
  • Connected displays (with EDID info)
  • USB Devices
  • Sensors (temperature, fan speeds, voltage)

Output

OSHI provides output directly via java methods or in JSON format for each of its interfaces. By periodically polling dynamic information (e.g., every second), users can calculate and track changes.

The main() method of SystemInfoTest provides sample code demonstrating the use of the interfaces to retrieve information and calculate additional metrics such as the below examples.

General information about the operating system and processor.

Microsoft Windows 7 (Home)
Intel(R) Core(TM)2 Duo CPU T7300  @ 2.00GHz
 4 physical CPU(s)
 8 logical CPU(s)
Identifier: Intel64 Family 6 Model 42 Stepping 7
Serial Num: 09203-891-5001202-52183

Process information is available

Processes: 401, Threads: 1159
   PID  %CPU %MEM       VSZ       RSS Name
 55977  27.9  0.2   6.8 GiB  34.3 MiB java
 51820  18.7  5.6   6.3 GiB 919.2 MiB eclipse
 39272  11.2 17.8   7.1 GiB   2.8 GiB prl_vm_app
 85316   6.5  2.9   5.6 GiB 471.4 MiB thunderbird
 35301   5.4  0.5   1.7 GiB  89.8 MiB Microsoft Excel

By measuring ticks (user, nice, system, idle, iowait, and irq) between time intervals, percent usage can be calculated. Java MXBean and per-processor information is also provided.

CPU, IOWait, and IRQ ticks @ 0 sec:[967282, 15484, 195343, 124216619], 6176, [4054, 2702]
CPU, IOWait, and IRQ ticks @ 1 sec:[967308, 15484, 195346, 124216790], 6177, [4057, 2705]
User: 13.0% Nice: 0.0% System: 1.5% Idle: 85.5%
CPU load: 8.8% (counting ticks)
CPU load: 9.0% (OS MXBean)
CPU load averages: 2.69 2.47 2.38
CPU load per processor: 23.6% 1.3% 18.2% 0.7% 12.9% 0.7% 12.1% 1.3%

Sensor readings are available for some hardware (see notes in the FAQ).

Sensors:
 CPU Temperature: 69.8°C
 Fan Speeds:[4685, 4687]
 CPU Voltage: 3.9V

The EDID for each Display is provided. This can be parsed with various utilities for detailed information. OSHI provides a summary of selected data.

Displays:
 Display 0:
  Manuf. ID=SAM, Product ID=2ad, Analog, Serial=HA19, ManufDate=3/2008, EDID v1.3
  41 x 27 cm (16.1 x 10.6 in)
  Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 
  Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz
  Monitor Name: SyncMaster
  Serial Number: H9FQ345476
 Display 1:
  Manuf. ID=SAM, Product ID=226, Analog, Serial=HA19, ManufDate=4/2007, EDID v1.3
  41 x 26 cm (16.1 x 10.2 in)
  Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 
  Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz
  Monitor Name: SyncMaster
  Serial Number: HMCP431880

Attached USB devices can be listed:

USB Devices:
 AppleUSBEHCI
 |-- Root Hub Simulation Simulation (Apple Inc.)
     |-- IOUSBHostDevice
         |-- IR Receiver (Apple Computer, Inc.)
         |-- USB Receiver (Logitech)
 AppleUSBEHCI
 |-- Root Hub Simulation Simulation (Apple Inc.)
     |-- FaceTime HD Camera (Built-in) (Apple Inc.) [s/n: DJHB1V077FDH5HL0]
     |-- IOUSBHostDevice
         |-- Apple Internal Keyboard / Trackpad (Apple Inc.)
         |-- BRCM2070 Hub (Apple Inc.)
             |-- Bluetooth USB Host Controller (Apple Inc.)
 AppleUSBEHCI
 |-- Root Hub Simulation Simulation (Apple Inc.)
     |-- IOUSBHostDevice
         |-- Apple Thunderbolt Display (Apple Inc.) [s/n: 162C0C25]
         |-- Display Audio (Apple Inc.) [s/n: 162C0C25]
         |-- FaceTime HD Camera (Display) (Apple Inc.) [s/n: CCGCAN000TDJ7DFX]
         |-- USB2.0 Hub
             |-- ANT USBStick2 (Dynastream Innovations) [s/n: 051]
             |-- Fitbit Base Station (Fitbit Inc.)

Where are we?

OSHI is a young project. While we've developed a strong core of features on major Operating Systems, we'd like you to contribute ports, and help implement more methods, and suggest new features. Read the project intro.

How is this different from ...

  • Sigar:
    • Sigar uses JNI which requires a native DLL to be installed. OSHI uses JNA and doesn't require a native DLL to be installed.
    • Sigar is licensed under Apache 2.0 license. OSHI is distributed under the EPL license.
    • The last stable release of Sigar (1.6.4) was in 2010. OSHI is under active development as-of 2016.
  • jHardware:
    • jHardware does not require JNA but instead uses command-line parsing. OSHI uses some command line parsing but attempts to use native commands whenever possible.
    • jHardware presently only supports Windows and Unix systems.
    • jHardware is licensed under Apache 2.0 license. OSHI is distributed under the EPL license.
  • OperatingSystemMXBean
    • The com.sun.management MXBean may not be availabile in non-Oracle JVMs.
    • The MXBean has very few methods that address system-wide statistics.
    • OSHI provides significantly more information than the OperatingSystemMXBean.

License

This project is licensed under the Eclipse Public License 1.0.

About

Native Operating System and Hardware Information

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%