summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZack Hobson2014-02-04 08:11:18 -0800
committerZack Hobson2014-02-04 08:11:18 -0800
commitf2a4e5543eaa4024d69c271f820d34f29dc0578d (patch)
tree86aa3b793534566befa1e70414cdda3d6a841d07
parentfedd5c7dc23996512e41a9ee4eb37bc88a640f3a (diff)
downloadhcl-f2a4e5543eaa4024d69c271f820d34f29dc0578d.tar.bz2
commands: add status command
-rw-r--r--lib/hcl/app.rb2
-rw-r--r--lib/hcl/commands.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb
index 47a87af..5c98452 100644
--- a/lib/hcl/app.rb
+++ b/lib/hcl/app.rb
@@ -181,7 +181,7 @@ EOM
def read_settings
if File.exists? SETTINGS_FILE
- @settings = YAML.load(File.read(SETTINGS_FILE))
+ @settings = YAML.load(File.read(SETTINGS_FILE)) || {}
else
@settings = {}
end
diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb
index 4156a69..3e68c2b 100644
--- a/lib/hcl/commands.rb
+++ b/lib/hcl/commands.rb
@@ -10,6 +10,16 @@ module HCl
http.config_hash.merge(password:'***').map {|k,v| "#{k}: #{v}" }.join("\n")
end
+ # Show the network status of the Harvest service.
+ def status
+ result = Faraday.new("http://harveststatus.com/") do |f|
+ f.use :harvest, '', ''
+ f.adapter Faraday.default_adapter
+ end.get('status.json').body
+ date = Time.at(result[:last_check_time].to_i)
+ "Harvest is #{result[:status]}, response time: #{result[:last_response_time]}ms. [#{date}]"
+ end
+
def console
Console.new(self)
nil