serverspec and sensu - testing and monitoring collide
DESCRIPTION
Lightning talk from Sydney DevOps MeetupTRANSCRIPT
+
MICHAEL RICHARDSON - @M_RICHO
Testing and Monitoring Collide
WHAT IS IT?
RSpec Tests for checking your servers are configured correctly
CM/PROVISIONING TOOL AGNOSTIC
CM/PROVISIONING TOOL AGNOSTIC
SERVERS CAN BE BUILT USING• CHEF• PUPPET• CF-ENGINE• ANSIBLE
• SALT STACK• SHELL SCRIPTS• MANUAL HACK• WHAT EVER.
26 RESOURE TYPES INCLUDING• COMMAND• CRON• DEFAULT_GATEWAY• FILE• GROUP• HOST• INTERFACE
• IPTABLES• KERNEL_MODULE• PACKAGE• PORT• PROCESS• SERVICE• USER
That’s super fast
WHEN TO RUN SERVERSPEC TESTS?
??
WHEN TO RUN SERVERSPEC TESTS?
That’s super useful
• When developing or updating config management code (eg puppet/chef)
• When validating a node or environment
WHEN TO RUN SERVERSPEC TESTS?
Hell yeah. That’s a great idea.
• What about every 2 minutes on all hosts orchestrated via your monitoring tool
WHEN TO RUN SERVERSPEC TESTS?
Hell yeah. That’s a great idea.
• What about every 2 minutes on all hosts orchestrated via your monitoring tool
Why?• Fast• Lightweight• Overlaps with traditional
monitoring checks. (Eg. Is the apache service running)
• Simplifies monitoring tool config
WE USE SENSU FOR MONITORING
It’s • Simple• Extensible• Lightweight• Simple to install on linux and windows.
ITERATION 1+GET SENSU TO JUST RUN THE RSPEC TESTS
ITERATION 1+
RSpec stdout isn’t great to simply pass back to a monitoring tool.
ITERATION 1+SURE, WE CAN TIDY UP RSPEC STD OUT
But now have no idea which tests are failing
2 USEFUL FEATURES TO THE RESCUE
1. Rspec has a JSON format option
2. Sensu-Client has a local socket to accept ‘arbitrary’ check results
RSPEC JSON OUTPUT
4 exampletests
Summary results
SENSU CLIENT SOCKET
Send results here
Failures appear here
ITERATION 2+
ITERATION 2+RSpec in json format
Send each test result to sensu socket
Report summary serverspec results to back to sensu defined check
Iterate over results
ITERATION 2+
Summary results Individual test failures
SUMMARY
1. Write comprehensive tests2. Don’t duplicate effort by writing the same thing
again as a monitoring check.3. Simply run your tests via a monitoring tool
THANK YOU
Michael Richardson - @m_richohttps://github.com/m-richo/sensu_check-rspec