Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crystal-community/hardware
Get CPU, Memory and Network informations of the running OS and its processes
https://github.com/crystal-community/hardware
cpu crystal hardware memory network system
Last synced: about 1 month ago
JSON representation
Get CPU, Memory and Network informations of the running OS and its processes
- Host: GitHub
- URL: https://github.com/crystal-community/hardware
- Owner: crystal-community
- License: isc
- Created: 2017-12-03T13:01:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-12-23T02:31:50.000Z (almost 3 years ago)
- Last Synced: 2024-10-25T01:58:37.300Z (about 2 months ago)
- Topics: cpu, crystal, hardware, memory, network, system
- Language: Crystal
- Homepage: https://crystal-community.github.io/hardware
- Size: 84 KB
- Stars: 72
- Watchers: 7
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - hardware - Get CPU, Memory and Network informations of the running OS and its processes (System)
- awesome-crystal - hardware - Get CPU, Memory and Network informations of the running OS and its processes (System)
- awesome-crystal - hardware - Get CPU, Memory and Network informations of the running OS and its processes (System)
README
# hardware
[![GitHub release](https://img.shields.io/github/release/crystal-community/hardware.svg)](https://github.com/crystal-community/hardware/releases)
[![Build Status](https://travis-ci.org/crystal-community/hardware.svg?branch=master)](https://travis-ci.org/crystal-community/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`:
```yaml
dependencies:
hardware:
github: crystal-community/hardware
```## Documentation
The documentation is accessible at https://crystal-community.github.io/hardware.
It is generated with [crystal docs](https://crystal-lang.org/docs/conventions/documenting_code.html) in the `gh-pages` branch.
## Examples
```crystal
require "hardware"memory = Hardware::Memory.new
memory.used #=> 2731404
memory.percent.to_i #=> 32cpu = Hardware::CPU.new
pid_stat = Hardware::PID.new.stat # Default is Process.pid
app_stat = Hardware::PID.new("firefox").stat # Take the first matching PIDloop 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:
```sh
$ docker-compose up
$ docker-compose run spec
```## Contributing
1. Fork it ( https://github.com/crystal-community/hardware/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request## Contributors
- [bararchy](https://github.com/bararchy) - creator, maintainer
- [j8r](https://github.com/j8r) - contributor