diff --git a/Gemfile b/Gemfile index 5538447..153be72 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,7 @@ source 'https://rubygems.org' gem 'carrierwave' gem 'devise' +gem 'net-ping' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.4' # Use sqlite3 as the database for Active Record diff --git a/Gemfile.lock b/Gemfile.lock index 12bf38b..51f55de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,6 +96,7 @@ GEM mini_portile2 (2.0.0) minitest (5.8.4) multi_json (1.11.2) + net-ping (2.0.1) nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) orm_adapter (0.5.0) @@ -183,6 +184,7 @@ DEPENDENCIES font-awesome-rails jbuilder (~> 2.0) jquery-rails + net-ping rails (= 4.2.4) sass-rails (~> 5.0) sdoc (~> 0.4.0) diff --git a/app/controllers/node_controller.rb b/app/controllers/node_controller.rb index d870f47..02b4108 100644 --- a/app/controllers/node_controller.rb +++ b/app/controllers/node_controller.rb @@ -1,6 +1,5 @@ class NodeController < ApplicationController - before_action :require_login - + before_action :require_login def index @hosts = Array.new @nodes = Node.all.order("id asc") diff --git a/app/helpers/node_helper.rb b/app/helpers/node_helper.rb index ff049b0..a0b203f 100644 --- a/app/helpers/node_helper.rb +++ b/app/helpers/node_helper.rb @@ -1,2 +1,7 @@ module NodeHelper + require 'net/ping' + def ping_test?(host) + check = Net::Ping::External.new(host) + check.ping? + end end diff --git a/app/views/node/index.html.erb b/app/views/node/index.html.erb index 44cadcd..d1a3904 100644 --- a/app/views/node/index.html.erb +++ b/app/views/node/index.html.erb @@ -9,7 +9,7 @@
# | +Ping | +Status | Host Name | Host IP | User Name | Date | - -+ | |||
---|---|---|---|---|---|---|---|---|---|---|
<%=t.id%> | -<%=t.host_name%> | + <%if ping_test?(t.host_ip)%> ++ | Prove | + <%else%> ++ | - | + <%end%> +<%=t.host_name%> | <%=t.host_ip%> | <%=t.user_name%> | <%=t.created_at%> | -
# | -First Name | -Last Name | -Username | -
---|---|---|---|
1 | -Mark | -Otto | -@mdo | -
2 | -Jacob | -Thornton | -@fat | -
3 | -Larry | -the Bird | -
Collapsible Item 2 data -
- Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, -