Popularity
8.3
Stable
Activity
0.0
Stable
71
7
10

Programming language: Crystal
License: ISC License
Tags: System    
Latest version: v0.5.2

hardware alternatives and similar shards

Based on the "System" category.
Alternatively, view hardware alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of hardware or a related project?

Add another 'System' Shard

README

hardware

GitHub release Build Status

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

  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