Using Nagios with Chef
-
Upload
bryan-mclellan -
Category
Technology
-
view
6.288 -
download
0
Transcript of Using Nagios with Chef
![Page 1: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/1.jpg)
Configuring Nagios with ChefBryan McLellanTechnical Program Manager, Open [email protected] / @btmspox
![Page 2: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/2.jpg)
Overview
•Who am I?
•Why automation
• Introduction to Chef
•Nagios Demo
•Questions
![Page 3: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/3.jpg)
Who am I?
• ChefEarly developer, user, pundit
• 10+ years in Systems AdministrationComputer repair, ISPs, Corporate IT,Web operations
• Event Logistics VolunteerTraffic Control, Parking, Communications, Networking, Emergency Management
• Hacker-Operator
![Page 4: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/4.jpg)
How did we get here?
Bare Metal Deployment
![Page 5: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/5.jpg)
How did we get here?
Bare Metal Deployment
• Purchasing
![Page 6: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/6.jpg)
How did we get here?
Bare Metal Deployment
• Purchasing
• Vendor build
![Page 7: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/7.jpg)
How did we get here?
Bare Metal Deployment
• Purchasing
• Vendor build
• Delivery
![Page 8: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/8.jpg)
How did we get here?
Bare Metal Deployment
• Purchasing
• Vendor build
• Delivery
• Installation
![Page 9: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/9.jpg)
How did we get here?
Bare Metal Deployment
• Purchasing
• Vendor build
• Delivery
• Installation
• OS deployment
![Page 10: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/10.jpg)
How did we get here?
Bare Metal Deployment
• Purchasing
• Vendor build
• Delivery
• Installation
• OS deployment
• Application deployment
![Page 11: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/11.jpg)
How did we get here?
Bare Metal Deployment
• Purchasing
• Vendor build
• Delivery
• Installation
• OS deployment
• Application deployment
Weeks?
![Page 12: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/12.jpg)
How did we get here?
Cloud or Virtual Deployment
• Purchasing
• Vendor build
• Delivery
• Installation
• OS deployment
• Application deployment
Nearly immediate
![Page 13: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/13.jpg)
How did we get here?
Cloud or Virtual Deployment
• Purchasing
• Vendor build
• Delivery
• Installation
• OS deployment
• Application deployment
Nearly immediate
Must be fast
![Page 14: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/14.jpg)
Why automate?
Good Reasons:
• More agility and faster scalability
• Improved infrastructure documentation
• Better disaster recovery
![Page 15: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/15.jpg)
Why automate?
Good Reasons:
• More agility and faster scalability
• Improved infrastructure documentation
• Better disaster recovery
Really Good Reasons:
• Spend less time on monotonous tasks
• Spend more time solving interesting problems
![Page 16: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/16.jpg)
Why automate?
Operations is responsible for two things:
![Page 17: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/17.jpg)
Why automate?
Operations is responsible for two things:
1. Availability
![Page 18: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/18.jpg)
Why automate?
Operations is responsible for two things:
1. Availability
2. Efficiency
![Page 19: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/19.jpg)
What is Chef?
•Configuration management language
• Systems integration framework
•API for your infrastructure
http://www.flickr.com/photos/morville/3220961040/
![Page 20: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/20.jpg)
Chef Principles
![Page 21: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/21.jpg)
Chef Principles
•Idempotent
![Page 22: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/22.jpg)
Chef Principles
•Idempotent
•Reasonable
![Page 23: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/23.jpg)
Chef Principles
•Idempotent
•Reasonable
•Primitives
![Page 24: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/24.jpg)
Chef Principles
•Idempotent
•Reasonable
•Primitives
•Scalable
![Page 25: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/25.jpg)
Chef Principles
•Idempotent
•Reasonable
•Primitives
•Scalable
•Hackable
![Page 26: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/26.jpg)
Chef Principles
•Idempotent
•Reasonable
•Primitives
•Scalable
•Hackable
•Shareable
![Page 27: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/27.jpg)
Chef Basics
Chef manages Nodes
![Page 28: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/28.jpg)
Chef Basics
Chef manages Nodes Nodes have Attributes
![Page 29: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/29.jpg)
Chef Basics
Chef manages Nodes Nodes have AttributesUsers and Nodes authenticate as Clients
![Page 30: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/30.jpg)
Chef Basics
Chef manages Nodes Nodes have AttributesUsers and Nodes authenticate as ClientsCookbooks contain Recipes
![Page 31: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/31.jpg)
Chef Basics
Chef manages Nodes Nodes have AttributesUsers and Nodes authenticate as ClientsCookbooks contain RecipesEach node has a Run List
![Page 32: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/32.jpg)
Chef Basics
Chef manages Nodes Nodes have AttributesUsers and Nodes authenticate as ClientsCookbooks contain RecipesEach node has a Run ListA Run List is a list of Recipes to run
![Page 33: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/33.jpg)
Chef Basics
Chef manages Nodes Nodes have AttributesUsers and Nodes authenticate as ClientsCookbooks contain RecipesEach node has a Run ListA Run List is a list of Recipes to runA Role also has a Run List
![Page 34: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/34.jpg)
Chef Basics
Chef manages Nodes Nodes have AttributesUsers and Nodes authenticate as ClientsCookbooks contain RecipesEach node has a Run ListA Run List is a list of Recipes to runA Role also has a Run ListRoles can also be added to a Node’s Run List
![Page 35: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/35.jpg)
Chef Basics
Chef manages Nodes Nodes have AttributesUsers and Nodes authenticate as ClientsCookbooks contain RecipesEach node has a Run ListA Run List is a list of Recipes to runA Role also has a Run ListRoles can also be added to a Node’s Run ListNodes can be in Environments
![Page 36: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/36.jpg)
Chef Basics
Chef manages Nodes Nodes have AttributesUsers and Nodes authenticate as ClientsCookbooks contain RecipesEach node has a Run ListA Run List is a list of Recipes to runA Role also has a Run ListRoles can also be added to a Node’s Run ListNodes can be in EnvironmentsData bags are... bags of data.
![Page 37: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/37.jpg)
Chef Basics Visualized
node: srv03run_list: “role[db_server]”
role: web_serverrun_list: [“recipe[apache2]”, “recipe[php]” ]
role: db_serverrun_list: [ “recipe[mysql]”, “recipe[nfs]” ]
node: srv01run_list: “role[web_server]”
node: srv02run_list: “role[web_server]”
client: srv03client: srv01 client: srv02
![Page 38: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/38.jpg)
Application Programming Interface
Give me an API or give me death.-- Andrew Clay Shafer (@littleidea)
The Meatcloud Manifesto
![Page 39: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/39.jpg)
chef-shellknife
Chef Stacks
chef-client
Open Source Hosted Chef Private Chef
API
chef-solo
![Page 40: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/40.jpg)
Chef 10 Open Source Architecture
Chef Expander
![Page 41: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/41.jpg)
Resources
• A Resource is something you manageservice, package, file, user, execute, git
![Page 42: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/42.jpg)
Resources
• A Resource is something you manageservice, package, file, user, execute, git
• Resources have actionsstart, install, create, deploy
• Resources can notify of other resources
![Page 43: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/43.jpg)
Resources
• A Resource is something you manageservice, package, file, user, execute, git
• Resources have actionsstart, install, create, deploy
• Resources can notify of other resources
cookbook_file “/etc/apache2/apache2.conf” do source “apache2.conf” owner “root” group “root” mode 0644 notifies :restart, “service[apache2]”end
![Page 44: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/44.jpg)
Providers
• A Provider performs the actions specified by the resource
![Page 45: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/45.jpg)
Providers
• A Provider performs the actions specified by the resource
• Each Resource can have multiple providerspackage: apt, yum, macports...service: upstart, windows, systemd...
![Page 46: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/46.jpg)
Providers
• A Provider performs the actions specified by the resource
• Each Resource can have multiple providerspackage: apt, yum, macports...service: upstart, windows, systemd...
• Each platform (OS) has default Providers that can be
package “sudo” do provider Chef::Provider::Package::Yum action :installend
![Page 47: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/47.jpg)
A basic recipe
package “apache2” do action :installend
![Page 48: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/48.jpg)
A basic recipe
package “apache2” do action :installend
service “apache2” do action :enableend
![Page 49: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/49.jpg)
A basic recipe
package “apache2” do action :installend
service “apache2” do action :enableend
cookbook_file “/etc/apache2/apache2.conf” do source “apache2.conf” owner “root” group “root” mode 0644end
![Page 50: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/50.jpg)
A basic recipe
package “apache2” do action :installend
service “apache2” do action :enableend
cookbook_file “/etc/apache2/apache2.conf” do source “apache2.conf” owner “root” group “root” mode 0644end
service “apache2” do action :startend
![Page 51: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/51.jpg)
A basic recipe
package “apache2” do action :installend
service “apache2” do action :enable supports [ :restart, :reload, :status ]end
cookbook_file “/etc/apache2/apache2.conf” do source “apache2.conf” owner “root” group “root” mode 0644 notifies :restart, “service[apache2]”end
service “apache2” do action :startend
![Page 52: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/52.jpg)
Search
# Find all nodes in production that are tagged ‘group_d’search(:node, “tags:group_d AND chef_environment:prod”)
# Find the mail server in this environmentsearch (:node, “role:mail_server AND chef_environment:corp”)
# Find all my nodes that run on HP hardwarenodes = search(:node, “dmi_systems_manufacturer:HP”)
# Dynamically create a config in a template<% nodes.each do |node| -%>server <%= node[‘hostname’] %><% end -%>
Search is a first class citizen
Search and Ruby are powerful allies
![Page 53: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/53.jpg)
Nagios Demo•Download nagios server
cookbooks•Install nagios server•Create fake nodes
![Page 54: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/54.jpg)
knife cookbook site install nagiosknife cookbook upload -acd chef-repoknife role from file monitoring.jsonknife data bag create usersknife data bag from file users btm.jsonknife node run list add chef-demo-server role[monitoring]sudo chef-client
http://chef-demo-server/nagios3/
for n in {1..5} ; do knife node from file fake${n}.json ; donesudo chef-client
knife data bag create nagios_hostgroupsknife data bag from file nagios_hostgroups hp_systems.jsonsudo chef-client
![Page 55: Using Nagios with Chef](https://reader034.fdocuments.net/reader034/viewer/2022050613/5550d506b4c905e8318b4f8a/html5/thumbnails/55.jpg)
Questions?
There is lots more to learn about Chef at
http://