fuey_client 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c86636e2212bdd9723a32d56b771ff7d1029d6c4
4
- data.tar.gz: cdb1b0f91b2ebdb2fc1853ace704b45dbe970a7e
3
+ metadata.gz: 8d3d138eba9c4a6c4590f5708562f8d62dfadc2f
4
+ data.tar.gz: 7a6da90ed25d9e506f6c3b0f98f319ebf3f5d5d5
5
5
  SHA512:
6
- metadata.gz: 5a44c0e81061779c5405e8f0e9a8e608c1d9835327ae57d0276753553f141a689815e21078b27bb8a03370a3bca1dc11c6956d1a691e7b57e5e88127a4e34216
7
- data.tar.gz: 52c58832d391ff2c1f88da07c862a7b4c8ef30a9925f381905cb9651fc0bada3c26c95f89ce5ed1eab153116adcd22e4be94177824693724c8f5703ec5dc9c34
6
+ metadata.gz: 203299863dba3d56f249f666a3d606bef3f535f5be218f4fe9b26df87bc389b4e92816bcc173d25ece07b4c4a49c165a8a94b0ef70808854f165ee12a5f4b022
7
+ data.tar.gz: 3399464ea1bf57f92642314f38deb598638a0fca6d056808ca3c9a8a318ad154c0e32e662914276087e68bd6f62b80defe9ca36657b9aa15ecc52fdeeec6f706
data/.gitignore CHANGED
@@ -1,4 +1,4 @@
1
- *.gem
1
+ fuey_client*.gem
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
@@ -16,3 +16,4 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ .#*
data/README.md CHANGED
@@ -1,24 +1,29 @@
1
- # FueyClient
1
+ [![Build Status](https://travis-ci.org/b2b2dot0/fuey_client.png?branch=master)](https://travis-ci.org/b2b2dot0/fuey_client)
2
+ [![Code Climate](https://codeclimate.com/repos/5203a52189af7e65a002c4a5/badges/6fe497d679e5e80d0770/gpa.png)](https://codeclimate.com/repos/5203a52189af7e65a002c4a5/feed)
2
3
 
3
- TODO: Write a gem description
4
+ # Fuey::Client
5
+
6
+ Fuey currently supports pinging hosts only. This is great for ensuring your servers are live. You can easily tie this to a cron job that
7
+ runs at an interval or write your own Ruby script to run it continually.
4
8
 
5
9
  ## Installation
6
10
 
7
- Add this line to your application's Gemfile:
11
+ Install the gem:
8
12
 
9
- gem 'fuey_client'
13
+ $ gem install 'fuey_client'
10
14
 
11
- And then execute:
15
+ Copy and modify the example [config file](https://github.com/b2b2dot0/fuey_client/blob/master/config_example/fuey/config.yml).
16
+ Place it where you would like to keep it and note the location. The file needs to be called `config.yml` and it needs to be in a directory called
17
+ `fuey`. So an acceptable location would be, `/etc/fuey/config.yml`.
12
18
 
13
- $ bundle
19
+ ## Usage
14
20
 
15
- Or install it yourself as:
21
+ To run Fuey _(assuming your config file is located at /etc/fuey/config.yml)_:
16
22
 
17
- $ gem install fuey_client
23
+ $ fuey /etc
18
24
 
19
- ## Usage
25
+ Fuey output is logged to the logfile you identified in your `config.yml`.
20
26
 
21
- TODO: Write usage instructions here
22
27
 
23
28
  ## Contributing
24
29
 
@@ -1,11 +1,18 @@
1
1
  ---
2
2
  title: "My app server"
3
3
  logfile: /var/log/fuey.log
4
- inspections:
5
- pings:
6
- -
7
- - 'Google DNS'
8
- - '8.8.8.8'
9
- -
10
- = 'Localhost'
11
- - '0.0.0.0'
4
+ notifications:
5
+ -
6
+ - "run.trace"
7
+ - "Fuey::Log"
8
+ traces:
9
+ two_pings:
10
+ - Ping:
11
+ name: Google
12
+ host: 8.8.8.8
13
+ - SNMPWalk:
14
+ name: "VPNTunnel"
15
+ ip: "98.31.121.10"
16
+ community: "public"
17
+ oid: "1.1.0.2.0.1.9.4.131.9.2.7.7.1"
18
+ version: "v1"
data/fuey_client.gemspec CHANGED
@@ -19,8 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "configurethis", ">= 1.0.4"
22
+ spec.add_dependency "configurethis", ">= 1.0.5"
23
23
  spec.add_dependency "net-ping", "~> 1.6"
24
+ spec.add_dependency "activesupport"
25
+ spec.add_dependency "activemodel"
26
+ # spec.add_dependency "b2b2dot0-sapnwrfc", "~> 0.26" # https://github.com/piersharding/ruby-sapnwrfc
24
27
 
25
28
  spec.add_development_dependency "bundler", "~> 1.3"
26
29
  spec.add_development_dependency "rake"
@@ -1,27 +1,29 @@
1
1
  require "fuey_client/fuey/log"
2
2
  require "fuey_client/fuey/config"
3
+ require "fuey_client/fuey/trace"
3
4
  require "fuey_client/fuey/inspections"
4
5
  require "net/ping"
6
+ require "active_support"
5
7
 
6
8
  module Fuey
7
9
  class Client
8
- def initialize(path_to_config_dir="")
10
+ def initialize(path_to_config_dir="", notifications=nil)
9
11
  Configurethis.root_path = path_to_config_dir
12
+
13
+ notifications = Config.notifications if notifications.nil?
14
+ setup_notifications notifications
10
15
  end
11
16
 
12
17
  def run
13
- Config.inspections.pings.map{|name, host| Inspections::Ping.new(name, host) }.each do |ping|
14
- ping.execute
18
+ Trace.all.each do |trace|
19
+ output = trace.run
20
+ Log.write %([#{trace.name}] #{output})
15
21
  end
22
+ end
16
23
 
17
- 0
18
- rescue => caught
19
- if (caught.message =~ /is not configured/)
20
- Log.write "Nothing configured."
21
- return 0
22
- else
23
- Log.write caught.message
24
- return 1
24
+ def setup_notifications(notifications)
25
+ notifications.each do |name, subscriber|
26
+ ActiveSupport::Notifications.subscribe name, ActiveSupport::Inflector.constantize(subscriber).new
25
27
  end
26
28
  end
27
29
  end
@@ -1 +1,2 @@
1
1
  require "fuey_client/fuey/inspections/ping"
2
+ require "fuey_client/fuey/inspections/snmp_walk"
@@ -1,18 +1,22 @@
1
- require 'net/ping'
1
+ require "net/ping"
2
+ require "active_model"
2
3
 
3
4
  module Fuey
4
5
  module Inspections
5
6
  class Ping
6
- def initialize(name, host)
7
- @host = host
8
- @name = name
9
- end
7
+ include ActiveModel::Model
8
+
9
+ attr_accessor :host, :name
10
10
 
11
11
  def execute
12
12
  result = Net::Ping::External.new(@host).ping
13
13
  Log.write "[#{@name}] Pinging #{@host} #{result ? 'succeeded' : 'failed'}."
14
14
  result
15
15
  end
16
+
17
+ def to_s
18
+ %(Ping #{name} #{host})
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -0,0 +1,35 @@
1
+ require "fuey_client/fuey/inspections/support/shell_command"
2
+ require "active_model"
3
+
4
+ module Fuey
5
+ module Inspections
6
+ class SNMPWalk
7
+ include ActiveModel::Model
8
+
9
+ attr_accessor :name, :ip, :agent, :oid, :version, :community
10
+
11
+ def initialize(args)
12
+ super(args)
13
+ @version ||= "v1"
14
+ @community ||= "public"
15
+ end
16
+
17
+ def execute
18
+ result = Support::ShellCommand.new(snmp_walk_command).execute
19
+ result = result =~ /#{@ip}/
20
+ Log.write %([#{@name}] SNMPWalk for #{@ip} using #{@agent} #{result ? "succeeded" : "failed" }.)
21
+ result
22
+ end
23
+
24
+ def to_s
25
+ snmp_walk_command
26
+ end
27
+
28
+ def snmp_walk_command
29
+ %(snmpwalk -#{@version} -c #{@community} #{@agent} #{@oid})
30
+ end
31
+ private :snmp_walk_command
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,15 @@
1
+ module Fuey
2
+ module Inspections
3
+ module Support
4
+ class ShellCommand
5
+ def initialize(command)
6
+ @command = command
7
+ end
8
+
9
+ def execute
10
+ %x(#{@command})
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -7,6 +7,11 @@ module Fuey
7
7
  logger.info "[#{Config.title}] #{message}"
8
8
  end
9
9
 
10
+ # Handles ActiveSupport::Notifications
11
+ def call(name, started, finished, unique_id, payload)
12
+ Fuey::Log.write %([Event #{name}] Completed in #{finished - started} seconds. #{payload})
13
+ end
14
+
10
15
  def self.logger
11
16
  @@logger ||= Logger.new Config.logfile, 'daily'
12
17
  end
@@ -0,0 +1,50 @@
1
+ require "active_model"
2
+ require "active_support"
3
+
4
+ module Fuey
5
+ class Trace
6
+ include ActiveModel::Model
7
+
8
+ attr_accessor :name, :steps
9
+
10
+ def initialize(args)
11
+ super(args)
12
+ @steps ||= Array.new
13
+ end
14
+
15
+ def self.all
16
+ Config.traces.keys.map do |trace_name|
17
+ trace = Trace.new :name => trace_name
18
+ Config.traces.send(trace_name).each do |step|
19
+ inspection = ActiveSupport::Inflector.constantize %(Fuey::Inspections::#{step.keys.first})
20
+ trace.steps.push inspection.new(step.values.first)
21
+ end
22
+ trace
23
+ end
24
+ end
25
+
26
+ def to_s
27
+ %(#{name}: [#{steps.join(', ')}])
28
+ end
29
+
30
+ def run
31
+ ActiveSupport::Notifications.instrument("run.trace", {:trace => self.to_s}) do
32
+ run, failed, current = 0, 0, ""
33
+ steps.each do |step|
34
+ run += 1
35
+ current = step.name
36
+ if step.execute
37
+ else
38
+ failed += 1
39
+ break
40
+ end
41
+ end
42
+ if failed == 0
43
+ %(#{name} passed. #{steps.size} steps, #{run} executed, #{failed} failed.)
44
+ else
45
+ %(#{name} failed on #{current}. #{steps.size} steps, #{run} executed, #{failed} failed.)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module FueyClient
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fuey::Trace do
4
+ after(:each) { Fuey::Config.reload_configuration }
5
+
6
+ describe "retrieving all configured traces" do
7
+ context "when configured for no traces" do
8
+ Given { Fuey::Config.test_with(no_traces) }
9
+ When (:result) { Fuey::Trace.all }
10
+ Then { expect( result ).to be_empty }
11
+ end
12
+
13
+ context "when configured with one trace" do
14
+ Given { Fuey::Config.test_with(two_pings) }
15
+ When (:result) { Fuey::Trace.all }
16
+ Then { expect( result ).to have(1).items }
17
+ And { expect( result.first ).to be_a(Fuey::Trace) }
18
+ And { expect( result.first ).to have(2).steps }
19
+ And { expect( result.first.steps[0] ).to ping("Google").at("8.8.8.8") }
20
+ And { expect( result.first.steps[1] ).to ping("Self").at("172.0.0.1") }
21
+ end
22
+ end
23
+
24
+ describe "running a trace" do
25
+ context "when the first step fails" do
26
+ Given (:step1) { double(Fuey::Inspections::Ping, :name => "step1", :execute => false) }
27
+ Given (:step2) { double(Fuey::Inspections::Ping) }
28
+ Given { step2.should_not_receive(:execute) }
29
+ When (:result) { Fuey::Trace.new(:name => "trace1", :steps => [step1, step2]).run }
30
+ Then { expect( result ).to eql(%[trace1 failed on step1. 2 steps, 1 executed, 1 failed.]) }
31
+ end
32
+
33
+ context "when all steps pass" do
34
+ Given (:step1) { double(Fuey::Inspections::Ping, :name => "step1", :execute => true) }
35
+ Given (:step2) { double(Fuey::Inspections::Ping, :name => "step2", :execute => true) }
36
+ When (:result) { Fuey::Trace.new(:name => "trace1", :steps => [step1, step2]).run }
37
+ Then { expect( result ).to eql(%[trace1 passed. 2 steps, 2 executed, 0 failed.]) }
38
+ end
39
+ end
40
+
41
+ RSpec::Matchers.define :ping do |name|
42
+ match do |actual|
43
+ (actual.name == name) && (actual.host == @host)
44
+ end
45
+
46
+ chain :at do |host|
47
+ @host = host
48
+ end
49
+
50
+ failure_message_for_should do
51
+ %(should have pinged #{name} at #{@host}, but was #{actual.name} and #{actual.host})
52
+ end
53
+
54
+ failure_message_for_should_not do
55
+ %(should not have pinged #{actual.host})
56
+ end
57
+
58
+ description do
59
+ %(should ping #{name} at #{@host})
60
+ end
61
+ end
62
+
63
+ def two_pings
64
+ {
65
+ "traces" => {
66
+ "two_pings" =>
67
+ [
68
+ {
69
+ "Ping" => {
70
+ "name" => "Google",
71
+ "host" => "8.8.8.8"
72
+ }
73
+ },
74
+ {
75
+ "Ping" => {
76
+ "name" => "Self",
77
+ "host" => "172.0.0.1"
78
+ }
79
+ }
80
+ ]
81
+ }
82
+ }
83
+ end
84
+
85
+ def no_traces
86
+ {
87
+ "traces" => {}
88
+ }
89
+ end
90
+ end
@@ -1,75 +1,21 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Fuey::Client do
4
+ after(:each) { Fuey::Config.reload_configuration }
4
5
 
5
6
  describe "#initialize" do
6
7
  context "passing a configuration path" do
7
8
  Given { Configurethis.should_receive(:root_path=).with('path/to/dir') }
8
- When (:result) { Fuey::Client.new 'path/to/dir' }
9
+ When (:result) { Fuey::Client.new 'path/to/dir', [] }
9
10
  Then { expect( result ).to be_a(Fuey::Client) }
10
11
  end
11
- end
12
-
13
- describe "#run" do
14
- after(:each) { Fuey::Config.reload_configuration }
15
-
16
- context "when nothing is configured" do
17
- Given { Fuey::Log.should_receive(:write).with("Nothing configured.") }
18
- Given { Fuey::Config.test_with(no_inspections) }
19
- When (:result) { Fuey::Client.new.run }
20
- Then { expect( result ).to eql(0) }
21
- end
22
12
 
23
- context "when one ping is configured" do
24
- Given { Fuey::Config.test_with(one_ping) }
25
- Given (:mock_ping) { double Fuey::Inspections::Ping }
26
- Given { mock_ping.should_receive(:execute).and_return true }
27
- Given { Fuey::Inspections::Ping.stub(:new).with("test-server", "0.0.0.1").and_return mock_ping }
28
- When (:result) { Fuey::Client.new.run }
29
- Then { expect( result ).to eql(0) }
13
+ context "passing an array of notification settings" do
14
+ Given { ActiveSupport::Notifications.should_receive(:subscribe).with("ping", an_instance_of(Fuey::Log)) }
15
+ Given { ActiveSupport::Notifications.should_receive(:subscribe).with("snmp", an_instance_of(Fuey::Log)) }
16
+ When (:result) { Fuey::Client.new '', [["ping", "Fuey::Log"], ["snmp","Fuey::Log"]] }
17
+ Then { expect( result ).to be_a(Fuey::Client) }
30
18
  end
31
-
32
- context "when two pings are configured" do
33
- Given { Fuey::Config.test_with(two_pings) }
34
- Given (:mock_ping) { double Fuey::Inspections::Ping }
35
- Given { mock_ping.should_receive(:execute).twice.and_return true }
36
- Given { Fuey::Inspections::Ping.stub(:new).twice.and_return mock_ping }
37
- When (:result) { Fuey::Client.new.run }
38
- Then { expect( result ).to eql(0) }
39
- end
40
-
41
- context "and there is a configuration error" do
42
- Given { Fuey::Log.should_receive(:write).with("crap") }
43
- Given { Fuey::Config.stub(:inspections).and_raise(RuntimeError, "crap") }
44
- When (:result) { Fuey::Client.new.run }
45
- Then { expect( result ).to eql(1) }
46
- end
47
- end
48
-
49
- def no_inspections
50
- {
51
- "inspections" => {}
52
- }
53
19
  end
54
20
 
55
- def one_ping
56
- {
57
- "inspections" => {
58
- "pings" => [
59
- ['test-server', '0.0.0.1']
60
- ]
61
- }
62
- }
63
- end
64
-
65
- def two_pings
66
- {
67
- "inspections" => {
68
- "pings" => [
69
- ['test-server', '0.0.0.1'],
70
- ['vpn-tunnel', '5.5.5.5']
71
- ]
72
- }
73
- }
74
- end
75
21
  end
@@ -1,19 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Fuey::Inspections::Ping do
4
-
5
4
  describe "#execute" do
6
5
  context "when the ping fails" do
7
6
  Given { Fuey::Log.should_receive(:write).with("[some-server] Pinging 172.0.0.1 failed.") }
8
7
  Given { Net::Ping::External.stub(:new).with("172.0.0.1").and_return double("ping", :ping => false) }
9
- When (:result){ Fuey::Inspections::Ping.new('some-server', '172.0.0.1').execute }
8
+ When (:result){ Fuey::Inspections::Ping.new(:name => 'some-server', :host => '172.0.0.1').execute }
10
9
  Then { expect( result ).to eql(false) }
11
10
  end
12
11
 
13
12
  context "when the ping succeeds" do
14
13
  Given { Fuey::Log.should_receive(:write).with("[some-server] Pinging 172.0.0.1 succeeded.") }
15
14
  Given { Net::Ping::External.stub(:new).with("172.0.0.1").and_return double("ping", :ping => true) }
16
- When (:result){ Fuey::Inspections::Ping.new('some-server', '172.0.0.1').execute }
15
+ When (:result){ Fuey::Inspections::Ping.new(:name => 'some-server', :host => '172.0.0.1').execute }
17
16
  Then { expect( result ).to eql(true) }
18
17
  end
19
18
  end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fuey::Inspections::SNMPWalk do
4
+
5
+ describe "#execute" do
6
+ Given (:name) { 'some-tunnel' }
7
+ Given (:oid) { '1.2.9.2.5.3.5.7.111.0.2.0.1.0' }
8
+ Given (:agent) { '172.16.0.100' }
9
+ Given (:walk_result) {
10
+ <<-WALK
11
+ SNMPv2-SMI::enterprises.3.5.7.111.0.2.0.1.16384 = STRING: "121.240.15.226"
12
+ SNMPv2-SMI::enterprises.3.5.7.111.0.2.0.1.20480 = STRING: "121.42.241.30"
13
+ SNMPv2-SMI::enterprises.3.5.7.111.0.2.0.1.28672 = STRING: "121.48.196.13"
14
+ SNMPv2-SMI::enterprises.3.5.7.111.0.2.0.1.32768 = STRING: "192.180.190.25"
15
+ SNMPv2-SMI::enterprises.3.5.7.111.0.2.0.1.36864 = STRING: "81.197.184.129"
16
+ WALK
17
+ }
18
+
19
+ context "when the walk fails" do
20
+ Given (:ip) { '172.0.0.1' }
21
+ Given { Fuey::Log.should_receive(:write).with("[some-tunnel] SNMPWalk for 172.0.0.1 using 172.16.0.100 failed.") }
22
+ Given { Fuey::Inspections::Support::ShellCommand.stub(:new).with("snmpwalk -v1 -c public 172.16.0.100 1.2.9.2.5.3.5.7.111.0.2.0.1.0").and_return double("ShellCommand", :execute => walk_result) }
23
+ When (:result) { Fuey::Inspections::SNMPWalk.new(:name => name, :ip => ip, :agent => agent, :oid => oid).execute }
24
+ Then { expect( result ).to be_false }
25
+ end
26
+
27
+ context "when the walk succeeds" do
28
+ Given (:ip) { '121.48.196.13' }
29
+ Given { Fuey::Log.should_receive(:write).with("[some-tunnel] SNMPWalk for 121.48.196.13 using 172.16.0.100 succeeded.") }
30
+ Given { Fuey::Inspections::Support::ShellCommand.stub(:new).with("snmpwalk -v1 -c public 172.16.0.100 1.2.9.2.5.3.5.7.111.0.2.0.1.0").and_return double("ShellCommand", :execute => walk_result) }
31
+ When (:result) { Fuey::Inspections::SNMPWalk.new(:name => name, :ip => ip, :agent => agent, :oid => oid).execute }
32
+ Then { expect( result ).to be_true }
33
+ end
34
+
35
+ context "when the walk specifies the version and community" do
36
+ Given (:ip) { '81.197.184.129' }
37
+ Given { Fuey::Log.should_receive(:write).with("[some-tunnel] SNMPWalk for 81.197.184.129 using 172.16.0.100 succeeded.") }
38
+ Given { Fuey::Inspections::Support::ShellCommand.stub(:new).with("snmpwalk -v3 -c private 172.16.0.100 1.2.9.2.5.3.5.7.111.0.2.0.1.0").and_return double("ShellCommand", :execute => walk_result) }
39
+ When (:result) { Fuey::Inspections::SNMPWalk.new(:name => name, :ip => ip, :agent => agent, :oid => oid, :version => 'v3', :community => 'private').execute }
40
+ Then { expect( result ).to be_true }
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fuey::Trace do
4
+ after(:each) { Fuey::Config.reload_configuration }
5
+
6
+ describe "retrieving all configured traces" do
7
+ context "when configured for no traces" do
8
+ Given { Fuey::Config.test_with(no_traces) }
9
+ When (:result) { Fuey::Trace.all }
10
+ Then { expect( result ).to be_empty }
11
+ end
12
+
13
+ context "when configured with one trace" do
14
+ Given { Fuey::Config.test_with(two_pings) }
15
+ When (:result) { Fuey::Trace.all }
16
+ Then { expect( result ).to have(1).items }
17
+ And { expect( result.first ).to be_a(Fuey::Trace) }
18
+ And { expect( result.first ).to have(2).steps }
19
+ And { expect( result.first.steps[0] ).to ping("Google").at("8.8.8.8") }
20
+ And { expect( result.first.steps[1] ).to ping("Self").at("172.0.0.1") }
21
+ end
22
+ end
23
+
24
+ describe "running a trace" do
25
+ context "when the first step fails" do
26
+ Given (:step1) { double(Fuey::Inspections::Ping, :name => "step1", :execute => false) }
27
+ Given (:step2) { double(Fuey::Inspections::Ping) }
28
+ Given { step2.should_not_receive(:execute) }
29
+ When (:result) { Fuey::Trace.new(:name => "trace1", :steps => [step1, step2]).run }
30
+ Then { expect( result ).to eql(%[trace1 failed on step1. 2 steps, 1 executed, 1 failed.]) }
31
+ end
32
+
33
+ context "when all steps pass" do
34
+ Given (:step1) { double(Fuey::Inspections::Ping, :name => "step1", :execute => true) }
35
+ Given (:step2) { double(Fuey::Inspections::Ping, :name => "step2", :execute => true) }
36
+ When (:result) { Fuey::Trace.new(:name => "trace1", :steps => [step1, step2]).run }
37
+ Then { expect( result ).to eql(%[trace1 passed. 2 steps, 2 executed, 0 failed.]) }
38
+ end
39
+ end
40
+
41
+ RSpec::Matchers.define :ping do |name|
42
+ match do |actual|
43
+ (actual.name == name) && (actual.host == @host)
44
+ end
45
+
46
+ chain :at do |host|
47
+ @host = host
48
+ end
49
+
50
+ failure_message_for_should do
51
+ %(should have pinged #{name} at #{@host}, but was #{actual.name} and #{actual.host})
52
+ end
53
+
54
+ failure_message_for_should_not do
55
+ %(should not have pinged #{actual.host})
56
+ end
57
+
58
+ description do
59
+ %(should ping #{name} at #{@host})
60
+ end
61
+ end
62
+
63
+ def two_pings
64
+ {
65
+ "traces" => {
66
+ "two_pings" =>
67
+ [
68
+ {
69
+ "Ping" => {
70
+ "name" => "Google",
71
+ "host" => "8.8.8.8"
72
+ }
73
+ },
74
+ {
75
+ "Ping" => {
76
+ "name" => "Self",
77
+ "host" => "172.0.0.1"
78
+ }
79
+ }
80
+ ]
81
+ }
82
+ }
83
+ end
84
+
85
+ def no_traces
86
+ {
87
+ "traces" => {}
88
+ }
89
+ end
90
+ end
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,8 @@
8
8
  require "fuey_client"
9
9
  require "rspec/given"
10
10
 
11
+ Dir["./spec/matchers/**/*.rb"].each { |f| require f }
12
+
11
13
  RSpec.configure do |config|
12
14
  config.treat_symbols_as_metadata_keys_with_true_values = true
13
15
  config.run_all_when_everything_filtered = true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuey_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-09 00:00:00.000000000 Z
11
+ date: 2013-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: configurethis
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.4
19
+ version: 1.0.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.4
26
+ version: 1.0.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-ping
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activemodel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -104,11 +132,18 @@ files:
104
132
  - lib/fuey_client/fuey/config.rb
105
133
  - lib/fuey_client/fuey/inspections.rb
106
134
  - lib/fuey_client/fuey/inspections/ping.rb
135
+ - lib/fuey_client/fuey/inspections/snmp_walk.rb
136
+ - lib/fuey_client/fuey/inspections/support/shell_command.rb
107
137
  - lib/fuey_client/fuey/log.rb
138
+ - lib/fuey_client/fuey/trace.rb
108
139
  - lib/fuey_client/version.rb
140
+ - spec/fuey_client/fuey/#trace_spec.rb#
109
141
  - spec/fuey_client/fuey/client_spec.rb
110
142
  - spec/fuey_client/fuey/inspections/ping_spec.rb
143
+ - spec/fuey_client/fuey/inspections/snmpwalk_spec.rb
144
+ - spec/fuey_client/fuey/trace_spec.rb
111
145
  - spec/spec_helper.rb
146
+ - vendor/gems/b2b2dot0-sapnwrfc-0.26-x86_64-darwin-12.gem
112
147
  homepage: http://github.com/b2b2dot0/fuey_client
113
148
  licenses:
114
149
  - MIT
@@ -136,6 +171,9 @@ specification_version: 4
136
171
  summary: Client for inspecting server state and reports it back to Fuey. Requires
137
172
  the Fuey web app to have any value.
138
173
  test_files:
174
+ - spec/fuey_client/fuey/#trace_spec.rb#
139
175
  - spec/fuey_client/fuey/client_spec.rb
140
176
  - spec/fuey_client/fuey/inspections/ping_spec.rb
177
+ - spec/fuey_client/fuey/inspections/snmpwalk_spec.rb
178
+ - spec/fuey_client/fuey/trace_spec.rb
141
179
  - spec/spec_helper.rb