PATH:
opt
/
alt
/
ruby18
/
lib64
/
ruby
/
1.8
# # = ping.rb: Check a host for upness # # Author:: Yukihiro Matsumoto # Documentation:: Konrad Meyer # # Performs the function of the basic network testing tool, ping. # See: Ping. # require 'timeout' require "socket" # # Ping contains routines to test for the reachability of remote hosts. # Currently the only routine implemented is pingecho(). # # Ping.pingecho uses a TCP echo (not an ICMP echo) to determine if the # remote host is reachable. This is usually adequate to tell that a remote # host is available to telnet, ftp, or ssh to. # # Warning: Ping.pingecho may block for a long time if DNS resolution is # slow. Requiring 'resolv-replace' allows non-blocking name resolution. # # Usage: # # require 'ping' # # puts "'jimmy' is alive and kicking" if Ping.pingecho('jimmy', 10) # module Ping # # Return true if we can open a connection to the hostname or IP address # +host+ on port +service+ (which defaults to the "echo" port) waiting up # to +timeout+ seconds. # # Example: # # require 'ping' # # Ping.pingecho "google.com", 10, 80 # def pingecho(host, timeout=5, service="echo") begin timeout(timeout) do s = TCPSocket.new(host, service) s.close end rescue Errno::ECONNREFUSED return true rescue Timeout::Error, StandardError return false end return true end module_function :pingecho end if $0 == __FILE__ host = ARGV[0] host ||= "localhost" printf("%s alive? - %s\n", host, Ping::pingecho(host, 5)) end
[+]
rinda
[+]
yaml
[-] rational.rb
[edit]
[-] matrix.rb
[edit]
[+]
rdoc
[-] shell.rb
[edit]
[-] ostruct.rb
[edit]
[-] eregex.rb
[edit]
[-] scanf.rb
[edit]
[+]
dl
[-] ftools.rb
[edit]
[+]
runit
[-] gserver.rb
[edit]
[-] getoptlong.rb
[edit]
[-] thread.rb
[edit]
[-] sync.rb
[edit]
[-] delegate.rb
[edit]
[-] open-uri.rb
[edit]
[-] openssl.rb
[edit]
[-] debug.rb
[edit]
[+]
irb
[-] ping.rb
[edit]
[-] digest.rb
[edit]
[-] Env.rb
[edit]
[-] yaml.rb
[edit]
[-] sha1.rb
[edit]
[-] forwardable.rb
[edit]
[-] weakref.rb
[edit]
[-] benchmark.rb
[edit]
[-] profiler.rb
[edit]
[-] uri.rb
[edit]
[-] English.rb
[edit]
[-] jcode.rb
[edit]
[-] timeout.rb
[edit]
[+]
xsd
[+]
bigdecimal
[-] tracer.rb
[edit]
[-] resolv.rb
[edit]
[+]
uri
[-] tsort.rb
[edit]
[-] find.rb
[edit]
[-] logger.rb
[edit]
[-] parsedate.rb
[edit]
[-] importenv.rb
[edit]
[-] profile.rb
[edit]
[-] optparse.rb
[edit]
[-] md5.rb
[edit]
[-] getopts.rb
[edit]
[-] pp.rb
[edit]
[+]
test
[-] date.rb
[edit]
[+]
drb
[+]
io
[+]
webrick
[-] cgi.rb
[edit]
[-] pathname.rb
[edit]
[+]
xmlrpc
[-] mutex_m.rb
[edit]
[+]
rss
[+]
wsdl
[+]
racc
[-] complex.rb
[edit]
[+]
..
[-] prettyprint.rb
[edit]
[-] csv.rb
[edit]
[-] kconv.rb
[edit]
[-] securerandom.rb
[edit]
[-] abbrev.rb
[edit]
[-] resolv-replace.rb
[edit]
[+]
digest
[-] mathn.rb
[edit]
[+]
rexml
[+]
soap
[-] mailread.rb
[edit]
[-] e2mmap.rb
[edit]
[-] shellwords.rb
[edit]
[-] rss.rb
[edit]
[-] time.rb
[edit]
[+]
openssl
[+]
date
[-] finalize.rb
[edit]
[-] readbytes.rb
[edit]
[-] fileutils.rb
[edit]
[-] generator.rb
[edit]
[+]
net
[-] monitor.rb
[edit]
[-] tempfile.rb
[edit]
[-] parsearg.rb
[edit]
[-] cgi-lib.rb
[edit]
[-] un.rb
[edit]
[-] mkmf.rb
[edit]
[-] base64.rb
[edit]
[-] thwait.rb
[edit]
[-] webrick.rb
[edit]
[-] erb.rb
[edit]
[-] rubyunit.rb
[edit]
[+]
shell
[-] expect.rb
[edit]
[-] open3.rb
[edit]
[+]
cgi
[-] tmpdir.rb
[edit]
[-] ipaddr.rb
[edit]
[-] pstore.rb
[edit]
[-] singleton.rb
[edit]
[-] set.rb
[edit]
[-] observer.rb
[edit]
[-] drb.rb
[edit]
[-] irb.rb
[edit]
[+]
x86_64-linux
[-] date2.rb
[edit]
[+]
optparse