You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 regels
609 B

  1. # Kitten Info
  2. # Required Modules
  3. require "http/client"
  4. # Network Status
  5. client = HTTP::Client.new("google.com")
  6. # Set Timeouts to 1.5 seconds
  7. client.connect_timeout = 1.5
  8. client.dns_timeout = 1.5
  9. begin
  10. response = client.get("/")
  11. network = "Connected"
  12. rescue Socket::Error
  13. # Disconnect due to DNS error and usually no network access
  14. network = "Disconnected"
  15. rescue IO::Timeout
  16. # Network Timeout
  17. network = "Timeout"
  18. rescue errno
  19. # Disconnect due unreachable host
  20. network = "Disconnected"
  21. end
  22. # Print Information
  23. puts "Internet: " + network
  24. puts "Hostname: " + System.hostname