Monitoring web application behaviour with cucumber-nagios
-
Upload
lindsay-holmwood -
Category
Technology
-
view
9.738 -
download
0
description
Transcript of Monitoring web application behaviour with cucumber-nagios
Monitoring web applicationbehaviour with
cucumber-nagiosLindsay Holmwood <[email protected]>
http://flickr.com/photos/therefromhere/510612621/
Feature: google.com.au It should be up And I should be able to search for things
Scenario: Searching for things When I visit "http://www.google.com" And I fill in "q" with "wikipedia" And I press "Google Search" Then I should see "www.wikipedia.org"
# features/google.com.au/search.feature
--format pretty
$ bin/cucumber --require bin/common.rb \ --require features/ \ features/google.com.au/search.feature
--format pretty
Feature: google.com.au It should be up And I should be able to search for things Scenario: Searching for things When I visit "http://www.google.com" And I fill in "q" with "wikipedia" And I press "Google Search" Then I should see "www.wikipedia.org"
1 scenario4 steps passed
$ bin/cucumber --require bin/common.rb \ --require features/ \ features/google.com.au/search.feature
--format pretty
cucumber
cucumberwebrat
cucumberwebratmechanize
cucumberwebratmechanizenagios =>
cucumber-nagios
cucumber-nagios
$ bin/cucumber-nagios features/google.com.au/search.feature
Critical: 0, Warning: 0, 4 okay | passed=4, failed=0, total=4
how it workshttp://flickr.com/photos/sunbeer/931205335/
$ bin/cucumber-nagios \ features/google.com.au/search.feature
$ bin/cucumber --require bin/common.rb \ --require features/ \ --format Nagios::NagiosFormatter \ features/google.com.au/search.feature
$ bin/cucumber-nagios \ features/google.com.au/search.feature
$ bin/cucumber --require bin/common.rb \ --require features/ \ --format Nagios::NagiosFormatter \ features/google.com.au/search.feature
$ bin/cucumber-nagios \ features/google.com.au/search.feature
module Nagios class NagiosFormatter def initialize(*args) @failed = []; @passed = [] end
def step_passed(step, name, params) @passed << step end
def step_failed(step, name, params) @failed << step end
def scenario_executed(scenario) @total = @failed.size + @passed.size message = "" message += "Critical: #{@failed.size}, " message += "Warning: 0, " message += "#{@passed.size} okay" message += " | passed=#{@passed.size))}" message += ", failed=#{@failed.size))}, total=#{@total}"" puts message end endend
#!/bin/sh
dirname=$(dirname $0) feature=$1 $dirname/cucumber --require $dirname/common.rb \ --require features/ \ --format Nagios::NagiosFormatter \ $featureretval=$? if [ "$retval" -eq "1" ]; then exit 2else exit $retval fi
#!/bin/sh
dirname=$(dirname $0) feature=$1 $dirname/cucumber --require $dirname/common.rb \ --require features/ \ --format Nagios::NagiosFormatter \ $featureretval=$? if [ "$retval" -eq "1" ]; then exit 2else exit $retval fi
0 good1 bad2 ugly
http://flickr.com/photos/chrisindarwin/3082606450/
Setting up
$ gem sources -a http://gems.github.com/
# gem install auxesis-cucumber-nagios
$ gem sources -a http://gems.github.com/
# gem install auxesis-cucumber-nagios
$ cucumber-nagios-gen project mysite.com
$ gem sources -a http://gems.github.com/
# gem install auxesis-cucumber-nagios
$ cucumber-nagios-gen project mysite.com
woosh!
$ gem sources -a http://gems.github.com/
# gem install auxesis-cucumber-nagios
$ cucumber-nagios-gen project mysite.com
$ cd mysite.com
woosh!
$ gem sources -a http://gems.github.com/
# gem install auxesis-cucumber-nagios
$ cucumber-nagios-gen project mysite.com
$ cd mysite.com
$ rake deps
woosh!
$ gem sources -a http://gems.github.com/
# gem install auxesis-cucumber-nagios
$ cucumber-nagios-gen project mysite.com
$ cd mysite.com
$ rake deps
brr!
woosh!
$ bin/cucumber-nagios-gen feature search
$ bin/cucumber-nagios-gen feature search
$ bin/cucumber-nagios features/search.feature
Quirks
Failure*IS* an option
begin
# foo
rescue
# bar
end
Multiple Scenariosper File
Critical: 1, Warning: 0, 2 okay | passed=2, failed=1, total=3Critical: 1, Warning: 0, 4 okay | passed=4, failed=1, total=5
”
Instead of writing boring monitoring plugins from scratch, you can now do behavior driven ops!
”
Instead of writing boring monitoring plugins from scratch, you can now do behavior driven ops!
Transform from a grumpy, misanthropic sysadmin to a hipster, agile developer instantly.
— Bradley Taylor (http://bit.ly/lWWfE)
”
developers sysadmins
http://flickr.com/photos/jshappell/1313699764/
building bridges
http://flickr.com/photos/douaireg/2313764485/
http://github.com/auxesis/cucumber-nagios
http://dryicons.com/free-icons/preview/coquette-part-3-icons-set/