pingr v2.0.0

0

Monthly downloads

0th

Percentile

Check if a Remote Computer is Up

Check if a remote computer is up. It can either just call the system ping command, or check a specified TCP port.

Readme

pingr: check if a server is alive

Linux Build
Status Windows Build
status CRAN RStudio mirror
downloads

The pingr package has tools to check if a remote computer or web server is up and some other related tools.

ICMP ping

The ping() function does ICMP ping, via the system’s ping utility:

library(pingr)
ping("127.0.0.1")
#> [1] 0.046 0.058 0.053

By default it sends three packets and measures the time it receives and answer. It waits between sending out the packets, so if you want a really quick check, you can just send a single packet:

ping("127.0.0.1", count = 1)
#> [1] 0.067

If a machine is down (or it does not exist), then NA is returned instead of the roundtrip time:

ping("192.0.2.1", count = 1)
#> [1] NA

TCP ping

With TCP ping we can check if a machine is listeing on a TCP port, e.g. if google’s search web server is up and running:

ping_port("www.google.com", port = 80, count = 1)
#> [1] 12.676

Query the public IP address of the computer

my_ip() queries the public IP of the computer, either via DNS or HTTPS:

my_ip()
#> [1] "81.133.85.232"

Check if the computer is online

is_online() checks if the computer is online. It makes three tries:

  • Queries myip.opendns.com on OpenDNS, see my_ip().
  • Retrieves icanhazip.com via HTTPS, see my_ip().
  • Retrieve Apple’s Captive Portal test page, see apple_captive_test().

If any of these are successful, it returns TRUE.

is_online()
#> [1] TRUE

DNS queries

The package also contains a function to perform DNS queries. This is a more portable and more functional version of the utils::nsl() function:

nsl("www.r-project.org", type = 1L)
#> $answer
#>                 name class type ttl               data
#> 1  www.r-project.org     1    5 900 cran.wu-wien.ac.at
#> 2 cran.wu-wien.ac.at     1    1 300      137.208.57.37
#> 
#> $flags
#>    aa    tc    rd    ra    ad    cd 
#> FALSE FALSE  TRUE  TRUE FALSE FALSE
nsl("google.com", type = 28L)
#> $answer
#>         name class type ttl                     data
#> 1 google.com     1   28 110 2a00:1450:4009:81a::200e
#> 
#> $flags
#>    aa    tc    rd    ra    ad    cd 
#> FALSE FALSE  TRUE  TRUE FALSE FALSE

License

MIT © RStudio

Functions in pingr

Name Description
nsl DNS query
my_ip Query the computer's public IP address
ping Ping a remote server, to see if it is alive
pingr-package Check if the local or remote computer is up
ping_port Check if a port of a server is active, measure response time
apple_captive_test Download Apple's captive portal test
is_online Is the computer online?
No Results!

Last month downloads

Details

License MIT + file LICENSE
LazyData true
URL https://github.com/r-lib/pingr#readme
BugReports https://github.com/r-lib/pingr/issues
RoxygenNote 6.1.99.9001
Encoding UTF-8
NeedsCompilation yes
Packaged 2019-10-21 14:15:34 UTC; gaborcsardi
Repository CRAN
Date/Publication 2019-10-21 16:20:02 UTC
suggests covr , testthat
imports processx , utils
Contributors

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/pingr)](http://www.rdocumentation.org/packages/pingr)