From dddcfc225c80f2f6f493f289bbfb3cb9b1952c4b Mon Sep 17 00:00:00 2001 From: Dave Shurtleff Date: Wed, 11 Jun 2014 12:48:16 -0400 Subject: [PATCH] Update plugin recipe and template, remove plugin attribute files replaced by mon_setup --- attributes/network.rb | 6 --- attributes/plugin_config_basenode.rb | 64 ---------------------------- recipes/plugin_cfg.rb | 12 ++---- templates/default/plugin_yaml.erb | 8 +++- 4 files changed, 9 insertions(+), 81 deletions(-) delete mode 100644 attributes/network.rb delete mode 100644 attributes/plugin_config_basenode.rb diff --git a/attributes/network.rb b/attributes/network.rb deleted file mode 100644 index 2422a9d..0000000 --- a/attributes/network.rb +++ /dev/null @@ -1,6 +0,0 @@ -default['mon-agent']['network']['instances'] = [ - { - 'collect_connection_state' => 'false', - 'excluded_interfaces' => ['lo', 'lo0'] - } -] diff --git a/attributes/plugin_config_basenode.rb b/attributes/plugin_config_basenode.rb deleted file mode 100644 index 1f29734..0000000 --- a/attributes/plugin_config_basenode.rb +++ /dev/null @@ -1,64 +0,0 @@ -#### agent plugin checks for basenode - -# Host alive check for api server - -node.default[:mon_agent][:plugin][:host_alive][:init_config] = { - :ssh_port => 22, - :ssh_timeout => 0.5, - :ping_timeout => 1 -} - -node.default[:mon_agent][:plugin][:host_alive][:instances][:api_with_ssh] = { - :name => "api_ssh_port", - :host_name => "192.168.10.4", - :alive_test => "ssh" -} - -# Process checks: Everyone should be running ssh/sshd and ntpd - -node.default[:mon_agent][:plugin][:process][:init_config] = { -} - -node.default[:mon_agent][:plugin][:process][:instances][:ssh] = { - :name => "ssh", - :search_string => ["ssh", "sshd"] -} -node.default[:mon_agent][:plugin][:process][:instances][:ntpd] = { - :name => "ntpd", - :search_string => ["/usr/sbin/ntpd"], - :exact_match => "True" -} - -# Service checks: For demo, everyone can check mon api - -node.default[:mon_agent][:plugin][:http_check][:init_config] = { -} - -node.default[:mon_agent][:plugin][:http_check][:instances][:monapi] = { - :name => "mon_api", - :url => "http://192.168.10.4:8080", - :timeout => 10, - :collect_response_time => "true", - :match_pattern => '.*status.*CURRENT.*', -} -node.default[:mon_agent][:plugin][:http_check][:instances][:monapi_health] = { - :name => "mon_api_health", - :url => "http://192.168.10.4:8081/healthcheck", - :timeout => 10, - :include_content => "true", - :collect_response_time => "true", - :match_pattern => '.*"healthy":true.*"healthy":true.*"healthy":true.*', -} - -# mon_nagios_wrapper checks: For demo, everyone can check disk -# -#node.default[:mon_agent][:plugin][:nagios_wrapper][:init_config] = { -# :check_path => "/usr/lib/nagios/plugins:/usr/local/bin/nagios" -#} -# -#node.default[:mon_agent][:plugin][:nagios_wrapper][:instances][:check_disk] = { -# :name => "local_disk" -# :service_name => "disk", -# :check_command => "check_disk -w 15\\% -c 5\\% -A -i /srv/node", -# :check_interval => 300 -#} diff --git a/recipes/plugin_cfg.rb b/recipes/plugin_cfg.rb index 34cdb18..fad33d5 100644 --- a/recipes/plugin_cfg.rb +++ b/recipes/plugin_cfg.rb @@ -15,18 +15,12 @@ package 'nagios-plugins-basic' do only_if { node[:mon_agent][:plugin].has_key?(:nagios_wrapper) } end -# Make sure the datadog conf.d directory exists -directory "/etc/mon-agent/conf.d" do - recursive true - action :create - owner node['mon_agent']['owner'] - group node['mon_agent']['group'] - mode 0755 -end - # Configures the plugin yaml files based on node[:mon_agent][:plugin] # attributes node[:mon_agent][:plugin].each_key do |plugin| + if not node[:mon_agent][:plugin][plugin].has_key?(:init_config): + node[:mon_agent][:plugin][plugin][:init_config] = {} + end template "/etc/mon-agent/conf.d/#{plugin}.yaml" do source "plugin_yaml.erb" action :create diff --git a/templates/default/plugin_yaml.erb b/templates/default/plugin_yaml.erb index 4b705e0..663eb74 100644 --- a/templates/default/plugin_yaml.erb +++ b/templates/default/plugin_yaml.erb @@ -15,14 +15,18 @@ instances: <% inst.sort.each do |key, value| %> <% if new_item %> <% if value.is_a?(Array) %> -<%= " - #{key}: "%> [<%= value.sort.map { |val| %Q/"#{val}"/ }.join(', ') %>] +<%= " - #{key}: "%>[<%= value.sort.map { |val| %Q/"#{val}"/ }.join(', ') %>] + <% elsif value.is_a?(Hash) %> +<%= " - #{key}: "%><%= value.sort.map { |hkey, hval| %Q/#{hkey}:#{hval}/ }.join(', ') %> <% else %> <%= " - #{key}: #{value}" %> <% end %> <% new_item = FALSE %> <% else %> <% if value.is_a?(Array) %> -<%= " #{key}: "%> [<%= value.sort.map { |val| %Q/"#{val}"/ }.join(', ') %>] +<%= " #{key}: "%>[<%= value.sort.map { |val| %Q/"#{val}"/ }.join(', ') %>] + <% elsif value.is_a?(Hash) %> +<%= " #{key}: "%>[<%= value.sort.map { |hkey, hval| %Q/#{hkey}:#{hval}/ }.join(', ') %> <% else %> <%= " #{key}: #{value}" %> <% end %>