pinger v1.1.0

Microlibrary to perform ping requests with Crystal Lang
  • v1.1.0 - July 14, 2020
  • v1.0.1 - February 4, 2020
  • v1.0.0 - June 17, 2019

pinger

Build Status Crystal Version

Microlib to generate ICMP ping requests.
Avoids sudo requirement of using raw sockets by shelling out to ping and thus pinger has an implicit dependency of ping.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      pinger:
        github: spider-gazelle/pinger
    
  2. Run shards install

Usage

require "pinger"

hostname = "www.duckduckgo.com"
pinger = Pinger.new(hostname, count: 3)

pinger.ping # => true / false
puts {
    host: pinger.ip,
    pingable: pinger.pingable,
    warning: pinger.warning,
    exception: pinger.exception
}

Or if you would like an error raised


require "pinger"

hostname = "www.doesnotexist.com"
pinger = Pinger.new(hostname, count: 3)

pinger.ping! # => self / raise pinger.exception

Todo

  • utilise Crystal::Config.default_target rather than shelling out to uname

Contributing

  1. Fork it
  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

Owner
github statistic
  • 5
  • 3
  • 0
  • 0
  • 3 months ago
  • May 2, 2019
License

MIT License

Links
Synced at

Mon, 19 Oct 2020 08:41:55 GMT