Monitoring web application behaviour with cucumber-nagios

  • 5,940 views
Uploaded on

Setting up monitoring for web applications can be complicated - tests tend to lack expressiveness, or and quite often they don't even test the right problem in the first place. …

Setting up monitoring for web applications can be complicated - tests tend to lack expressiveness, or and quite often they don't even test the right problem in the first place.

cucumber-nagios lets a sysadmin write behavioural tests for their web apps in plain English, and outputs the test results in the Nagios plugin format, allowing a sysadmin to be notified by Nagios when their production apps aren't behaving.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
5,940
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
132
Comments
1
Likes
8

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Monitoring web application behaviour with cucumber-nagios Lindsay Holmwood <lindsay@holmwood.id.au>
  • 2. http://flickr.com/photos/therefromhere/510612621/
  • 3. # features/google.com.au/search.feature Feature: google.com.au It should be up And I should be able to search for things Scenario: Searching for things When I visit quot;http://www.google.comquot; And I fill in quot;qquot; with quot;wikipediaquot; And I press quot;Google Searchquot; Then I should see quot;www.wikipedia.orgquot;
  • 4. --format pretty
  • 5. $ bin/cucumber --require bin/common.rb --require features/ features/google.com.au/search.feature --format pretty
  • 6. $ bin/cucumber --require bin/common.rb --require features/ features/google.com.au/search.feature Feature: google.com.au It should be up And I should be able to search for things Scenario: Searching for things When I visit quot;http://www.google.comquot; And I fill in quot;qquot; with quot;wikipediaquot; And I press quot;Google Searchquot; Then I should see quot;www.wikipedia.orgquot; 1 scenario 4 steps passed --format pretty
  • 7. cucumber
  • 8. cucumber webrat
  • 9. cucumber webrat mechanize
  • 10. cucumber webrat mechanize nagios =>
  • 11. cucumber-nagios
  • 12. $ bin/cucumber-nagios features/google.com.au/search.feature Critical: 0, Warning: 0, 4 okay | passed=4, failed=0, total=4 cucumber-nagios
  • 13. how it works http://flickr.com/photos/sunbeer/931205335/
  • 14. $ bin/cucumber-nagios features/google.com.au/search.feature
  • 15. $ 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
  • 16. $ 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
  • 17. 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 = quot;quot; message += quot;Critical: #{@failed.size}, quot; message += quot;Warning: 0, quot; message += quot;#{@passed.size} okayquot; message += quot; | passed=#{@passed.size))}quot; message += quot;, failed=#{@failed.size))}, total=#{@total}quot;quot; puts message end end end
  • 18. #!/bin/sh dirname=$(dirname $0) feature=$1 $dirname/cucumber --require $dirname/common.rb --require features/ --format Nagios::NagiosFormatter $feature retval=$? if [ quot;$retvalquot; -eq quot;1quot; ]; then exit 2 else exit $retval fi
  • 19. #!/bin/sh dirname=$(dirname $0) feature=$1 $dirname/cucumber --require $dirname/common.rb --require features/ --format Nagios::NagiosFormatter $feature retval=$? if [ quot;$retvalquot; -eq quot;1quot; ]; then exit 2 0 good else exit $retval 1 bad fi 2 ugly
  • 20. http://flickr.com/photos/chrisindarwin/3082606450/
  • 21. Setting up
  • 22. $ gem sources -a http://gems.github.com/
  • 23. $ gem sources -a http://gems.github.com/ # gem install auxesis-cucumber-nagios
  • 24. $ gem sources -a http://gems.github.com/ # gem install auxesis-cucumber-nagios $ cucumber-nagios-gen project mysite.com
  • 25. $ gem sources -a http://gems.github.com/ # gem install auxesis-cucumber-nagios $ cucumber-nagios-gen project mysite.com woosh!
  • 26. $ gem sources -a http://gems.github.com/ # gem install auxesis-cucumber-nagios $ cucumber-nagios-gen project mysite.com woosh! $ cd mysite.com
  • 27. $ gem sources -a http://gems.github.com/ # gem install auxesis-cucumber-nagios $ cucumber-nagios-gen project mysite.com woosh! $ cd mysite.com $ rake deps
  • 28. $ gem sources -a http://gems.github.com/ # gem install auxesis-cucumber-nagios $ cucumber-nagios-gen project mysite.com woosh! $ cd mysite.com $ rake deps brr!
  • 29. $ bin/cucumber-nagios-gen feature search
  • 30. $ bin/cucumber-nagios-gen feature search $ bin/cucumber-nagios features/search.feature
  • 31. Quirks
  • 32. Failure *IS* an option
  • 33. begin # foo rescue # bar end
  • 34. Multiple Scenarios per File
  • 35. Critical: 1, Warning: 0, 2 okay | passed=2, failed=1, total=3 Critical: 1, Warning: 0, 4 okay | passed=4, failed=1, total=5
  • 36. Instead of writing boring monitoring plugins from scratch, you can now do behavior driven ops!
  • 37. 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)
  • 38. developers sysadmins http://flickr.com/photos/jshappell/1313699764/
  • 39. building bridges http://flickr.com/photos/douaireg/2313764485/
  • 40. http://github.com/auxesis/ cucumber-nagios http://dryicons.com/free-icons/preview/coquette-part-3-icons-set/