开源OSHI :一个免费的基于 JNA 的 (本机) Java 操作系统和硬件信息库

开源 0

https://github.com/oshi/oshi

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 a cross-platform implementation to retrieve system information, such as OS version, processes, memory and CPU usage, disks and partitions, devices, sensors, etc.
OSHI 是一个免费的基于 JNA 的 (本机) Java 操作系统和硬件信息库。它不需要安装任何其他本机库,旨在提供跨平台实现来检索系统信息,例如操作系统版本、进程、内存和 CPU 使用率、磁盘和分区、设备、传感器等。

  • Supported Platforms 支持的平台
  • Downloads and Dependency Management
    下载和依赖项管理
  • Documentation 文档
  • Usage 用法
  • Supported Features 支持的功能
  • Support 支持
  • OSHI for Enterprise OSHI 企业版
  • Security Contact Information
    安全联系信息
  • Continuous Integration Test Status
    持续集成测试状态
  • How Can I Help? 我能帮忙吗?
  • Contributing to OSHI 为 OSHI 做出贡献
  • Acknowledgments 确认
  • License 许可证

Supported Platforms 支持的平台

  • Windows 窗户
  • macOS macOS 的
  • Linux (Android) Linux (Android)
  • UNIX (AIX, FreeBSD, OpenBSD, Solaris)
    UNIX(AIX、FreeBSD、OpenBSD、Solaris)

Documentation 文档

  • API (javadocs) API (javadocs)
  • FAQ 常见问题
  • Change Log 更改日志
  • Performance Considerations
    性能注意事项
  • Major Version Breaking Changes
    主要版本重大更改
  • Sample Output 示例输出
  • Applications and Projects using OSHI
    使用 OSHI 的应用程序和项目

Downloads and Dependency Management 下载和依赖项管理

Stable Release Version 稳定发布版本

  • JDK8: oshi-core-6.6.3
    JDK8:oshi-core-6.6.3
  • JPMS: oshi-core-java11-6.6.3
    JPMS:oshi-core-java11-6.6.3
  • JDK6: oshi-core-3.14.0
    JDK6:oshi-core-3.14.0

Current Development (SNAPSHOT) downloads
当前开发 (SNAPSHOT) 下载

  • JDK8: oshi-core-6.6.4-SNAPSHOT
    JDK8:oshi-core-6.6.4-快照
  • JPMS: oshi-core-java11-6.6.4-SNAPSHOT
    JPMS:oshi-core-java11-6.6.4-SNAPSHOT

Usage 用法

  1. Include OSHI and its dependencies on your classpath.

    在 Classpath 中包含 OSHI 及其依赖项。

    • We strongly recommend you add oshi-core as a dependency to your project dependency manager such as Maven or Gradle.
      我们强烈建议您将 oshi-core 作为依赖项添加到您的项目依赖项管理器(如 Maven 或 Gradle)中。
    • For Android, you’ll need to add the AAR artifact for JNA and exclude OSHI’s transitive (JAR) dependency.
      对于 Android,您需要为 JNA 添加 AAR 工件,并排除 OSHI 的传递 (JAR) 依赖项。
    • See the FAQ if you encounter NoClassDefFoundError or NoSuchMethodError problems.
      如果您遇到 NoClassDefFoundErrorNoSuchMethodError 问题,请参阅 FAQ。
  2. Create a new instance of SystemInfo
    创建 SystemInfo 的新实例

  3. Use the getters from SystemInfo to access hardware or operating system components, such as:
    使用 SystemInfo 中的 getter 访问硬件或操作系统组件,例如:

SystemInfo si = new SystemInfo();HardwareAbstractionLayer hal = si.getHardware();CentralProcessor cpu = hal.getProcessor();

See SystemInfoTest.java for examples. To see sample output for your machine:
有关示例,请参阅 SystemInfoTest.java。要查看计算机的示例输出,请执行以下操作:

git clone https://github.com/oshi/oshi.git && cd oshi./mvnw test-compile -pl oshi-core exec:java /  -Dexec.mainClass="oshi.SystemInfoTest" /  -Dexec.classpathScope="test"

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.
某些设置可以在 oshi.properties 文件中进行配置,也可以使用 GlobalConfig 类进行操作。这应该在启动时完成,因为配置不是线程安全的,并且 OSHI 不保证在操作期间重新读取配置。

The oshi-demo artifact includes several proof-of-concept examples of using OSHI to obtain information, including a basic Swing GUI.
oshi-demo 工件包括使用 OSHI 获取信息的几个概念验证示例,包括基本的 Swing GUI。

Supported Features 支持的功能

  • Computer System and firmware, baseboard
    计算机系统和固件、底板
  • Operating System and Version/Build
    操作系统和版本/内部版本
  • Physical (core) and Logical (hyperthreaded) CPUs, processor groups, NUMA nodes
    物理(核心)和逻辑(超线程)CPU、处理器组、NUMA 节点
  • System and per-processor load, usage tick counters, interrupts, uptime
    系统和每个处理器的负载、使用情况滴答计数器、中断、正常运行时间
  • Process uptime, CPU, memory usage, user/group, command line args, thread details
    进程正常运行时间、CPU、内存使用情况、用户/组、命令行参数、线程详细信息
  • Physical and virtual memory used/available
    已使用/可用的物理内存和虚拟内存
  • Mounted filesystems (type, usable and total space, options, reads and writes)
    挂载的文件系统(类型、可用和总空间、选项、读取和写入)
  • Disk drives (model, serial, size, reads and writes) and partitions
    磁盘驱动器(型号、序列号、大小、读取和写入)和分区
  • Network interfaces (IPs, bandwidth in/out), network parameters, TCP/UDP statistics
    网络接口(IP、带宽输入/输出)、网络参数、TCP/UDP 统计信息
  • Battery state (% capacity, time remaining, power usage stats)
    电池状态(% 容量、剩余时间、电源使用统计数据)
  • USB Devices USB 设备
  • Connected displays (with EDID info), graphics and audio cards
    连接的显示器(带有 EDID 信息)、图形卡和音频卡
  • Sensors (temperature, fan speeds, voltage) on some hardware
    某些硬件上的传感器(温度、风扇速度、电压)

Support 支持

  • For bug reports, feature requests, or general questions about OSHI’s longer term plans, please create an issue.
    有关错误报告、功能请求或有关 OSHI 长期计划的一般问题,请创建一个问题。
  • 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.
    如需帮助将 OSHI 集成到您自己的项目中或维护者代码审查您的 PR,请在项目站点的议题或拉取请求中标记@dbwiddis
  • For “how to” questions regarding the use of the API, consult examples in the oshi-demo project, create an issue, or search on Stack Overflow using the oshi tag, asking a new question if it hasn’t been answered before.
    有关使用 API 的 “操作方法” 问题,请查阅 oshi-demo 项目中的示例,创建问题,或使用 oshi 标签在 Stack Overflow 上搜索,如果之前没有回答过,请提出新问题。
  • To say thanks to OSHI’s primary maintainer, you can sponsor him or buy him a coffee.
    要感谢 OSHI 的主要维护者,您可以赞助他或请他喝杯咖啡。

OSHI for Enterprise OSHI 企业版

](https://tidelift.com/subscription/pkg/maven-com-github-oshi-oshi-core?utm_source=maven-com-github-oshi-oshi-core&utm_medium=referral&utm_campaign=readme)的一部分提供

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.
OSHI 和数千个其他软件包的维护者正在与 Tidelift 合作,为您用于构建应用程序的开源依赖项提供商业支持和维护。节省时间、降低风险并改善代码运行状况,同时向您使用的确切依赖项的维护者支付费用。了解更多信息。

Security Contact Information 安全联系信息

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
要报告安全漏洞,请使用 Tidelift 安全联系人。Tidelift 将协调修复和披露。

Continuous Integration Test Status 持续集成测试状态

](https://codecov.io/github/oshi/oshi)

How Can I Help? 我能帮忙吗?

OSHI originated as a platform-independent library that did not require additional software and had a license compatible with both open source and commercial products. We have developed a strong core of features on major Operating Systems, but we would love for you to help by:
OSHI 最初是一个独立于平台的库,不需要额外的软件,并且具有与开源和商业产品兼容的许可证。我们已经在主要操作系统上开发了强大的核心功能,但我们希望能通过以下方式提供帮助:

  • Testing! Our CI testing is limited to a few platforms. Download and test the program on various operating systems/versions and hardware and help identify gaps that our limited development and testing may have missed. Specific high priority testing needs include:

    测试! 我们的 CI 测试仅限于少数平台。 下载并在各种操作系统/版本和硬件上测试该程序,并帮助确定我们有限的开发和测试可能遗漏的差距。具体的高优先级检测需求包括:

    • Windows systems with over 64 logical processors
      具有超过 64 个逻辑处理器的 Windows 系统
    • Raspberry Pi 树莓派
    • Less common Linux distributions
      不太常见的 Linux 发行版
  • Contributing code. See something that’s not working right or could work better? Help us fix it! New contributors are welcome.
    贡献代码。看到某些内容无法正常工作或可以更好地工作?帮助我们修复它!欢迎新的贡献者。

  • Documenting implementation. Our Wiki is sparse and the oshi-demo artifact is a place to host proof-of-concept ideas. Want to help new users follow in your footsteps?
    记录实施。我们的 Wiki 很少,而 oshi-demo 工件是托管概念验证想法的地方。想帮助新用户追随您的脚步吗?

  • Suggesting new features. Do you need OSHI to do something it doesn’t currently do? Let us know.
    建议新功能。您是否需要 OSHI 来做一些目前没有做的事情?请告诉我们。

Contributing to OSHI 为 OSHI 做出贡献

  • How to Contribute 如何贡献
  • How to Release 如何发布

Acknowledgments 确认

Many thanks to the following companies for providing free support of Open Source projects including OSHI:
非常感谢以下公司为包括 OSHI 在内的开源项目提供免费支持:

  • SonarCloud for a range of code quality tools
    SonarCloud 提供一系列代码质量工具
  • GitHub Actions, AppVeyor, and Cirrus CI for continuous integration testing
    用于持续集成测试的 GitHub Actions、AppVeyor 和 Cirrus CI
  • The jProfile Java Profiler used to eliminate CPU bottlenecks
    用于消除 CPU 瓶颈的 jProfile Java Profiler

License 许可证

This project is licensed under the MIT License.
本项目根据 MIT 许可证获得许可。

也许您对下面的内容还感兴趣: