Slide 1

Slide 1 text

ߏஙͱઃఆ؅ཧ͕൥ࡶʹͳΓ͕ ͪͳSensuͷ؅ཧΛChefͰ! (ͳΔ΂͘)γϯϓϧʹߦ͏ํ๏ kenjiskywalker Sensu Casual Talks #1! 14/09/17

Slide 2

Slide 2 text

RabbitMQ΍Redisͱ͔! ৭ʑΠϯετʔϧ͠ͳ͍ͱ͍͚ͳ͍...! ! configϑΝΠϧͱ͔ͨ͘͞Μ͋ͬͯ! Ͳ͏΍ͬͯ؅ཧͨ͠Β͍͍ͷ͔Θ͔Βͳ͍... ՝୊!

Slide 3

Slide 3 text

Official Chef cookbookΛ࢖͑͹! (؆୯ʹ)ΠϯετʔϧͰ͖Δ! ղܾ!

Slide 4

Slide 4 text

ݸผʹChef cookbookΛͭ͘Ε͹! ؆୯ʹઃఆϑΝΠϧ΍࣮ߦϑΝΠϧΛ! ؅ཧ͢Δ͜ͱ͕Ͱ͖Δ! ղܾ!

Slide 5

Slide 5 text

! Official Chef cookbookͱ! ࣗՈ੡cookbookΛར༻ͯ͠! Πϯετʔϧͱӡ༻Λ! ͳΔ΂ָ͘ʹ͢Δํ๏Λ͓࿩͠·͢ ࠓճ!

Slide 6

Slide 6 text

Πϯετʔϧฤ

Slide 7

Slide 7 text

supermarket ! ͱ͍͏ΤίγεςϜ͕͋Δ!

Slide 8

Slide 8 text

librarian-chef ͳͲΛར༻ͨ͠ΤίγεςϜ! ґଘؔ܎ͷ͋ΔcookbookΛ! supermarket͔Βμ΢ϯϩʔυͯ͘͠ΕΔ! $ knife cookbook site vendor sensu -o cookbooks/

Slide 9

Slide 9 text

ίϚϯυϥΠϯ! Ұൃୟ͚͹׬ྃͩʂ ! $ sudo chef-solo -c knife.rb -j roles/sensu_server.json

Slide 10

Slide 10 text

[vagrant@vagrant-centos64 chef]$! [vagrant@vagrant-centos64 chef]$ sudo chef-solo -c knife.rb -j roles/sensu_server.json! ! Starting Chef Client, version 11.16.0! [2014-09-12T05:15:44+00:00] WARN: found a directory sensu-chef in the cookbook path, but it contains no cookbook files. skipping.! Compiling Cookbooks...! ! ================================================================================! Recipe Compile Error in /home/vagrant/chef/cookbooks/sensu/recipes/default.rb! ================================================================================! ! Chef::Exceptions::InvalidDataBagPath! ------------------------------------! Data bag path '/home/vagrant/chef/data_bags' is invalid! ! Cookbook Trace:! ---------------! /home/vagrant/chef/cookbooks/sensu/libraries/sensu_helpers.rb:36:in `data_bag_item'! /home/vagrant/chef/cookbooks/sensu/recipes/default.rb:65:in `from_file'! ! Relevant File Content:! ----------------------! /home/vagrant/chef/cookbooks/sensu/libraries/sensu_helpers.rb:! ! 29: "/opt/sensu/embedded/bin/gem"! 30: else! 31: "gem"! 32: end! 33: end! 34:! 35: def data_bag_item(item, missing_ok=false)! 36>> raw_hash = Chef::DataBagItem.load("sensu", item)! 37: encrypted = raw_hash.detect do |key, value|! 38: if value.is_a?(Hash)! 39: value.has_key?("encrypted_data")! 40: end! 41: end! 42: if encrypted! 43: secret = Chef::EncryptedDataBagItem.load_secret! 44: Chef::EncryptedDataBagItem.new(raw_hash, secret)! 45: else! ! ! Running handlers:! [2014-09-12T05:15:44+00:00] ERROR: Running exception handlers! Running handlers complete! [2014-09-12T05:15:44+00:00] ERROR: Exception handlers complete! [2014-09-12T05:15:44+00:00] FATAL: Stacktrace dumped to /tmp/chef-solo/chef-stacktrace.out! Chef Client failed. 0 resources updated in 3.580390451 seconds! [2014-09-12T05:15:44+00:00] ERROR: Data bag path '/home/vagrant/chef/data_bags' is invalid! [2014-09-12T05:15:44+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)! [vagrant@vagrant-centos64 chef]$ Θ͚͕ͳ͍

Slide 11

Slide 11 text

sensu v0.13.0! sensu-chef v2.0.0

Slide 12

Slide 12 text

[vagrant@vagrant-centos64 chef]$! [vagrant@vagrant-centos64 chef]$ sudo chef-solo -c knife.rb -j roles/sensu_server.json! ! Starting Chef Client, version 11.16.0! [2014-09-12T05:15:44+00:00] WARN: found a directory sensu-chef in the cookbook path, but it contains no cookbook files. skipping.! Compiling Cookbooks...! ! ================================================================================! Recipe Compile Error in /home/vagrant/chef/cookbooks/sensu/recipes/default.rb! ================================================================================! ! Chef::Exceptions::InvalidDataBagPath! ------------------------------------! Data bag path '/home/vagrant/chef/data_bags' is invalid! ! Cookbook Trace:! ---------------! /home/vagrant/chef/cookbooks/sensu/libraries/sensu_helpers.rb:36:in `data_bag_item'! /home/vagrant/chef/cookbooks/sensu/recipes/default.rb:65:in `from_file'! ! Relevant File Content:! ----------------------! /home/vagrant/chef/cookbooks/sensu/libraries/sensu_helpers.rb:! ! 29: "/opt/sensu/embedded/bin/gem"! 30: else! 31: "gem"! 32: end! 33: end! 34:! 35: def data_bag_item(item, missing_ok=false)! 36>> raw_hash = Chef::DataBagItem.load("sensu", item)! 37: encrypted = raw_hash.detect do |key, value|! 38: if value.is_a?(Hash)! 39: value.has_key?("encrypted_data")! 40: end! 41: end! 42: if encrypted! 43: secret = Chef::EncryptedDataBagItem.load_secret! 44: Chef::EncryptedDataBagItem.new(raw_hash, secret)! 45: else! ! ! Running handlers:! [2014-09-12T05:15:44+00:00] ERROR: Running exception handlers! Running handlers complete! [2014-09-12T05:15:44+00:00] ERROR: Exception handlers complete! [2014-09-12T05:15:44+00:00] FATAL: Stacktrace dumped to /tmp/chef-solo/chef-stacktrace.out! Chef Client failed. 0 resources updated in 3.580390451 seconds! [2014-09-12T05:15:44+00:00] ERROR: Data bag path '/home/vagrant/chef/data_bags' is invalid! [2014-09-12T05:15:44+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)! [vagrant@vagrant-centos64 chef]$ Chef::DataBagItem.load("sensu", item)! ! !

Slide 13

Slide 13 text

[vagrant@vagrant-centos64 chef]$! [vagrant@vagrant-centos64 chef]$ sudo chef-solo -c knife.rb -j roles/sensu_server.json! ! Starting Chef Client, version 11.16.0! [2014-09-12T05:15:44+00:00] WARN: found a directory sensu-chef in the cookbook path, but it contains no cookbook files. skipping.! Compiling Cookbooks...! ! ================================================================================! Recipe Compile Error in /home/vagrant/chef/cookbooks/sensu/recipes/default.rb! ================================================================================! ! Chef::Exceptions::InvalidDataBagPath! ------------------------------------! Data bag path '/home/vagrant/chef/data_bags' is invalid! ! Cookbook Trace:! ---------------! /home/vagrant/chef/cookbooks/sensu/libraries/sensu_helpers.rb:36:in `data_bag_item'! /home/vagrant/chef/cookbooks/sensu/recipes/default.rb:65:in `from_file'! ! Relevant File Content:! ----------------------! /home/vagrant/chef/cookbooks/sensu/libraries/sensu_helpers.rb:! ! 29: "/opt/sensu/embedded/bin/gem"! 30: else! 31: "gem"! 32: end! 33: end! 34:! 35: def data_bag_item(item, missing_ok=false)! 36>> raw_hash = Chef::DataBagItem.load("sensu", item)! 37: encrypted = raw_hash.detect do |key, value|! 38: if value.is_a?(Hash)! 39: value.has_key?("encrypted_data")! 40: end! 41: end! 42: if encrypted! 43: secret = Chef::EncryptedDataBagItem.load_secret! 44: Chef::EncryptedDataBagItem.new(raw_hash, secret)! 45: else! ! ! Running handlers:! [2014-09-12T05:15:44+00:00] ERROR: Running exception handlers! Running handlers complete! [2014-09-12T05:15:44+00:00] ERROR: Exception handlers complete! [2014-09-12T05:15:44+00:00] FATAL: Stacktrace dumped to /tmp/chef-solo/chef-stacktrace.out! Chef Client failed. 0 resources updated in 3.580390451 seconds! [2014-09-12T05:15:44+00:00] ERROR: Data bag path '/home/vagrant/chef/data_bags' is invalid! [2014-09-12T05:15:44+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)! [vagrant@vagrant-centos64 chef]$ Chef::DataBagItem.load("sensu", item)! ! Data Bagsͷઃఆ͕଍Γͳ͍!

Slide 14

Slide 14 text

Officialͷcookookͷதʹ͋Δ! Data Bags༻ͷSSL࡞੒πʔϧΛར༻͍ͨ͠

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

ignore...

Slide 17

Slide 17 text

ssl.jsonੜ੒܅Λ΋ͬͯ͘Δ! (GitHub্ͷϑΝΠϧ͸rm͞Ε͍ͯͳ͍) $ git clone git@github.com:sensu/sensu-chef.git! $ cd sensu-chef/examples/ssl/! $ ./ssl_certs.sh generate! $ cd -! $ mkdir ./data_bags/sensu! $ cp sensu-chef/examples/ssl/ssl.json data_bags/sensu/!

Slide 18

Slide 18 text

͜ΕͰ͏͘͝͸ͣͩ

Slide 19

Slide 19 text

$ sudo chef-solo -c solo.rb -j roles/sensu_server.json! Starting Chef Client, version 11.16.0! [2014-09-12T02:40:05+00:00] WARN: found a directory sensu-chef in the cookbook path, but it contains no cookbook files. skipping.! Compiling Cookbooks...! ! ================================================================================! Recipe Compile Error in /home/vagrant/chef/cookbooks/sensu/recipes/redis.rb! ================================================================================! ! Chef::Exceptions::ResourceNotFound! ----------------------------------! Cannot find a resource matching service[redis6379] (did you define it first?)! ! Cookbook Trace:! ---------------! /home/vagrant/chef/cookbooks/redisio/recipes/enable.rb:25:in `block in from_file'! /home/vagrant/chef/cookbooks/redisio/recipes/enable.rb:23:in `each'! /home/vagrant/chef/cookbooks/redisio/recipes/enable.rb:23:in `from_file'! /home/vagrant/chef/cookbooks/sensu/recipes/redis.rb:23:in `from_file'! ! Relevant File Content:! ----------------------! /home/vagrant/chef/cookbooks/redisio/recipes/enable.rb:! ! 18: # limitations under the License.! 19: #! 20:! 21: redis = node['redisio']! 22:! 23: redis['servers'].each do |current_server|! 24: server_name = current_server["name"] || current_server["port"]! 25>> resource = resources("service[redis#{server_name}]")! 26: resource.action Array(resource.action)! 27: resource.action << :start! 28: resource.action << :enable! 29: end! 30:! ! ! Running handlers:! [2014-09-12T02:40:05+00:00] ERROR: Running exception handlers! Running handlers complete! [2014-09-12T02:40:05+00:00] ERROR: Exception handlers complete! [2014-09-12T02:40:05+00:00] FATAL: Stacktrace dumped to /tmp/chef-solo/chef-stacktrace.out! Chef Client failed. 0 resources updated in 8.415939823 seconds! [2014-09-12T02:40:05+00:00] ERROR: Cannot find a resource matching service[redis6379] (did you define it first?)! [2014-09-12T02:40:05+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)! $

Slide 20

Slide 20 text

$ sudo chef-solo -c solo.rb -j roles/sensu_server.json! Starting Chef Client, version 11.16.0! [2014-09-12T02:40:05+00:00] WARN: found a directory sensu-chef in the cookbook path, but it contains no cookbook files. skipping.! Compiling Cookbooks...! ! ================================================================================! Recipe Compile Error in /home/vagrant/chef/cookbooks/sensu/recipes/redis.rb! ================================================================================! ! Chef::Exceptions::ResourceNotFound! ----------------------------------! Cannot find a resource matching service[redis6379] (did you define it first?)! ! Cookbook Trace:! ---------------! /home/vagrant/chef/cookbooks/redisio/recipes/enable.rb:25:in `block in from_file'! /home/vagrant/chef/cookbooks/redisio/recipes/enable.rb:23:in `each'! /home/vagrant/chef/cookbooks/redisio/recipes/enable.rb:23:in `from_file'! /home/vagrant/chef/cookbooks/sensu/recipes/redis.rb:23:in `from_file'! ! Relevant File Content:! ----------------------! /home/vagrant/chef/cookbooks/redisio/recipes/enable.rb:! ! 18: # limitations under the License.! 19: #! 20:! 21: redis = node['redisio']! 22:! 23: redis['servers'].each do |current_server|! 24: server_name = current_server["name"] || current_server["port"]! 25>> resource = resources("service[redis#{server_name}]")! 26: resource.action Array(resource.action)! 27: resource.action << :start! 28: resource.action << :enable! 29: end! 30:! ! ! Running handlers:! [2014-09-12T02:40:05+00:00] ERROR: Running exception handlers! Running handlers complete! [2014-09-12T02:40:05+00:00] ERROR: Exception handlers complete! [2014-09-12T02:40:05+00:00] FATAL: Stacktrace dumped to /tmp/chef-solo/chef-stacktrace.out! Chef Client failed. 0 resources updated in 8.415939823 seconds! [2014-09-12T02:40:05+00:00] ERROR: Cannot find a resource matching service[redis6379] (did you define it first?)! [2014-09-12T02:40:05+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)! $ ͳΜ͔ΤϥʔͰͯΔͧ! ! resource = resources("service[redis#{server_name}]")

Slide 21

Slide 21 text

#276, #278

Slide 22

Slide 22 text

ࠓ·Ͱ͸σόοά! ͜Ε͔Βຊ୊

Slide 23

Slide 23 text

Πϯετʔϧʹ͍ͭͯ

Slide 24

Slide 24 text

ࠓճར༻͢ΔJSONϑΝΠϧ! ! - base.json! - sensu_server.json! - sensu_client.json

Slide 25

Slide 25 text

൚༻తͳ! JSONϑΝΠϧ

Slide 26

Slide 26 text

൚༻తͳRole! (base.json) {! "name": "base",! "description": "vagrant base",! "json_class": "Chef::Role",! "override_attributes": {! "sensu": {! "role_subscriptions": [! "all"! ],! "use_embedded_ruby": true! }! },! "default_attributes": {! },! "chef_type": "role",! "run_list": [! ]! }

Slide 27

Slide 27 text

൚༻తͳRole! (base.json) {! "name": "base",! "description": "vagrant base",! "json_class": "Chef::Role",! "override_attributes": {! "sensu": {! "role_subscriptions": [! "all"! ],! "use_embedded_ruby": true! }! },! "default_attributes": {! },! "chef_type": "role",! "run_list": [! ]! } - શαʔόڞ௨! - Sensuͷࠜຊతͳઃఆ! - "all" subscriptions ͷઃఆ

Slide 28

Slide 28 text

൚༻తͳRole! (base.json) Sensu༻ͷRubyΛར༻͍ͨ͠! ! [:sensu][:use_embedded_ruby]! ! /opt/sensu/embedded/bin/ruby! {! "name": "base",! "description": "vagrant base",! "json_class": "Chef::Role",! "override_attributes": {! "sensu": {! "role_subscriptions": [! "all"! ],! "use_embedded_ruby": true! }! },! "default_attributes": {! },! "chef_type": "role",! "run_list": [! ]! } - શαʔόڞ௨! - Sensuͷࠜຊతͳઃఆ! - "all" subscriptions ͷઃఆ

Slide 29

Slide 29 text

Sensu Server! (؂ࢹ͢Δଆ)! ͷΠϯετʔϧ

Slide 30

Slide 30 text

Sensu Server! (sensu_server.json) {! "sensu": {! "rabbitmq": {! "host": "localhost",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_server"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu::client_service]",! "recipe[sensu::server_service]",! "recipe[sensu::redis]",! "recipe[sensu::rabbitmq]",! "recipe[uchiwa]"! ]! }

Slide 31

Slide 31 text

Sensu Server! (sensu_server.json) ! - [:rabbitmq][:password]! ! มߋ͸ඞਢ! {! "sensu": {! "rabbitmq": {! "host": "localhost",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_server"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu::client_service]",! "recipe[sensu::server_service]",! "recipe[sensu::redis]",! "recipe[sensu::rabbitmq]",! "recipe[uchiwa]"! ]! }

Slide 32

Slide 32 text

Sensu Server! (sensu_server.json) ! - [:rabbitmq][:password]! ! มߋ͸ඞਢ! ! - [:rabbitmq][:host]! ! ࣗ෼ࣗ਎(localhost) {! "sensu": {! "rabbitmq": {! "host": "localhost",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_server"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu::client_service]",! "recipe[sensu::server_service]",! "recipe[sensu::redis]",! "recipe[sensu::rabbitmq]",! "recipe[uchiwa]"! ]! }

Slide 33

Slide 33 text

Sensu Server! (sensu_server.json) {! "sensu": {! "rabbitmq": {! "host": "localhost",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_server"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu::client_service]",! "recipe[sensu::server_service]",! "recipe[sensu::redis]",! "recipe[sensu::rabbitmq]",! "recipe[uchiwa]"! ]! } Sensu ServerͷΠϯετʔϧ! recipe[sensu]! recipe[sensu::client_service]! recipe[sensu::server_service]! recipe[sensu::redis]! recipe[sensu::rabbitmq]!

Slide 34

Slide 34 text

Sensu Client! (؂ࢹ͞ΕΔଆ)! ͷΠϯετʔϧ

Slide 35

Slide 35 text

Sensu Client! (sensu_client.json) {! "sensu": {! "rabbitmq": {! "host": "SENSU SERVER",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_client"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu::client_service]"! ]! }

Slide 36

Slide 36 text

Sensu Client! (sensu_client.json) ! - [:rabbitmq][:password]! ! Sensu Serverͷઃఆ! {! "sensu": {! "rabbitmq": {! "host": "SENSU SERVER",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_client"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu::client_service]"! ]! }

Slide 37

Slide 37 text

Sensu Client! (sensu_client.json) ! - [:rabbitmq][:password]! ! Sensu Serverͷઃఆ! ! - [:rabbitmq][:host]! ! Sensu ServerΛࢦఆ! {! "sensu": {! "rabbitmq": {! "host": "SENSU SERVER",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_client"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu::client_service]"! ]! }

Slide 38

Slide 38 text

Sensu Client! (sensu_client.json) {! "sensu": {! "rabbitmq": {! "host": "SENSU SERVER",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_client"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu::client_service]"! ]! } Sensu ClientͷΠϯετʔϧ! recipe[sensu]! recipe[sensu::client_service]

Slide 39

Slide 39 text

ઃఆฤ

Slide 40

Slide 40 text

client.jsonͷઃఆ! (؂ࢹ͞ΕΔଆͷઃఆ)

Slide 41

Slide 41 text

Client༻ͷઃఆ! (client.json)! ! ! ! !

Slide 42

Slide 42 text

Client༻ͷઃఆ! (client.json)! ! ! nodeͷ৘ใ! - name(ࣗ෼ͷ໊લ)! - address(ࣗ෼ͷIPΞυϨε)! - subscriptions(؂ࢹ߲໨)! !

Slide 43

Slide 43 text

ࠓճ࡞੒ͨ͠cookbook!

Slide 44

Slide 44 text

ࠓճ࡞੒ͨ͠cookbook! ! - sensu-client-config (client.json)! - sensu-server-plugin (plugin)! - sensu-client-plugin (plugin)

Slide 45

Slide 45 text

sensu-client-config /etc/sensu/conf.d/client.json! Λ࡞੒͢Δcookbook

Slide 46

Slide 46 text

sensu-client-config

Slide 47

Slide 47 text

sensu-client-config - node[:sensu][:hostname]! - node[:sensu][:ipaddress]! - node[:sensu][:node_subscription]! - node[:sensu][:role_subscription]

Slide 48

Slide 48 text

sensu-client-config - node[:sensu][:hostname]! - node[:sensu][:ipaddress]! - node[:sensu][:node_subscription]! - node[:sensu][:role_subscription] ChefͷtemplateػೳΛར༻͠! /etc/sensu/conf.d/client.json ʹઃఆΛॻ͖ग़͢!

Slide 49

Slide 49 text

sensu-client-config - node[:sensu][:node_subscription]!

Slide 50

Slide 50 text

sensu-client-config - node[:sensu][:node_subscription]! => db_master! => db_slave! => queue_master! => queue_slave

Slide 51

Slide 51 text

sensu-client-config - node[:sensu][:node_subscription]! => db_master! => db_slave! => queue_master! => queue_slave! ! - node[:sensu][:role_subscription]!

Slide 52

Slide 52 text

sensu-client-config - node[:sensu][:node_subscription]! => db_master! => db_slave! => queue_master! => queue_slave! ! - node[:sensu][:role_subscription]! => db! => queue! => all

Slide 53

Slide 53 text

sensu-server-plugin server༻ͷ֤छઃఆϑΝΠϧΛ! ഑ஔ͢Δcookbook! (໋໊͕Α͘ͳ͍)

Slide 54

Slide 54 text

/etc/sensu/conf.d/checks/! ! ! ؂ࢹ༻ͷઃఆϑΝΠϧΛ֨ೲ! ! - check_cpu.json! - check_cpu_iowait.json! - check_disk.json! - check_fluentd_monitor_agent.json! remote_directory "/etc/sensu/conf.d/checks/" do! source "checks"! files_mode 0644! mode 0755! owner "root"! end sensu-server-plugin 1/6

Slide 55

Slide 55 text

sensu-server-plugin 2/6 remote_directory "/etc/sensu/metrics/" do! source "metrics"! files_mode 0755! mode 0755! owner "root"! end /etc/sensu/metrics/! ! ! ϝτϦΫεͷ࣮ߦϑΝΠϧΛ֨ೲ! ! - cpu-metrics.rb! - disk-usage-metrics.rb

Slide 56

Slide 56 text

sensu-server-plugin 3/6 remote_directory "/etc/sensu/conf.d/metrics/" do! source "metrics_config"! files_mode 0644! mode 0755! owner "root"! end /etc/sensu/conf.d/metrics/! ! ! ϝτϦΫεͷઃఆϑΝΠϧΛ֨ೲ! ! - cpu-metrics.json! - disk-usage-metrics.json

Slide 57

Slide 57 text

sensu-server-plugin 4/6 remote_directory "/etc/sensu/handlers/" do! source "handlers"! files_mode 0755! mode 0755! owner "root"! end /etc/sensu/handlers/! ! ! ௨஌पΓͷ࣮ߦϑΝΠϧΛ֨ೲ! ! - hipchat.rb! - mailer.rb

Slide 58

Slide 58 text

sensu-server-plugin 5/6 remote_directory "/etc/sensu/conf.d/handlers/" do! source "handlers_config"! files_mode 0644! mode 0755! owner "root"! end /etc/sensu/conf.d/handlers/! ! ! ௨஌पΓͷઃఆϑΝΠϧΛ֨ೲ! ! - graphite.json! - hipchat.json! - mailer.json

Slide 59

Slide 59 text

sensu-server-plugin 6/6 remote_directory "/etc/sensu/plugins/" do! source "plugins"! files_mode 0755! mode 0755! owner "root"! end! ! gems = ["redis"]! ! gems.each do |gem|! execute "/opt/sensu/embedded/bin/gem install #{gem}" do! command "/opt/sensu/embedded/bin/gem install #{gem}"! cwd "/tmp/"! not_if "/opt/sensu/embedded/bin/gem list | grep -w \"^#{gem}\s\""! end! end /etc/sensu/plugins/! ! ! Serverͷpluginͷ࣮ߦϑΝΠϧΛ֨ೲ! ࣮ߦʹඞཁͳϥΠϒϥϦͷΠϯετʔϧ! ! - check-fluentd-log.rb

Slide 60

Slide 60 text

sensu-client-plugin client༻ͷpluginͷ࣮ߦϑΝΠϧΛ! ഑ஔ͢Δcookbook

Slide 61

Slide 61 text

sensu-client-plugin 1/1 remote_directory "/etc/sensu/plugins/" do! source "plugins"! files_mode 0755! mode 0755! owner "root"! end! ! gems = ["redis"]! ! gems.each do |gem|! execute "/opt/sensu/embedded/bin/gem install #{gem}" do! command "/opt/sensu/embedded/bin/gem install #{gem}"! cwd "/tmp/"! not_if "/opt/sensu/embedded/bin/gem list | grep -w \"^#{gem}\s\""! end! end /etc/sensu/plugins/! ! Clientͷpluginͷ࣮ߦϑΝΠϧΛ֨ೲ! ࣮ߦʹඞཁͳϥΠϒϥϦͷΠϯετʔϧ! ! - check_cpu.rb! - check_cpu_iowait.rb! - check_disk.rb! - check_fluentd_monitor_agent.rb!

Slide 62

Slide 62 text

sensu-server-plugin /etc/sensu/conf.d/checks/! ؂ࢹ༻ͷઃఆϑΝΠϧͷ֨ೲ! /etc/sensu/metrics/! ϝτϦΫε༻ͷ࣮ߦϑΝΠϧͷ֨ೲ! /etc/sensu/conf.d/metrics/! ϝτϦΫε༻ͷઃఆϑΝΠϧͷ֨ೲ! /etc/sensu/handlers/! ௨஌पΓͷ࣮ߦϑΝΠϧΛ֨ೲ! /etc/sensu/conf.d/handlers/! ௨஌पΓͷઃఆϑΝΠϧΛ֨ೲ! /etc/sensu/plugins/! Server༻ͷpluginͷ࣮ߦϑΝΠϧͷ֨ೲ

Slide 63

Slide 63 text

sensu-client-plugin /etc/sensu/plugins/
 Client༻ͷpluginͷ࣮ߦϑΝΠϧͷ֨ೲ

Slide 64

Slide 64 text

͓͞Β͍

Slide 65

Slide 65 text

֤छRoleͷઃఆ

Slide 66

Slide 66 text

൚༻తͳRole! (base.json) {! "name": "base",! "description": "vagrant base",! "json_class": "Chef::Role",! "override_attributes": {! "sensu": {! "role_subscriptions": [! "all"! ],! "use_embedded_ruby": true! }! },! "default_attributes": {! },! "chef_type": "role",! "run_list": [! ]! }

Slide 67

Slide 67 text

൚༻తͳRole! (base.json) [:sensu][:use_embedded_ruby]! omnibus-rubyΛΠϯετʔϧ {! "name": "base",! "description": "vagrant base",! "json_class": "Chef::Role",! "override_attributes": {! "sensu": {! "role_subscriptions": [! "all"! ],! "use_embedded_ruby": true! }! },! "default_attributes": {! },! "chef_type": "role",! "run_list": [! ]! }

Slide 68

Slide 68 text

൚༻తͳRole! (base.json) [:sensu][:use_embedded_ruby]! omnibus-rubyΛΠϯετʔϧ {! "name": "base",! "description": "vagrant base",! "json_class": "Chef::Role",! "override_attributes": {! "sensu": {! "role_subscriptions": [! "all"! ],! "use_embedded_ruby": true! }! },! "default_attributes": {! },! "chef_type": "role",! "run_list": [! ]! } [:sensu][:role_subscriptions]! ൚༻తͳsubscriptionͷઃఆ

Slide 69

Slide 69 text

Sensu Server! (sensu_server.json) {! "sensu": {! "rabbitmq": {! "host": "localhost",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_server"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu-client-config]",! "recipe[sensu-client-plugin]",! "recipe[sensu-server-plugin]",! "recipe[sensu::client_service]",! "recipe[sensu::server_service]",! "recipe[sensu::redis]",! "recipe[sensu::rabbitmq]",! "recipe[uchiwa]"! ]! }

Slide 70

Slide 70 text

Sensu Server! (sensu_server.json) {! "sensu": {! "rabbitmq": {! "host": "localhost",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_server"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu-client-config]",! "recipe[sensu-client-plugin]",! "recipe[sensu-server-plugin]",! "recipe[sensu::client_service]",! "recipe[sensu::server_service]",! "recipe[sensu::redis]",! "recipe[sensu::rabbitmq]",! "recipe[uchiwa]"! ]! } Sensu ServerͷΠϯετʔϧ! recipe[sensu]! recipe[sensu::client_service]! recipe[sensu::server_service]! recipe[sensu::redis]! recipe[sensu::rabbitmq]!

Slide 71

Slide 71 text

Sensu Server! (sensu_server.json) {! "sensu": {! "rabbitmq": {! "host": "localhost",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_server"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu-client-config]",! "recipe[sensu-client-plugin]",! "recipe[sensu-server-plugin]",! "recipe[sensu::client_service]",! "recipe[sensu::server_service]",! "recipe[sensu::redis]",! "recipe[sensu::rabbitmq]",! "recipe[uchiwa]"! ]! } Sensu ServerͷΠϯετʔϧ! recipe[sensu]! recipe[sensu::client_service]! recipe[sensu::server_service]! recipe[sensu::redis]! recipe[sensu::rabbitmq]! pluginपΓͷઃఆͷ഑෍! recipe[sensu-client-plugin]! recipe[sensu-server-plugin]!

Slide 72

Slide 72 text

Sensu Server! (sensu_server.json) {! "sensu": {! "rabbitmq": {! "host": "localhost",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_server"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu-client-config]",! "recipe[sensu-client-plugin]",! "recipe[sensu-server-plugin]",! "recipe[sensu::client_service]",! "recipe[sensu::server_service]",! "recipe[sensu::redis]",! "recipe[sensu::rabbitmq]",! "recipe[uchiwa]"! ]! } Sensu ServerͷΠϯετʔϧ! recipe[sensu]! recipe[sensu::client_service]! recipe[sensu::server_service]! recipe[sensu::redis]! recipe[sensu::rabbitmq]! pluginपΓͷઃఆͷ഑෍! recipe[sensu-client-plugin]! recipe[sensu-server-plugin]! client.jsonͷઃఆ! recipe[sensu-client-config]!

Slide 73

Slide 73 text

Sensu Client! (sensu_client.json) {! "sensu": {! "rabbitmq": {! "host": "SENSU SERVER",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_client"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu-client-config]",! "recipe[sensu-client-plugin]",! "recipe[sensu::client_service]"! ]! }

Slide 74

Slide 74 text

Sensu Client! (sensu_client.json) {! "sensu": {! "rabbitmq": {! "host": "SENSU SERVER",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_client"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu-client-config]",! "recipe[sensu-client-plugin]",! "recipe[sensu::client_service]"! ]! } Sensu ClientͷΠϯετʔϧ! recipe[sensu]! recipe[sensu::client_service]

Slide 75

Slide 75 text

Sensu Client! (sensu_client.json) {! "sensu": {! "rabbitmq": {! "host": "SENSU SERVER",! "port": 5671,! "vhost": "/sensu",! "password": "sensu_rabbitmq_pass"! },! "node_subscriptions": [! "sensu_client"! ]! },! "run_list": [! "role[base]",! "recipe[sensu]",! "recipe[sensu-client-config]",! "recipe[sensu-client-plugin]",! "recipe[sensu::client_service]"! ]! } pluginपΓͷઃఆͷ഑෍! recipe[sensu-client-plugin]! Sensu ClientͷΠϯετʔϧ! recipe[sensu]! recipe[sensu::client_service] client.jsonͷઃఆ! recipe[sensu-client-config]!

Slide 76

Slide 76 text

ಠࣗcookbook

Slide 77

Slide 77 text

- sensu-client-config(client.json)!

Slide 78

Slide 78 text

- sensu-client-config(client.json)! - sensu-server-plugin(plugin)

Slide 79

Slide 79 text

- sensu-client-config(client.json)! - sensu-server-plugin(plugin)! - sensu-client-plugin(plugin)

Slide 80

Slide 80 text

- Chefࣗମͷ໰୊͚ͩͲ1ճcook͕௨Δ·Ͱ͕௕͍! - 1ճ௨Ε͹ޙ͸ख์͠Ͱӡ༻Ͱ͖Δ! - ઃఆϑΝΠϧ΋ಠࣗcookbookͰΑ͠ͳʹͰ͖Δ ·ͱΊ

Slide 81

Slide 81 text

ࢀߟURL! ! sensu! - http://sensuapp.org/! ! sensu chef! - https://github.com/sensu/sensu-chef! ! supermarket! - https://supermarket.getchef.com/cookbooks/sensu! ! example cookbook! - https://github.com/kenjiskywalker/chef ͓ΘΓ