Giter VIP home page Giter VIP logo

net-fping's Introduction

Net::Fping

A ruby gem to interface with fping.

Usage

Pretty straight forward:

require 'net/fping'

alive = Net::Fping.alive(["10.0.0.1", "10.0.0.2", "10.0.0.3"])
> ["10.0.0.1", "10.0.0.3"]

alive = Net::Fping.dead(["10.0.0.1", "10.0.0.2", "10.0.0.3"])
> ["10.0.0.2"]

alive = Net::Fping.alive_in_subnet("192.168.0.0/24")
> ["192.168.0.1", "192.168.0.100", "192.168.0.254"]

alive = Net::Fping.alive_in_range("192.168.0.0", "192.168.0.200")
> ["192.168.0.1", "192.168.0.100"]

You can also specify the following options on each command (defaults as per fping shown):

{
  retries: 3,
  count: 1,
  bytes: 56,
  interval: 25,
  timeout: 500
}

So this would be a faster way to ping a 16 bit subnet:

alive = Net::Fping.alive_in_subnet("172.16.0.0/16", retries: 0)

You can also extract latencies:

latencies = Net::Fping.latency("4.2.2.2", 68, 6, 1000)
pp latencies
> [
  0,     # LOSS
  13.7,  # MIN
  15.5,  # AVG
  17.3   # MAX
]

net-fping's People

Contributors

penguinpowernz avatar rlue avatar nckrse avatar

Stargazers

 avatar Ironpillow avatar

Watchers

James Cloos avatar  avatar  avatar

net-fping's Issues

Doesn't work for alive_in_subnet

I am trying a command to ping a subnet

alive = Net::Fping.alive_in_subnet("162.222.72.0/21")

but it is returning the empty set [].

Tidy up latency code

The code submitted in #1 could use a bit of a tidy up:

  1. make some of the args in the latency method have default values
  2. See if latency can use the output from latency_simple
  3. latency seems to parse output from STDERR where latency_simple seems to parse it from STDOUT
  4. Maybe return a hash with named values instead of an array (implementers could still use the hash method to get just hash values in an array)

Not urgent. Just putting this here to remind me (or others) to do it.

Doesn't find file 'fping'

Gem install - is all ok.
require 'net-fping' - true. However if i try some like Net::Fping.latency('8.8.8.8',1,1,20).
irb, pry or Rails enviroment tell me about the following - Errno::ENOENT: No such file or directory - fping.

Incompatible with fping v4.0

Fping 4.0 (released 11 days ago) appears to have changed the output on the -c flag,

$ fping -r 3 -t 500 -i 25 -b 56 -a 8.8.8.8
8.8.8.8
$ fping -c 1 -r 3 -t 500 -i 25 -b 56 -a 8.8.8.8
8.8.8.8 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 21.9/21.9/21.9

which breaks this library:

>> Net::Fping.alive(['8.8.8.8'])
=> []

PR forthcoming.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.