Github – Oshi Health
Launching Visual Studio
If nothing happens, download the travelhome.vn extension for Visual Studio and try again.
Đang xem: Github
Go back
OSHI is a free JNA-based (native) Operating System and Hardware Information library for Java.It does not require the installation of any additional native libraries and aims to provide across-platform implementation to retrieve system information, such as OS version, processes,memory and CPU usage, disks and partitions, devices, sensors, etc.
Supported platforms
Windows • Linux • macOS • Unix (AIX, FreeBSD, OpenBSD, Solaris)
Essentials
Supported features
Computer System and firmware, baseboardOperating System and Version/BuildPhysical (core) and Logical (hyperthreaded) CPUs, processor groups, NUMA nodesSystem and per-processor load, usage tick counters, interrupts, uptimeProcess uptime, CPU, memory usage, user/group, command line args, thread detailsPhysical and virtual memory used/availableMounted filesystems (type, usable and total space, options, reads and writes)Disk drives (model, serial, size, reads and writes) and partitionsNetwork interfaces (IPs, bandwidth in/out), network parameters, TCP/UDP statisticsBattery state (% capacity, time remaining, power usage stats)USB DevicesConnected displays (with EDID info), graphics and audio cardsSensors (temperature, fan speeds, voltage) on some hardware
Downloads
oshi-core-5.7.0 | oshi-core-5.7.1-SNAPSHOT | JNA • SLF4J |
oshi-core-java11-5.7.0 | oshi-core-java11-5.7.1-SNAPSHOT |
Usage
Create a new instance of SystemInfo
Use the getters from SystemInfo to access hardware or operating system components, such as:
SystemInfo si = new SystemInfo();HardwareAbstractionLayer hal = si.getHardware();CentralProcessor cpu = hal.getProcessor();See the PERFORMANCE document for general CPU/Memory tradeoffs and specific Windows (WMI) recommendations depending upon your application.
See the FAQ document for common implementation and calculation questions.
Some settings are configurable in the oshi.properties file, which may also be manipulated using the GlobalConfig class. This should be done at startup, as configuration is not thread-safe and OSHI does not guarantee re-reading the configuration during operation.
The oshi-demo artifact includes several proof-of-concept examples of using OSHI to obtain information, including a basic Swing GUI.
Note: OSHI uses the latest version of JNA.If you experience a NoClassDefFoundError or NoSuchMethodError issues with JNA artifacts, you likely havean older version of either jna or jna-platform in your classpath from a transitive dependency on another project.Consider one or more of the following steps to resolve the conflict:
Listing OSHI earlier (or first) in your dependency listSpecifying the most recent version of JNA (both jna and jna-platform artifacts) in your pom.xml as dependencies.If you are using the Spring Boot Starter Parent version 2.2 and earlier that includes JNA as a dependency:Upgrade to version 2.3 which does not have a JNA dependency (preferred)If you must use version 2.2 or earlier, override the jna.version property to the latest JNA version.
Support
For help integrating OSHI into your own project or maintainer code review of your PRs, tag
dbwiddis in issues or pull requests on your project site.
Xem thêm: Vé Xe Khách Đà Nẵng Vinh Nghệ An: Limousine, Xe Khách Giường Nằm
OSHI for enterprise
Available as part of the Tidelift Subscription
The maintainers of OSHI and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
Security contact information
To report a security vulnerability, please use the Tidelift security contact.Tidelift will coordinate the fix and disclosure.
Output
OSHI provides output directly via Java methods for each of its interfaces.By periodically polling dynamic information (e.g., every second), users can calculate and track changes.
You can see more examples and run the SystemInfoTestand see the full output for your system by cloning the project and building it with Maven:
git clone https://travelhome.vn/oshi/oshi.git && cd oshi./mvnw test-compile -pl oshi-core exec:java -Dexec.mainClass=”oshi.SystemInfoTest” -Dexec.classpathScope=”test”In addition, the oshi-demo project includes an OshiGui class implementing a basic Swing GUI offering suggestions for potential visualizations using OSHI in a UI, monitoring, or alerting application, as shown below:
General information about the operating system and computer system hardware:
By measuring ticks (user, nice, system, idle, iowait, and irq) between time intervals, percent usage can be calculated.Per-processor information is also provided.
Process information including CPU and memory per process is available.
Memory and swapfile information is available.
Xem thêm: ship đồ ăn trưa ở hà nội
Statistics for the system battery are provided:
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 3840×2880 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 3840×2880 Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz Monitor Name: SyncMaster Serial Number: HMCP431880Disks and usage (reads, writes, transfer times) are shown, and partitions can be mapped to filesystems.
Disks: disk0: (model: SanDisk Ultra II 960GB – S/N: 161008800550) size: 960.2 GB, reads: 1053132 (23.0 GiB), writes: 243792 (11.1 GiB), xfer: 73424854 ms |– disk0s1: EFI (EFI System Partition) Maj:Min=1:1, size: 209.7 MB |– disk0s2: Macintosh HD (Macintosh SSD) Maj:Min=1:2, size: 959.3 GB
/ disk1: (model: Disk Image – S/N: ) size: 960.0 GB, reads: 3678 (60.0 MiB), writes: 281 (8.6 MiB), xfer: 213627 ms |– disk1s1: EFI (EFI System Partition) Maj:Min=1:4, size: 209.7 MB |– disk1s2: Dropbox (disk image) Maj:Min=1:5, size: 959.7 GB
Bình luận