Permalink
Browse files

add nagios and sudo cookbook

  • Loading branch information...
1 parent e663afc commit c371ceb40a9364c811bd29645134eddfa6e9b283 @jsierles committed Aug 22, 2011
Showing with 14,429 additions and 0 deletions.
  1. +31 −0 nagios/attributes/client.rb
  2. +32 −0 nagios/attributes/server.rb
  3. +22 −0 nagios/definitions/nagios_conf.rb
  4. +3 −0 nagios/definitions/nagios_service_template.rb
  5. +65 −0 nagios/files/default/notifiers/bulksms
  6. +60 −0 nagios/files/default/notifiers/campfire
  7. +66 −0 nagios/files/default/notifiers/clickatell
  8. +40 −0 nagios/files/default/notifiers/jabber
  9. +84 −0 nagios/files/default/notifiers/jabber_bot
  10. +19 −0 nagios/files/default/notifiers/send_passive_check
  11. +81 −0 nagios/files/default/notifiers/twilio
  12. +158 −0 nagios/files/default/plugins/check-mysql-slave.pl
  13. +161 −0 nagios/files/default/plugins/check_bl_async.pl
  14. +237 −0 nagios/files/default/plugins/check_cisco.pl
  15. +230 −0 nagios/files/default/plugins/check_cisco_stack.pl
  16. +726 −0 nagios/files/default/plugins/check_cpu.pl
  17. +96 −0 nagios/files/default/plugins/check_exceptions_log_error_rate.rb
  18. +69 −0 nagios/files/default/plugins/check_file_age.rb
  19. +194 −0 nagios/files/default/plugins/check_fortigate_memory.pl
  20. +194 −0 nagios/files/default/plugins/check_fortigate_session.pl
  21. +90 −0 nagios/files/default/plugins/check_highrise.rb
  22. +117 −0 nagios/files/default/plugins/check_http_log_error_rate.rb
  23. +98 −0 nagios/files/default/plugins/check_mem.sh
  24. +86 −0 nagios/files/default/plugins/check_mogilefs_bored_workers.rb
  25. +49 −0 nagios/files/default/plugins/check_mysql_backup_size.sh
  26. +3,181 −0 nagios/files/default/plugins/check_mysql_health
  27. +59 −0 nagios/files/default/plugins/check_mysql_lzop_backup_integrity.sh
  28. +67 −0 nagios/files/default/plugins/check_mysql_readonly.rb
  29. +73 −0 nagios/files/default/plugins/check_mysql_slave_warmer.rb
  30. +4,877 −0 nagios/files/default/plugins/check_openmanage
  31. +23 −0 nagios/files/default/plugins/check_redis.rb
  32. +45 −0 nagios/files/default/plugins/check_resque_queue.rb
  33. +42 −0 nagios/files/default/plugins/check_ruby_version.rb
  34. +125 −0 nagios/files/default/plugins/check_solr.rb
  35. +102 −0 nagios/files/default/plugins/db_queues.rb
  36. +7 −0 nagios/files/default/plugins/dell_check_controller_battery_learn_state.sh
  37. +7 −0 nagios/files/default/plugins/dell_check_controller_battery_next_learn_time.sh
  38. +84 −0 nagios/files/default/plugins/file_queues.rb
  39. +118 −0 nagios/files/default/plugins/ganglia_metrics.rb
  40. +88 −0 nagios/files/default/plugins/haproxy_stats.rb
  41. +26 −0 nagios/files/default/plugins/nagios_helper.rb
  42. +219 −0 nagios/files/default/plugins/pagerduty_nagios.pl
  43. +17 −0 nagios/files/default/plugins/passenger_detect_hung_processes
  44. +26 −0 nagios/files/default/plugins/unicorn_detect_old_processes
  45. +19 −0 nagios/libraries/default.rb
  46. +8 −0 nagios/metadata.rb
  47. +31 −0 nagios/recipes/client.rb
  48. 0 nagios/recipes/default.rb
  49. +168 −0 nagios/recipes/secondary.rb
  50. +236 −0 nagios/recipes/server.rb
  51. +29 −0 nagios/templates/default/apache2.conf.erb
  52. +34 −0 nagios/templates/default/cgi.cfg.erb
  53. +563 −0 nagios/templates/default/commands.cfg.erb
  54. +39 −0 nagios/templates/default/contacts.cfg.erb
  55. +29 −0 nagios/templates/default/hostgroups.cfg.erb
  56. +84 −0 nagios/templates/default/hosts.cfg.erb
  57. +151 −0 nagios/templates/default/nagios.cfg.erb
  58. +54 −0 nagios/templates/default/nginx.conf.erb
  59. +20 −0 nagios/templates/default/nrpe.cfg.erb
  60. +22 −0 nagios/templates/default/pagerduty_nagios.cfg.erb
  61. +7 −0 nagios/templates/default/sec_hostgroups.cfg.erb
  62. +45 −0 nagios/templates/default/sec_hosts.cfg.erb
  63. +54 −0 nagios/templates/default/sec_nginx.conf.erb
  64. +95 −0 nagios/templates/default/sec_service_templates.cfg.erb
  65. +41 −0 nagios/templates/default/sec_services.cfg.erb
  66. +105 −0 nagios/templates/default/service_templates.cfg.erb
  67. +330 −0 nagios/templates/default/services.cfg.erb
  68. +2 −0 nagios/templates/default/sv-nagios-bot-log-run.erb
  69. +4 −0 nagios/templates/default/sv-nagios-bot-run.erb
  70. +2 −0 nagios/templates/default/sv-nagios3-log-run.erb
  71. +4 −0 nagios/templates/default/sv-nagios3-run.erb
  72. 0 nagios/templates/default/templates.cfg.erb
  73. +14 −0 nagios/templates/default/timeperiods.cfg.erb
  74. 0 sudo/attributes/sudoers.rb
  75. +5 −0 sudo/metadata.rb
  76. +14 −0 sudo/recipes/default.rb
  77. +26 −0 sudo/templates/default/sudoers.erb
@@ -0,0 +1,31 @@
+default.nagios[:plugins_dir] = "/u/nagios/plugins"
+
+# load average check: 5, 10 and 15 minute averages
+default.nagios[:checks][:load][:enable] = true
+default.nagios[:checks][:load][:warning] = "15,10,7"
+default.nagios[:checks][:load][:critical] = "30,20,10"
+
+# free memory
+default.nagios[:checks][:free_memory][:enable] = true
+default.nagios[:checks][:free_memory][:warning] = 250
+default.nagios[:checks][:free_memory][:critical] = 150
+
+# free disk space percentage
+default.nagios[:checks][:free_disk][:enable] = true
+default.nagios[:checks][:free_disk][:warning] = "8"
+default.nagios[:checks][:free_disk][:critical] = "5"
+
+# HAProxy
+default.nagios[:checks][:haproxy_queue][:enable] = true
+default.nagios[:checks][:haproxy_queue][:critical] = "10"
+default.nagios[:checks][:haproxy_queue][:warning] = "1"
+
+# HTTP error rates
+default.nagios[:checks][:http_error_rate][:enable] = true
+default.nagios[:checks][:http_error_rate][:critical] = "20"
+default.nagios[:checks][:http_error_rate][:warning] = "15"
+
+# Exceptions error rates
+default.nagios[:checks][:exceptions_log_error_rate][:enable] = true
+default.nagios[:checks][:exceptions_log_error_rate][:critical] = "30"
+default.nagios[:checks][:exceptions_log_error_rate][:warning] = "10"
@@ -0,0 +1,32 @@
+default.nagios[:root] = "/etc/nagios3"
+default.nagios[:webroot] = "/usr/share/nagios3/htdocs"
+default.nagios[:bin_path] = "/usr/sbin/nagios3"
+default.nagios[:config_path] = "/etc/nagios3/nagios.cfg"
+default.nagios[:config_subdir] = "conf.d"
+default.nagios[:notifications_enabled] = 1
+default.nagios[:check_external_commands] = true
+default.nagios[:default_contact_groups] = %w(sysadmin)
+
+# This setting is effectively sets the minimum interval (in seconds) nagios can handle.
+# Other interval settings provided in seconds will calculate their actual from this value, since nagios works in 'time units' rather than allowing definitions everywhere in seconds
+
+default.nagios[:templates][:service] = {}
+
+default.nagios[:interval_length] = 1
+
+default.nagios[:default_host][:check_interval] = 15
+default.nagios[:default_host][:retry_interval] = 15
+default.nagios[:default_host][:notification_interval] = 300
+default.nagios[:default_host][:max_check_attempts] = 1
+
+default.nagios[:default_service][:check_interval] = 60
+default.nagios[:default_service][:retry_interval] = 15
+default.nagios[:default_service][:notification_interval] = 600
+default.nagios[:default_service][:max_check_attempts] = 3
+
+default.nagios[:notifiers_dir] = "/var/lib/nagios3/notifiers"
+
+default.nagios[:bot_path] = "#{nagios[:notifiers_dir]}/jabber_bot"
+
+# http checks
+#default.nagios[:checks][:http][:enable]
@@ -0,0 +1,22 @@
+define :nagios_conf, :variables => {}, :config_subdir => true, :prefix => nil do
+
+ subdir = if params[:config_subdir]
+ "/#{node[:nagios][:config_subdir]}/"
+ else
+ "/"
+ end
+
+ template "#{node[:nagios][:root]}#{subdir}#{params[:name]}.cfg" do
+ owner "nagios"
+ group "nagios"
+ if params[:prefix]
+ source "#{params[:prefix]}_#{params[:name]}.cfg.erb"
+ else
+ source "#{params[:name]}.cfg.erb"
+ end
+ mode 0644
+ variables params[:variables]
+ notifies :restart, resources(:service => "nagios3")
+ backup 0
+ end
+end
@@ -0,0 +1,3 @@
+define :nagios_template, :template_type => "service" do
+ node[:nagios][:templates][params[:template_type]][params[:name]] = params
+end
@@ -0,0 +1,65 @@
+#!/usr/local/bin/ruby
+
+require 'rubygems'
+require 'choice'
+require 'ruby-bulksms'
+
+Choice.options do
+ header ''
+ header 'Specific options:'
+
+ option :number do
+ short '-n'
+ long '--number=NUMBER'
+ desc 'The recipient phone number, e.g. 1312555555 (including country code, no spaces)'
+ end
+
+ option :username do
+ short '-u'
+ long '--username=USERNAME'
+ desc 'BulkSMS username'
+ end
+
+ option :password do
+ short '-p'
+ long '--password=PASSWORD'
+ desc 'BulkSMS password'
+ end
+
+ option :message do
+ short '-m'
+ long '--message=MESSAGE'
+ desc 'Message to be sent'
+ end
+
+ option :country do
+ short '-c'
+ long '--country=COUNTRY'
+ desc 'Which country API to use: spain, uk, usa, international, safrica'
+ end
+
+ separator ''
+ separator 'Common options: '
+
+ option :help do
+ long '--help'
+ desc 'Show this message'
+ end
+ end
+
+choices = Choice.choices
+
+service = Service.new(choices[:username], choices[:password], choices[:country])
+
+if choices
+
+ if choices[:message].length > 160
+ messages = choices[:message].scan(/.{1,160}/)
+ else
+ messages = [choices[:message]]
+ end
+
+ messages.each do |message|
+ service.send(message, choices[:number])
+ end
+end
@@ -0,0 +1,60 @@
+#!/usr/bin/env ruby
+#
+# Uses tinder to say things in a campfire room
+#
+#
+
+require 'rubygems'
+require 'tinder'
+require 'choice'
+
+Choice.options do
+ header ''
+ header 'Specific options:'
+
+ option :subdomain do
+ short '-s'
+ long '--subdomain=SUBDOMAIN'
+ desc 'The Campfire subdomain'
+ end
+
+ option :room do
+ short '-r'
+ long '--room=ROOM'
+ desc 'The target Campfire room name'
+ end
+
+ option :message do
+ short '-m'
+ long '--message=MESSAGE'
+ desc 'The desired message'
+ end
+
+ option :ssl do
+ short '-S'
+ long '--ssl'
+ desc 'Use SSL connections'
+ end
+
+ option :token do
+ short '-t'
+ long '-token=TOKEN'
+ desc 'Campfire API token'
+ end
+
+ separator ''
+ separator 'Common options: '
+
+ option :help do
+ long '--help'
+ desc 'Show this message'
+ end
+ end
+
+choices = Choice.choices
+
+if choices[:subdomain] && choices[:room] && choices[:message]
+ campfire = Tinder::Campfire.new(choices[:subdomain], :ssl => choices[:ssl], :token => choices[:token])
+ room = campfire.find_room_by_name choices[:room]
+ room.speak choices[:message]
+end
@@ -0,0 +1,66 @@
+#!/usr/bin/env ruby
+#
+# Uses tinder to say things in a campfire room
+#
+#
+
+require 'rubygems'
+require 'clickatell'
+require 'choice'
+
+Choice.options do
+ header ''
+ header 'Specific options:'
+
+ option :number do
+ short '-n'
+ long '--number=NUMBER'
+ desc 'The recipient phone number, e.g. 1312555555 (including country code, no spaces)'
+ end
+
+ option :username do
+ short '-u'
+ long '--username=USERNAME'
+ desc 'Clickatell API username'
+ end
+
+ option :password do
+ short '-p'
+ long '--password=PASSWORD'
+ desc 'Clickatell API password'
+ end
+
+ option :message do
+ short '-m'
+ long '--message=MESSAGE'
+ desc 'Message to be sent'
+ end
+
+ option :api_id do
+ short '-a'
+ long '--api_id=API_ID'
+ desc 'Clickatell API identifier'
+ end
+
+ separator ''
+ separator 'Common options: '
+
+ option :help do
+ long '--help'
+ desc 'Show this message'
+ end
+ end
+
+choices = Choice.choices
+if choices
+ api = Clickatell::API.authenticate(choices[:api_id], choices[:username], choices[:password])
+ # split message up if it's longer than 153 characters
+ if choices[:message].length > 153
+ message_count = (choices[:message].length.to_f / 153).ceil
+ opts = {:concat => message_count}
+ else
+ opts = {}
+ end
+ puts "OPTIONS #{opts.inspect}"
+ api.send_message(choices[:number], choices[:message], opts)
+end
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+#
+#
+
+require 'rubygems'
+require 'choice'
+require 'drb'
+
+Choice.options do
+ header ''
+ header 'Specific options:'
+
+ option :jid do
+ short '-j'
+ long '--jid=JID'
+ desc 'The user JID'
+ end
+
+ option :message do
+ short '-m'
+ long '--message=MESSAGE'
+ desc 'The desired message'
+ end
+
+ separator ''
+ separator 'Common options: '
+
+ option :help do
+ long '--help'
+ desc 'Show this message'
+ end
+ end
+
+choices = Choice.choices
+
+if choices[:jid] && choices[:message]
+ agent = DRbObject.new(nil, "druby://localhost:10370")
+ agent.deliver choices[:jid], choices[:message]
+end
+
Oops, something went wrong.

0 comments on commit c371ceb

Please sign in to comment.