Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'COOK-991'

  • Loading branch information...
commit 71f61f2c64acfc432e8755bba1598db84763f655 2 parents 2eb0767 + 3bf6f42
@jtimberman jtimberman authored
View
17 nagios/providers/nrpecheck.rb
@@ -20,18 +20,15 @@
action :add do
Chef::Log.info "Adding #{new_resource.command_name} to #{node['nagios']['nrpe']['conf_dir']}/nrpe.d/"
command = new_resource.command || "#{node['nagios']['plugin_dir']}/#{new_resource.command_name}"
- template "#{node['nagios']['nrpe']['conf_dir']}/nrpe.d/#{new_resource.command_name}.cfg" do
- source "nrpe_command.cfg.erb"
+ file_contents = "command[#{new_resource.command_name}]=#{command}"
+ file_contents += " -w #{new_resource.warning_condition}" unless new_resource.warning_condition.nil?
+ file_contents += " -c #{new_resource.critical_condition}" unless new_resource.critical_condition.nil?
+ file_contents += " #{new_resource.parameters}" unless new_resource.parameters.nil?
+ file "#{node['nagios']['nrpe']['conf_dir']}/nrpe.d/#{new_resource.command_name}.cfg" do
owner "root"
group "root"
mode 0644
- variables(
- :command_name => new_resource.command_name,
- :command => command,
- :warning_condition => new_resource.warning_condition,
- :critical_condition => new_resource.critical_condition,
- :parameters => new_resource.parameters
- )
+ content file_contents
notifies :restart, resources(:service => "nagios-nrpe-server")
end
end
@@ -41,7 +38,7 @@
Chef::Log.info "Removing #{new_resource.command_name} from #{node['nagios']['nrpe']['conf_dir']}/nrpe.d/"
file "#{node['nagios']['nrpe']['conf_dir']}/nrpe.d/#{new_resource.command_name}.cfg" do
action :delete
- notifies :restart, "service[nagios-nrpe-server]"
+ notifies :restart, resources(:service => "nagios-nrpe-server")
end
end
end
View
17 nagios/recipes/client.rb
@@ -65,10 +65,25 @@
supports :restart => true, :reload => true
end
-# Use NRPE LWRP to define a check
+# Use NRPE LWRP to define a few checks
nagios_nrpecheck "check_load" do
command "#{node['nagios']['plugin_dir']}/check_load"
warning_condition node['nagios']['checks']['load']['warning']
critical_condition node['nagios']['checks']['load']['critical']
action :add
end
+
+nagios_nrpecheck "check_all_disks" do
+ command "#{node['nagios']['plugin_dir']}/check_disk"
+ warning_condition "8%"
+ critical_condition "5%"
+ parameters "-A -x /dev/shm -X nfs -i /boot"
+ action :add
+end
+
+nagios_nrpecheck "check_users" do
+ command "#{node['nagios']['plugin_dir']}/check_users"
+ warning_condition "20"
+ critical_condition "30"
+ action :add
+end
View
4 nagios/resources/nrpecheck.rb
@@ -22,8 +22,8 @@
# Name of the nrpe check, used for the filename and the command name
attribute :command_name, :kind_of => String, :name_attribute => true
-attribute :warning_condition, :kind_of => String
-attribute :critical_condition, :kind_of => String
+attribute :warning_condition, :kind_of => String, :default => nil
+attribute :critical_condition, :kind_of => String, :default => nil
attribute :command, :kind_of => String
attribute :parameters, :kind_of => String, :default => nil
View
2  nagios/templates/default/nrpe.cfg.erb
@@ -8,8 +8,6 @@ command_timeout=60
allowed_hosts=<%= @mon_host.join(',') %>
include_dir=<%= @nrpe_directory %>
-command[check_users]=<%= node['nagios']['plugin_dir'] %>/check_users -w 20 -c 30
-command[check_all_disks]=<%= node['nagios']['plugin_dir'] %>/check_disk -w 8% -c 5% -A -x /dev/shm -X nfs -i /boot
command[check_zombie_procs]=<%= node['nagios']['plugin_dir'] %>/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=<%= node['nagios']['plugin_dir'] %>/check_procs -w 500 -c 800
command[check_swap]=<%= node['nagios']['plugin_dir'] %>/check_swap -w '50%' -c '25%'
View
3  nagios/templates/default/nrpe_command.cfg.erb
@@ -1,3 +0,0 @@
-# NRPE command file generated by Chef.
-
-command[<%= @command_name %>]=<%= @command %> -w <%= @warning_condition %> -c <%= @critical_condition %> <%= @parameters -%>
Please sign in to comment.
Something went wrong with that request. Please try again.