hardware
Version, currently 0.5.39 versions
github.com/crystal-community/hardware
Get CPU, Memory and Network informations of the running OS and its processes
76 stars
13 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
hardware:
github: crystal-community/hardware
version: ~> 0.5.3Then run:
shards installshard.yml
- Crystal
>= 0.35, < 2- License
- MIT
- Authors
- bararchy, Julien Reichardt
Dependencies
This version declares no dependencies.
README
hardware
A basic module to get CPU, memory and network informations of the current running OS and its processes.
Tested on Linux.
Installation
Add this to your application's shard.yml:
dependencies:
hardware:
github: crystal-community/hardware
Documentation
The documentation is accessible at https://crystal-community.github.io/hardware.
It is generated with crystal docs in the gh-pages branch.
Examples
require "hardware"
memory = Hardware::Memory.new
memory.used #=> 2731404
memory.percent.to_i #=> 32
cpu = Hardware::CPU.new
pid_stat = Hardware::PID.new.stat # Default is Process.pid
app_stat = Hardware::PID.new("firefox").stat # Take the first matching PID
loop do
sleep 1
p cpu.usage!.to_i #=> 17
p pid_stat.cpu_usage! #=> 1.5
p app_stat.cpu_usage!.to_i #=> 4
end
Development
Docker
You can run the specs in a Docker container:
$ docker-compose up
$ docker-compose run spec
Contributing
- Fork it ( https://github.com/crystal-community/hardware/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.5.3- Tagged
- Jun 7, 2025
- Commit
2897271a72c1- Crystal
>= 0.35, < 2- Indexed
- yes
Dependents
- ctop
- placeos-core
- placeos-core
- ai4cr2
- tiny-stats
- sandbox
- loudspeaker
- crystal_ray_tracer
- ai4cr
- minion-agent
- the_hub
- akane
and 1 more
Repository
github.com/crystal-community/hardware
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 28, 2026
- Synced
- Sep 28, 2026
- Versions
- 9