Created
November 12, 2013 20:20
-
-
Save afirth/7437947 to your computer and use it in GitHub Desktop.
nagios 5.0.2 vs 4.2.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/.gitignore b/.gitignore | |
index fc5b76d..abf8a27 100644 | |
--- a/.gitignore | |
+++ b/.gitignore | |
@@ -1,4 +1,23 @@ | |
-.bundle | |
-.cache | |
-.kitchen | |
-bin | |
+_Store | |
+*~ | |
+*# | |
+.#* | |
+\#*# | |
+.*.sw[a-z] | |
+*.un~ | |
+*.tmp | |
+*.bk | |
+*.bkup | |
+.kitchen.local.yml | |
+Berksfile.lock | |
+Gemfile.lock | |
+ | |
+.bundle/ | |
+.cache/ | |
+.kitchen/ | |
+.vagrant/ | |
+.vagrant.d/ | |
+bin/ | |
+tmp/ | |
+vendor/ | |
+ | |
diff --git a/CHANGELOG.md b/CHANGELOG.md | |
index dd9ae53..afb2696 100644 | |
--- a/CHANGELOG.md | |
+++ b/CHANGELOG.md | |
@@ -3,10 +3,36 @@ nagios Cookbook CHANGELOG | |
This file is used to list changes made in each version of the nagios cookbook. | |
-v4.2.1 | |
+v5.0.2 | |
------ | |
-- Scholastic modified to use new URL for Nagios Plugins download. | |
-- Scholastic modified to enhance pager behavior | |
+### Improvement | |
+- **[COOK-3777](https://tickets.opscode.com/browse/COOK-3777)** - Update NRPE in nagios cookbook to 2.15 | |
+- **[COOK-3021](https://tickets.opscode.com/browse/COOK-3021)** - NRPE LWRP updates files every run | |
+- Fixing up to pass rubocop | |
+ | |
+ | |
+v5.0.0 | |
+------ | |
+### Bug | |
+- **[COOK-3778](https://tickets.opscode.com/browse/COOK-3778)** - Fix missing customization points for Icinga | |
+- **[COOK-3731](https://tickets.opscode.com/browse/COOK-3731)** - Remove range searches in Nagios cookbook that break chef-zero | |
+- **[COOK-3729](https://tickets.opscode.com/browse/COOK-3729)** - Update Nagios Plugin download URL | |
+- **[COOK-3579](https://tickets.opscode.com/browse/COOK-3579)** - Stop shipping icons files that arent used | |
+- **[COOK-3332](https://tickets.opscode.com/browse/COOK-3332)** - Fix `nagios::client` failures on Chef Solo | |
+ | |
+### Improvement | |
+- **[COOK-3730](https://tickets.opscode.com/browse/COOK-3730)** - Change the default authentication method | |
+- **[COOK-3696](https://tickets.opscode.com/browse/COOK-3696)** - Sort hostgroups so they don't get updated on each run | |
+- **[COOK-3670](https://tickets.opscode.com/browse/COOK-3670)** - Add Travis support | |
+- **[COOK-3583](https://tickets.opscode.com/browse/COOK-3583)** - Update Nagios source to 3.5.1 | |
+- **[COOK-3577](https://tickets.opscode.com/browse/COOK-3577)** - Cleanup code style | |
+- **[COOK-3287](https://tickets.opscode.com/browse/COOK-3287)** - Provide more customization points to make it possible to use Icinga | |
+- **[COOK-1725](https://tickets.opscode.com/browse/COOK-1725)** - Add configurable notification options for `nagios::pagerduty` | |
+ | |
+### New Feature | |
+- **[COOK-3723](https://tickets.opscode.com/browse/COOK-3723)** - Support regexp_matching in Nagios | |
+- **[COOK-3695](https://tickets.opscode.com/browse/COOK-3695)** - Add more tunables for default host template | |
+ | |
v4.2.0 | |
------ | |
diff --git a/Gemfile b/Gemfile | |
index 5e8a588..3fc386a 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -1,4 +1,12 @@ | |
-source :rubygems | |
+source 'https://rubygems.org' | |
-gem 'test-kitchen', '< 1.0' | |
-gem 'chefspec', git: 'git://github.com/acrmp/chefspec.git' | |
+gem 'strainer' | |
+gem 'berkshelf', '~> 2.0' | |
+gem 'chefspec', '~> 3.0' | |
+gem 'foodcritic', '~> 3.0' | |
+gem 'rubocop', '~> 0.14' | |
+ | |
+group :integration do | |
+ gem 'test-kitchen', '~> 1.0.0.beta.4' | |
+ gem 'kitchen-vagrant', '~> 0.11' | |
+end | |
diff --git a/README.md b/README.md | |
index e86d9ba..0506f9f 100644 | |
--- a/README.md | |
+++ b/README.md | |
@@ -1,5 +1,7 @@ | |
nagios Cookbook | |
=============== | |
+[](http://travis-ci.org/opscode-cookbooks/nagios) | |
+ | |
Installs and configures Nagios server and NRPE client. Chef nodes are automatically discovered using search, and Nagios host groups are created based on Chef roles and optionally environments as well. NRPE client commands can be defined by using a LWRP, and Nagios service checks applied to hostgroups using definitions in data bag items. | |
@@ -88,7 +90,7 @@ The following attributes are used for the Nagios server | |
* `node['nagios']['additional_contacts']` - additional contacts to be utilized for notifying of status changes. Example: `node['nagios']['additional_contacts']['pagerduty'] = true`. | |
* `node['nagios']['sysadmin_email']` - default notification email. | |
* `node['nagios']['sysadmin_sms_email']` - default notification sms. | |
-* `node['nagios']['server_auth_method']` - authentication with the server can be done with openid (using `apache2::mod_auth_openid`), cas (using `apache2::mod_auth_cas`),ldap (using `apache2::mod_authnz_ldap`), or htauth (basic). The default is openid, "cas" will utilize cas authentication, "ldap" will utilize LDAP authentication, and any other value will use htauth (basic). | |
+* `node['nagios']['server_auth_method']` - authentication with the server can be done with openid (using `apache2::mod_auth_openid`), cas (using `apache2::mod_auth_cas`),ldap (using `apache2::mod_authnz_ldap`), or htauth (basic). The default is htauth. "openid" will utilize openid authentication, "cas" will utilize cas authentication, "ldap" will utilize LDAP authentication, and any other value will use htauth (basic). | |
* `node['nagios']['cas_login_url']` - login url for cas if using cas authentication. | |
* `node['nagios']['cas_validate_url']` - validation url for cas if using cas authentication. | |
* `node['nagios']['cas_validate_server']` - whether to validate the server cert. Defaults to off. | |
@@ -101,23 +103,27 @@ The following attributes are used for the Nagios server | |
* `node['nagios']['users_databag_group']` - users databag group considered Nagios admins. defaults to sysadmin | |
* `node['nagios']['host_name_attribute']` - node attribute to use for naming the host. Must be unique across monitored nodes. Defaults to hostname | |
* `node['nagios']['regexp_matching']` - Attribute to enable [regexp matching](http://nagios.sourceforge.net/docs/3_0/configmain.html#use_regexp_matching). Defaults to 0. | |
-* `node['nagios']['true_regexp_matching']` - Attribute to enable [true regexp matching](http://nagios.sourceforge.net/docs/3_0/configmain.html#use_true_regexp_matching). Defaults to 0. | |
* `node['nagios']['large_installation_tweaks']` - Attribute to enable [large installation tweaks](http://nagios.sourceforge.net/docs/3_0/largeinstalltweaks.html). Defaults to 0. | |
* `node['nagios']['templates']` | |
* `node['nagios']['interval_length']` - minimum interval. | |
-* `node['nagios']['default_host']['check_interval']` | |
-* `node['nagios']['default_host']['retry_interval']` | |
-* `node['nagios']['default_host']['max_check_attempts']` | |
-* `node['nagios']['default_host']['notification_interval']` | |
+These set directives in the default host template. Unless explicitly | |
+overridden, they will be inheirited by the host definitions for each | |
+disovered node and `nagios_unmanagedhosts` data bag. For more | |
+information about these directives, see the Nagios documentation for | |
+[host definitions](http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#host). | |
-* `node['nagios']['default_service']['check_interval']` | |
-* `node['nagios']['default_service']['retry_interval']` | |
-* `node['nagios']['default_service']['max_check_attempts']` | |
-* `node['nagios']['default_service']['notification_interval']` | |
+* `node['nagios']['default_host']['flap_detection']` - Defaults to `true`. | |
+* `node['nagios']['default_host']['check_period']` - Defaults to `'24x7'`. | |
+* `node['nagios']['default_host']['check_interval']` - In seconds. Must be divisible by `node['nagios']['interval_length']`. Defaults to `15`. | |
+* `node['nagios']['default_host']['retry_interval']` - In seconds. Must be divisible by `node['nagios']['interval_length']`. Defaults to `15`. | |
+* `node['nagios']['default_host']['max_check_attempts']` - Defaults to `1`. | |
+* `node['nagios']['default_host']['check_command']` - Defaults to the pre-defined command `'check-host-alive'`. | |
+* `node['nagios']['default_host']['notification_interval']` - In seconds. Must be divisible by `node['nagios']['interval_length']`. Defaults to `300`. | |
+* `node['nagios']['default_host']['notification_options']` - Defaults to `'d,u,r'`. | |
* `node['nagios']['server']['web_server']` - web server to use. supports Apache or Nginx, default "apache" | |
-* `node['nagios']['server']['nginx_dispatch']` - nginx dispatch method. support cgi or php, default "cgi" | |
+* `node['nagios']['server']['nginx_dispatch']` - nginx dispatch method. supports cgi or php, default "cgi" | |
* `node['nagios']['server']['stop_apache']` - stop apache service if using nginx, default false | |
* `node['nagios']['server']['redirect_root']` - if using Apache, should http://server/ redirect to http://server/nagios3 automatically, default false | |
* `node['nagios']['server']['normalize_hostname']` - If set to true, normalize all hostnames in hosts.cfg to lowercase. Defaults to false. | |
@@ -173,7 +179,7 @@ Installs the Nagios server from packages. Default for Debian / Ubuntu systems. | |
Installs the Nagios server from source. Default for Red Hat / Fedora based systems as native packages for Nagios are not available in the default repositories. | |
### pagerduty | |
-Installs and configures pagerduty plugin for Nagios. You need to set a `node['nagios']['pagerduty_key']` attribute on your server for this to work. This can be set through environments so that you can use different API keys for servers in production vs staging for instance. | |
+Installs and configures pagerduty plugin for Nagios. You need to set a `node['nagios']['pagerduty']['key']` attribute on your server for this to work. This can be set through environments so that you can use different API keys for servers in production vs staging for instance. | |
This recipe was written based on the [Nagios Integration Guide](http://www.pagerduty.com/docs/guides/nagios-integration-guide) from PagerDuty which explains how to get an API key for your Nagios server. | |
diff --git a/attributes/client.rb b/attributes/client.rb | |
index d25dc9c..d6dd72d 100644 | |
--- a/attributes/client.rb | |
+++ b/attributes/client.rb | |
@@ -8,7 +8,7 @@ | |
# Attributes:: client | |
# | |
# Copyright 2009, 37signals | |
-# Copyright 2009-2011, Opscode, Inc | |
+# Copyright 2009-2013, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
@@ -29,7 +29,7 @@ when 'debian' | |
default['nagios']['nrpe']['pidfile'] = '/var/run/nagios/nrpe.pid' | |
default['nagios']['nrpe']['home'] = '/usr/lib/nagios' | |
default['nagios']['nrpe']['packages'] = %w{ nagios-nrpe-server nagios-plugins nagios-plugins-basic nagios-plugins-standard } | |
- if node['kernel']['machine'] == "i686" | |
+ if node['kernel']['machine'] == 'i686' | |
default['nagios']['nrpe']['ssl_lib_dir'] = '/usr/lib/i386-linux-gnu' | |
else | |
default['nagios']['nrpe']['ssl_lib_dir'] = '/usr/lib/x86_64-linux-gnu' | |
@@ -43,7 +43,7 @@ when 'rhel','fedora' | |
default['nagios']['client']['install_method'] = 'source' | |
default['nagios']['nrpe']['pidfile'] = '/var/run/nrpe.pid' | |
default['nagios']['nrpe']['packages'] = %w{ nrpe nagios-plugins-disk nagios-plugins-load nagios-plugins-procs nagios-plugins-users } | |
- if node['kernel']['machine'] == "i686" | |
+ if node['kernel']['machine'] == 'i686' | |
default['nagios']['nrpe']['home'] = '/usr/lib/nagios' | |
default['nagios']['nrpe']['ssl_lib_dir'] = '/usr/lib' | |
else | |
@@ -70,8 +70,8 @@ default['nagios']['plugins']['checksum'] = 'b0caf07e0084e9b7f10fdd71cbd3ebabcd85 | |
# for nrpe from source installation | |
default['nagios']['nrpe']['url'] = 'http://prdownloads.sourceforge.net/sourceforge/nagios' | |
-default['nagios']['nrpe']['version'] = '2.14' | |
-default['nagios']['nrpe']['checksum'] = '808c7c4a82d0addf15449663e4712b5018c8bbd668e46723139f731f1ac44431' | |
+default['nagios']['nrpe']['version'] = '2.15' | |
+default['nagios']['nrpe']['checksum'] = '66383b7d367de25ba031d37762d83e2b55de010c573009c6f58270b137131072' | |
default['nagios']['server_role'] = 'monitoring' | |
default['nagios']['allowed_hosts'] = nil | |
diff --git a/attributes/default.rb b/attributes/default.rb | |
index 67df038..61778a7 100644 | |
--- a/attributes/default.rb | |
+++ b/attributes/default.rb | |
@@ -3,7 +3,7 @@ | |
# Cookbook Name:: nagios | |
# Attributes:: default | |
# | |
-# Copyright 2011, Opscode, Inc | |
+# Copyright 2011-2013, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
@@ -28,7 +28,7 @@ case node['platform_family'] | |
when 'debian' | |
default['nagios']['plugin_dir'] = '/usr/lib/nagios/plugins' | |
when 'rhel', 'fedora' | |
- if node['kernel']['machine'] == "i686" | |
+ if node['kernel']['machine'] == 'i686' | |
default['nagios']['plugin_dir'] = '/usr/lib/nagios/plugins' | |
else | |
default['nagios']['plugin_dir'] = '/usr/lib64/nagios/plugins' | |
diff --git a/attributes/server.rb b/attributes/server.rb | |
index 2352f50..ee09701 100644 | |
--- a/attributes/server.rb | |
+++ b/attributes/server.rb | |
@@ -7,7 +7,7 @@ | |
# Attributes:: server | |
# | |
# Copyright 2009, 37signals | |
-# Copyright 2009-2011, Opscode, Inc | |
+# Copyright 2009-2013, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
@@ -22,11 +22,14 @@ | |
# limitations under the License. | |
# | |
-default['nagios']['pagerduty_key'] = '' | |
-default['nagios']['pagerduty']['script_url'] = 'https://raw.github.com/PagerDuty/pagerduty-nagios-pl/master/pagerduty_nagios.pl' | |
-unless node['nagios']['pagerduty_key'].empty? | |
+node.set['nagios']['pagerduty']['key'] = node['nagios']['pagerduty_key'] | |
+default['nagios']['pagerduty']['key'] = '' | |
+unless node['nagios']['pagerduty']['key'].empty? | |
default['nagios']['additional_contacts'] = { 'pagerduty' => true } | |
end | |
+default['nagios']['pagerduty']['script_url'] = 'https://raw.github.com/PagerDuty/pagerduty-nagios-pl/master/pagerduty_nagios.pl' | |
+default['nagios']['pagerduty']['service_notification_options'] = 'w,u,c,r' | |
+default['nagios']['pagerduty']['host_notification_options'] = 'd,r' | |
case node['platform_family'] | |
when 'debian' | |
@@ -54,34 +57,41 @@ default['nagios']['docroot'] = '/usr/share/nagios3/htdocs' | |
default['nagios']['timezone'] = 'UTC' | |
default['nagios']['enable_ssl'] = false | |
default['nagios']['http_port'] = node['nagios']['enable_ssl'] ? '443' : '80' | |
-default['nagios']['server_name'] = node.has_key?(:domain) ? "nagios.#{domain}" : 'nagios' | |
+default['nagios']['server_name'] = node.key?(:domain) ? "nagios.#{domain}" : 'nagios' | |
default['nagios']['ssl_cert_file'] = "#{node['nagios']['conf_dir']}/certificates/nagios-server.pem" | |
default['nagios']['ssl_cert_key'] = "#{node['nagios']['conf_dir']}/certificates/nagios-server.pem" | |
default['nagios']['ssl_req'] = '/C=US/ST=Several/L=Locality/O=Example/OU=Operations/' + | |
"CN=#{node['nagios']['server_name']}/emailAddress=ops@#{node['nagios']['server_name']}" | |
+# nagios server name and webserver vname. this can be changed to allow for the installation of icinga | |
+default['nagios']['server']['name'] = 'nagios' | |
+default['nagios']['server']['vname'] = 'nagios3' | |
+ | |
# for server from source installation | |
default['nagios']['server']['url'] = 'http://prdownloads.sourceforge.net/sourceforge/nagios' | |
default['nagios']['server']['version'] = '3.5.0' | |
default['nagios']['server']['checksum'] = '469381b2954392689c85d3db733e8da4bd43b806b3d661d1a7fbd52dacc084db' | |
+default['nagios']['server']['src_dir'] = 'nagios' | |
+ | |
+# for server from packages installation | |
+default['nagios']['server']['packages'] = %w[nagios3 nagios-nrpe-plugin nagios-images] | |
default['nagios']['notifications_enabled'] = 0 | |
default['nagios']['check_external_commands'] = true | |
default['nagios']['default_contact_groups'] = %w{admins} | |
-default['nagios']['sysadmin_email'] = "root@localhost" | |
-default['nagios']['sysadmin_sms_email'] = "root@localhost" | |
-default['nagios']['server_auth_method'] = "openid" | |
-default['nagios']['users_databag'] = "users" | |
-default['nagios']['users_databag_group'] = "sysadmin" | |
-default['nagios']['host_name_attribute'] = "hostname" | |
+default['nagios']['sysadmin_email'] = 'root@localhost' | |
+default['nagios']['sysadmin_sms_email'] = 'root@localhost' | |
+default['nagios']['server_auth_method'] = 'htauth' | |
+default['nagios']['users_databag'] = 'users' | |
+default['nagios']['users_databag_group'] = 'sysadmin' | |
+default['nagios']['host_name_attribute'] = 'hostname' | |
default['nagios']['regexp_matching'] = 0 | |
-default['nagios']['true_regexp_matching'] = 0 | |
default['nagios']['large_installation_tweaks'] = 0 | |
# for cas authentication | |
-default['nagios']['cas_login_url'] = "https://example.com/cas/login" | |
-default['nagios']['cas_validate_url'] = "https://example.com/cas/serviceValidate" | |
-default['nagios']['cas_validate_server'] = "off" | |
+default['nagios']['cas_login_url'] = 'https://example.com/cas/login' | |
+default['nagios']['cas_validate_url'] = 'https://example.com/cas/serviceValidate' | |
+default['nagios']['cas_validate_server'] = 'off' | |
default['nagios']['cas_root_proxy_url'] = nil | |
# for apache ldap authentication | |
@@ -96,12 +106,15 @@ default['nagios']['ldap_authoritative'] = nil | |
default['nagios']['templates'] = Mash.new | |
default['nagios']['interval_length'] = 1 | |
+default['nagios']['default_host']['flap_detection'] = true | |
+default['nagios']['default_host']['check_period'] = '24x7' | |
# Provide all interval values in seconds | |
default['nagios']['default_host']['check_interval'] = 15 | |
default['nagios']['default_host']['retry_interval'] = 15 | |
default['nagios']['default_host']['max_check_attempts'] = 1 | |
+default['nagios']['default_host']['check_command'] = 'check-host-alive' | |
default['nagios']['default_host']['notification_interval'] = 300 | |
-default['nagios']['default_host']['flap_detection'] = true | |
+default['nagios']['default_host']['notification_options'] = 'd,u,r' | |
default['nagios']['default_service']['check_interval'] = 60 | |
default['nagios']['default_service']['retry_interval'] = 15 | |
@@ -113,5 +126,4 @@ default['nagios']['server']['web_server'] = :apache | |
default['nagios']['server']['nginx_dispatch'] = :cgi | |
default['nagios']['server']['stop_apache'] = false | |
default['nagios']['server']['redirect_root'] = false | |
- | |
default['nagios']['server']['normalize_hostname'] = false | |
diff --git a/definitions/nagios_conf.rb b/definitions/nagios_conf.rb | |
index e21d0fb..46ff709 100644 | |
--- a/definitions/nagios_conf.rb | |
+++ b/definitions/nagios_conf.rb | |
@@ -7,7 +7,7 @@ | |
# Definition:: nagios_conf | |
# | |
# Copyright 2009, 37signals | |
-# Copyright 2009-2011, Opscode, Inc | |
+# Copyright 2009-2013, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
@@ -21,17 +21,18 @@ | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
-define :nagios_conf, :variables => {}, :config_subdir => true do | |
+define :nagios_conf, :variables => {}, :config_subdir => true, :source => nil do | |
conf_dir = params[:config_subdir] ? node['nagios']['config_dir'] : node['nagios']['conf_dir'] | |
+ params[:source] ||= "#{params[:name]}.cfg.erb" | |
template "#{conf_dir}/#{params[:name]}.cfg" do | |
owner node['nagios']['user'] | |
group node['nagios']['group'] | |
- source "#{params[:name]}.cfg.erb" | |
+ source params[:source] | |
mode 00644 | |
variables params[:variables] | |
- notifies :reload, "service[nagios]" | |
+ notifies :reload, 'service[nagios]' | |
backup 0 | |
end | |
end | |
diff --git a/examples/base_monitoring.rb b/examples/base_monitoring.rb | |
index 02ceb38..fae0fab 100644 | |
--- a/examples/base_monitoring.rb | |
+++ b/examples/base_monitoring.rb | |
@@ -8,25 +8,25 @@ | |
# in Example Company Inc's Chef environment. | |
# Check for high load. This check defines warning levels and attributes | |
-nagios_nrpecheck "check_load" do | |
+nagios_nrpecheck 'check_load' do | |
command "#{node['nagios']['plugin_dir']}/check_load" | |
- warning_condition "6" | |
- critical_condition "10" | |
+ warning_condition '6' | |
+ critical_condition '10' | |
action :add | |
end | |
# Check all non-NFS/tmp-fs disks. | |
-nagios_nrpecheck "check_all_disks" do | |
+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" | |
+ warning_condition '8%' | |
+ critical_condition '5%' | |
+ parameters '-A -x /dev/shm -X nfs -i /boot' | |
action :add | |
end | |
# Check for excessive users. This command relies on the service definition to | |
# define what the warning/critical levels and attributes are | |
-nagios_nrpecheck "check_users" do | |
+nagios_nrpecheck 'check_users' do | |
command "#{node['nagios']['plugin_dir']}/check_users" | |
action :add | |
end | |
diff --git a/files/default/icons/centos.gd2 b/files/default/icons/centos.gd2 | |
deleted file mode 100644 | |
index 1da6777..0000000 | |
Binary files a/files/default/icons/centos.gd2 and /dev/null differ | |
diff --git a/files/default/icons/centos.gif b/files/default/icons/centos.gif | |
deleted file mode 100644 | |
index b35146c..0000000 | |
Binary files a/files/default/icons/centos.gif and /dev/null differ | |
diff --git a/files/default/icons/centos.jpg b/files/default/icons/centos.jpg | |
deleted file mode 100644 | |
index 3d1f7d9..0000000 | |
Binary files a/files/default/icons/centos.jpg and /dev/null differ | |
diff --git a/files/default/icons/centos.png b/files/default/icons/centos.png | |
deleted file mode 100644 | |
index e626bcf..0000000 | |
Binary files a/files/default/icons/centos.png and /dev/null differ | |
diff --git a/files/default/icons/munin-head.gif b/files/default/icons/munin-head.gif | |
deleted file mode 100644 | |
index 3a08d7f..0000000 | |
Binary files a/files/default/icons/munin-head.gif and /dev/null differ | |
diff --git a/files/default/icons/ubuntu.gd2 b/files/default/icons/ubuntu.gd2 | |
deleted file mode 100644 | |
index e05163b..0000000 | |
Binary files a/files/default/icons/ubuntu.gd2 and /dev/null differ | |
diff --git a/files/default/icons/ubuntu.gif b/files/default/icons/ubuntu.gif | |
deleted file mode 100644 | |
index 0a51c53..0000000 | |
Binary files a/files/default/icons/ubuntu.gif and /dev/null differ | |
diff --git a/files/default/icons/ubuntu.jpg b/files/default/icons/ubuntu.jpg | |
deleted file mode 100644 | |
index 0535df9..0000000 | |
Binary files a/files/default/icons/ubuntu.jpg and /dev/null differ | |
diff --git a/files/default/icons/ubuntu.png b/files/default/icons/ubuntu.png | |
deleted file mode 100644 | |
index b2d71d9..0000000 | |
Binary files a/files/default/icons/ubuntu.png and /dev/null differ | |
diff --git a/libraries/data_bag_helper.rb b/libraries/data_bag_helper.rb | |
index 2522272..888f3de 100644 | |
--- a/libraries/data_bag_helper.rb | |
+++ b/libraries/data_bag_helper.rb | |
@@ -1,5 +1,6 @@ | |
-require "chef/search/query" | |
+require 'chef/search/query' | |
+# simplified access to databags in the nagios cookbook | |
class NagiosDataBags | |
attr_accessor :bag_list | |
@@ -13,7 +14,7 @@ class NagiosDataBags | |
def get(bag_name) | |
results = [] | |
if @bag_list.include?(bag_name) | |
- Chef::Search::Query.new.search(bag_name.to_s, "*:*") {|rows| results << rows} | |
+ Chef::Search::Query.new.search(bag_name.to_s, '*:*') { |rows| results << rows } | |
else | |
Chef::Log.info "The #{bag_name} data bag does not exist." | |
end | |
diff --git a/libraries/default.rb b/libraries/default.rb | |
index a18b112..3e89c3c 100644 | |
--- a/libraries/default.rb | |
+++ b/libraries/default.rb | |
@@ -18,16 +18,16 @@ | |
# limitations under the License. | |
# | |
def nagios_boolean(true_or_false) | |
- true_or_false ? "1" : "0" | |
+ true_or_false ? '1' : '0' | |
end | |
def nagios_interval(seconds) | |
if seconds.to_i != 0 && seconds.to_i < node['nagios']['interval_length'].to_i | |
- raise ArgumentError, "Specified nagios interval of #{seconds} seconds must ether be zero or be equal to or greater than the default interval length of #{node['nagios']['interval_length']}" | |
+ fail ArgumentError, "Specified nagios interval of #{seconds} seconds must ether be zero or be equal to or greater than the default interval length of #{node['nagios']['interval_length']}" | |
end | |
interval = seconds.to_f / node['nagios']['interval_length'] | |
if interval != interval.to_i | |
- raise ArgumentError, "Specified nagios interval of #{seconds} seconds must be a multiple of the interval length of #{node['nagios']['interval_length']}" | |
+ fail ArgumentError, "Specified nagios interval of #{seconds} seconds must be a multiple of the interval length of #{node['nagios']['interval_length']}" | |
end | |
interval | |
end | |
@@ -35,4 +35,3 @@ end | |
def nagios_attr(name) | |
node['nagios'][name] | |
end | |
- | |
diff --git a/metadata.rb b/metadata.rb | |
index dbd8a25..db2ab5e 100644 | |
--- a/metadata.rb | |
+++ b/metadata.rb | |
@@ -1,15 +1,15 @@ | |
-name "nagios" | |
-maintainer "Opscode, Inc." | |
-maintainer_email "[email protected]" | |
-license "Apache 2.0" | |
-description "Installs and configures Nagios server and the NRPE client" | |
+name 'nagios' | |
+maintainer 'Opscode, Inc.' | |
+maintainer_email '[email protected]' | |
+license 'Apache 2.0' | |
+description 'Installs and configures Nagios server and the NRPE client' | |
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | |
-version "4.2.2" | |
+version '5.0.2' | |
-recipe "nagios", "Includes the client recipe." | |
-recipe "nagios::client", "Installs and configures a nrpe client" | |
-recipe "nagios::server", "Installs and configures a nagios server" | |
-recipe "nagios::pagerduty", "Integrates contacts w/ PagerDuty API" | |
+recipe 'nagios', 'Includes the client recipe.' | |
+recipe 'nagios::client', 'Installs and configures a nrpe client' | |
+recipe 'nagios::server', 'Installs and configures a nagios server' | |
+recipe 'nagios::pagerduty', 'Integrates contacts w/ PagerDuty API' | |
%w{ apache2 build-essential php nginx nginx_simplecgi yum }.each do |cb| | |
depends cb | |
diff --git a/providers/nrpecheck.rb b/providers/nrpecheck.rb | |
index aa9e23b..e632993 100644 | |
--- a/providers/nrpecheck.rb | |
+++ b/providers/nrpecheck.rb | |
@@ -28,23 +28,23 @@ action :add do | |
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 | |
+ f = file "#{node['nagios']['nrpe']['conf_dir']}/nrpe.d/#{new_resource.command_name}.cfg" do | |
owner node['nagios']['user'] | |
group node['nagios']['group'] | |
mode 00640 | |
content file_contents | |
notifies :restart, "service[#{node['nagios']['nrpe']['service_name']}]" | |
end | |
- new_resource.updated_by_last_action(true) | |
+ new_resource.updated_by_last_action(f.updated_by_last_action?) | |
end | |
action :remove do | |
if ::File.exists?("#{node['nagios']['nrpe']['conf_dir']}/nrpe.d/#{new_resource.command_name}.cfg") | |
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 | |
+ f = file "#{node['nagios']['nrpe']['conf_dir']}/nrpe.d/#{new_resource.command_name}.cfg" do | |
action :delete | |
notifies :restart, "service[#{node['nagios']['nrpe']['service_name']}]" | |
end | |
- new_resource.updated_by_last_action(true) | |
+ new_resource.updated_by_last_action(f.updated_by_last_action?) | |
end | |
end | |
diff --git a/recipes/apache.rb b/recipes/apache.rb | |
index 6faea55..ac2b327 100644 | |
--- a/recipes/apache.rb | |
+++ b/recipes/apache.rb | |
@@ -14,22 +14,19 @@ | |
# limitations under the License. | |
# | |
-include_recipe "apache2" | |
-include_recipe "apache2::mod_rewrite" | |
-include_recipe "apache2::mod_php5" | |
+include_recipe 'apache2' | |
+include_recipe 'apache2::mod_rewrite' | |
+include_recipe 'apache2::mod_php5' | |
+include_recipe 'apache2::mod_ssl' if node['nagios']['enable_ssl'] | |
-if node['nagios']['enable_ssl'] | |
- include_recipe "apache2::mod_ssl" | |
-end | |
- | |
-apache_site "000-default" do | |
+apache_site '000-default' do | |
enable false | |
end | |
public_domain = node['public_domain'] || node['domain'] | |
-template "#{node['apache']['dir']}/sites-available/nagios3.conf" do | |
- source "apache2.conf.erb" | |
+template "#{node['apache']['dir']}/sites-available/#{node['nagios']['server']['vname']}.conf" do | |
+ source 'apache2.conf.erb' | |
mode 00644 | |
variables( | |
:public_domain => public_domain, | |
@@ -38,13 +35,13 @@ template "#{node['apache']['dir']}/sites-available/nagios3.conf" do | |
:ssl_cert_file => node['nagios']['ssl_cert_file'], | |
:ssl_cert_key => node['nagios']['ssl_cert_key'] | |
) | |
- if ::File.symlink?("#{node['apache']['dir']}/sites-enabled/nagios3.conf") | |
- notifies :reload, "service[apache2]" | |
+ if ::File.symlink?("#{node['apache']['dir']}/sites-enabled/#{node['nagios']['server']['vname']}.conf") | |
+ notifies :reload, 'service[apache2]' | |
end | |
end | |
-file "#{node['apache']['dir']}/conf.d/nagios3.conf" do | |
+file "#{node['apache']['dir']}/conf.d/#{node['nagios']['server']['vname']}.conf" do | |
action :delete | |
end | |
-apache_site "nagios3.conf" | |
+apache_site "#{node['nagios']['server']['vname']}.conf" | |
diff --git a/recipes/client.rb b/recipes/client.rb | |
index ba9f086..c65613c 100644 | |
--- a/recipes/client.rb | |
+++ b/recipes/client.rb | |
@@ -7,7 +7,7 @@ | |
# Recipe:: client | |
# | |
# Copyright 2009, 37signals | |
-# Copyright 2009-2011, Opscode, Inc | |
+# Copyright 2009-2013, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
@@ -32,7 +32,7 @@ elsif node['nagios']['multi_environment_monitoring'] | |
search(:node, "role:#{node['nagios']['server_role']}") do |n| | |
mon_host << n['ipaddress'] | |
end | |
-else | |
+elsif !Chef::Config[:solo] | |
search(:node, "role:#{node['nagios']['server_role']} AND chef_environment:#{node.chef_environment}") do |n| | |
mon_host << n['ipaddress'] | |
end | |
@@ -40,9 +40,7 @@ end | |
# on the first run, search isn't available, so if you're the nagios server, go | |
# ahead and put your own IP address in the NRPE config (unless it's already there). | |
if node.run_list.roles.include?(node['nagios']['server_role']) | |
- unless mon_host.include?(node['ipaddress']) | |
- mon_host << node['ipaddress'] | |
- end | |
+ mon_host << node['ipaddress'] unless mon_host.include?(node['ipaddress']) | |
end | |
mon_host.concat node['nagios']['allowed_hosts'] if node['nagios']['allowed_hosts'] | |
@@ -56,7 +54,7 @@ directory "#{node['nagios']['nrpe']['conf_dir']}/nrpe.d" do | |
end | |
template "#{node['nagios']['nrpe']['conf_dir']}/nrpe.cfg" do | |
- source "nrpe.cfg.erb" | |
+ source 'nrpe.cfg.erb' | |
owner node['nagios']['user'] | |
group node['nagios']['group'] | |
mode 00644 | |
diff --git a/recipes/client_package.rb b/recipes/client_package.rb | |
index 6603f20..605d42c 100644 | |
--- a/recipes/client_package.rb | |
+++ b/recipes/client_package.rb | |
@@ -21,9 +21,9 @@ | |
# nrpe packages are available in EPEL on rhel / fedora platforms | |
# fedora 17 and later don't require epel | |
-if platform_family?("rhel","fedora") | |
- unless platform?("fedora") && node['platform_version'] < 17 | |
- include_recipe "yum::epel" | |
+if platform_family?('rhel', 'fedora') | |
+ unless platform?('fedora') && node['platform_version'] < 17 | |
+ include_recipe 'yum::epel' | |
end | |
end | |
diff --git a/recipes/client_source.rb b/recipes/client_source.rb | |
index de03a86..7f05613 100644 | |
--- a/recipes/client_source.rb | |
+++ b/recipes/client_source.rb | |
@@ -3,7 +3,7 @@ | |
# Cookbook Name:: nagios | |
# Recipe:: client_source | |
# | |
-# Copyright 2011, Opscode, Inc | |
+# Copyright 2011-2013, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
@@ -18,13 +18,13 @@ | |
# limitations under the License. | |
# | |
-include_recipe "build-essential" | |
+include_recipe 'build-essential' | |
pkgs = value_for_platform_family( | |
- ["rhel","fedora"] => ["openssl-devel","make","tar"] , | |
- "debian" => ["libssl-dev","make","tar"], | |
- "gentoo" => [], | |
- "default" => ["libssl-dev","make","tar"] | |
+ %w{ rhel fedora } => %w{ openssl-devel make tar }, | |
+ 'debian' => %w{ libssl-dev make tar }, | |
+ 'gentoo' => [], | |
+ 'default' => %w{ libssl-dev make tar } | |
) | |
pkgs.each do |pkg| | |
@@ -49,7 +49,7 @@ remote_file "#{Chef::Config[:file_cache_path]}/nagios-plugins-#{plugins_version} | |
action :create_if_missing | |
end | |
-bash "compile-nagios-plugins" do | |
+bash 'compile-nagios-plugins' do | |
cwd Chef::Config[:file_cache_path] | |
code <<-EOH | |
tar zxvf nagios-plugins-#{plugins_version}.tar.gz | |
@@ -65,5 +65,4 @@ bash "compile-nagios-plugins" do | |
end | |
# compile the NRPE service and NRPE plugin | |
-include_recipe "nagios::nrpe_source" | |
- | |
+include_recipe 'nagios::nrpe_source' | |
diff --git a/recipes/default.rb b/recipes/default.rb | |
index ceb1a4a..b40b3d1 100644 | |
--- a/recipes/default.rb | |
+++ b/recipes/default.rb | |
@@ -4,7 +4,7 @@ | |
# Cookbook Name:: nagios | |
# Recipe:: default | |
# | |
-# Copyright 2008-2009, Opscode, Inc | |
+# Copyright 2008-2013, Opscode, Inc | |
# Copyright 2009, 37signals | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
@@ -20,4 +20,4 @@ | |
# limitations under the License. | |
# | |
-include_recipe "nagios::client" | |
+include_recipe 'nagios::client' | |
diff --git a/recipes/nginx.rb b/recipes/nginx.rb | |
index a79d96b..971f797 100644 | |
--- a/recipes/nginx.rb | |
+++ b/recipes/nginx.rb | |
@@ -14,7 +14,7 @@ | |
# limitations under the License. | |
# | |
-if node["nagios"]["server"]["stop_apache"] | |
+if node['nagios']['server']['stop_apache'] | |
service 'apache2' do | |
action :stop | |
end | |
@@ -28,12 +28,12 @@ if platform_family?('rhel') || platform_family?('fedora') | |
end | |
end | |
-include_recipe "nginx" | |
+include_recipe 'nginx' | |
%w(default 000-default).each do |disable_site| | |
nginx_site disable_site do | |
enable false | |
- notifies :reload, "service[nginx]" | |
+ notifies :reload, 'service[nginx]' | |
end | |
end | |
@@ -45,17 +45,17 @@ end | |
case dispatch_type = node['nagios']['server']['nginx_dispatch'].to_sym | |
when :cgi | |
- node.set["nginx_simplecgi"]["cgi"] = true | |
+ node.set['nginx_simplecgi']['cgi'] = true | |
include_recipe 'nginx_simplecgi::setup' | |
when :php | |
- node.set["nginx_simplecgi"]["php"] = true | |
+ node.set['nginx_simplecgi']['php'] = true | |
include_recipe 'nginx_simplecgi::setup' | |
when :both | |
- node.set["nginx_simplecgi"]["php"] = true | |
- node.set["nginx_simplecgi"]["cgi"] = true | |
+ node.set['nginx_simplecgi']['php'] = true | |
+ node.set['nginx_simplecgi']['cgi'] = true | |
include_recipe 'nginx_simplecgi::setup' | |
else | |
- Chef::Log.warn "NAGIOS: NGINX setup does not have a dispatcher provided" | |
+ Chef::Log.warn 'NAGIOS: NGINX setup does not have a dispatcher provided' | |
end | |
template File.join(node['nginx']['dir'], 'sites-available', 'nagios3.conf') do | |
@@ -79,11 +79,11 @@ template File.join(node['nginx']['dir'], 'sites-available', 'nagios3.conf') do | |
:cgi => [:cgi, :both].include?(dispatch_type.to_sym), | |
:php => [:php, :both].include?(dispatch_type.to_sym) | |
) | |
- if(::File.symlink?(File.join(node['nginx']['dir'], 'sites-enabled', 'nagios3.conf'))) | |
+ if ::File.symlink?(File.join(node['nginx']['dir'], 'sites-enabled', 'nagios3.conf')) | |
notifies :reload, 'service[nginx]', :immediately | |
end | |
end | |
-nginx_site "nagios3.conf" do | |
- notifies :reload, "service[nginx]" | |
+nginx_site 'nagios3.conf' do | |
+ notifies :reload, 'service[nginx]' | |
end | |
diff --git a/recipes/nrpe_source.rb b/recipes/nrpe_source.rb | |
index 2f3349b..1caaf3c 100644 | |
--- a/recipes/nrpe_source.rb | |
+++ b/recipes/nrpe_source.rb | |
@@ -29,11 +29,11 @@ end | |
# handle a full install vs a plugin install. plugin installs are called via the | |
# server_source.rb recipe. full installs are called via client_source.rb | |
-if node['nagios']['client']['install_method'] == "source" | |
- install_type = "install" | |
+if node['nagios']['client']['install_method'] == 'source' | |
+ install_type = 'install' | |
template "/etc/init.d/#{node['nagios']['nrpe']['service_name']}" do | |
- source "nagios-nrpe-server.erb" | |
+ source 'nagios-nrpe-server.erb' | |
owner node['nagios']['user'] | |
group node['nagios']['group'] | |
mode 00755 | |
@@ -45,10 +45,10 @@ if node['nagios']['client']['install_method'] == "source" | |
mode 00755 | |
end | |
else | |
- install_type = "install-plugin" | |
+ install_type = 'install-plugin' | |
end | |
-bash "compile-nagios-nrpe" do | |
+bash 'compile-nagios-nrpe' do | |
cwd Chef::Config[:file_cache_path] | |
code <<-EOH | |
tar zxvf nrpe-#{nrpe_version}.tar.gz | |
diff --git a/recipes/pagerduty.rb b/recipes/pagerduty.rb | |
index 07ce34f..b5cdd58 100644 | |
--- a/recipes/pagerduty.rb | |
+++ b/recipes/pagerduty.rb | |
@@ -17,33 +17,45 @@ | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
-package "libwww-perl" do | |
- case node["platform_family"] | |
- when "rhel", "fedora" | |
- package_name "perl-libwww-perl" | |
- when "debian" | |
- package_name "libwww-perl" | |
- when "arch" | |
- package_name "libwww-perl" | |
+# TODO: remove when backward compatibility is dropped. | |
+def using_old_pagerduty_key_attribute? | |
+ node['nagios']['pagerduty_key'] && | |
+ node['nagios']['pagerduty_key'] != node['nagios']['pagerduty']['key'] | |
+end | |
+ | |
+if using_old_pagerduty_key_attribute? | |
+ Chef::Log.warn('The nagios.pagerduty_key attribute is deprecated. It is replaced by the nagios.pagerduty.key attribute.') | |
+ Chef::Log.warn('Assigning nagios.pagerduty.key from nagios.pagerduty_key now.') | |
+ node.set['nagios']['pagerduty']['key'] = node['nagios']['pagerduty_key'] | |
+end | |
+ | |
+package 'libwww-perl' do | |
+ case node['platform_family'] | |
+ when 'rhel', 'fedora' | |
+ package_name 'perl-libwww-perl' | |
+ when 'debian' | |
+ package_name 'libwww-perl' | |
+ when 'arch' | |
+ package_name 'libwww-perl' | |
end | |
action :install | |
end | |
-package "libcrypt-ssleay-perl" do | |
- case node["platform_family"] | |
- when "rhel", "fedora" | |
- package_name "perl-Crypt-SSLeay" | |
- when "debian" | |
- package_name "libcrypt-ssleay-perl" | |
- when "arch" | |
- package_name "libcrypt-ssleay-perl" | |
+package 'libcrypt-ssleay-perl' do | |
+ case node['platform_family'] | |
+ when 'rhel', 'fedora' | |
+ package_name 'perl-Crypt-SSLeay' | |
+ when 'debian' | |
+ package_name 'libcrypt-ssleay-perl' | |
+ when 'arch' | |
+ package_name 'libcrypt-ssleay-perl' | |
end | |
action :install | |
end | |
-remote_file "#{node['nagios']['plugin_dir']}/pagerduty_nagios.pl" do | |
- owner "root" | |
- group "root" | |
+remote_file "#{node['nagios']['plugin_dir']}/notify_pagerduty.pl" do | |
+ owner 'root' | |
+ group 'root' | |
mode 00755 | |
source node['nagios']['pagerduty']['script_url'] | |
action :create_if_missing | |
@@ -51,8 +63,8 @@ end | |
nagios_conf 'pagerduty' | |
-cron "Flush Pagerduty" do | |
+cron 'Flush Pagerduty' do | |
user node['nagios']['user'] | |
- mailto "root@localhost" | |
- command "#{node['nagios']['plugin_dir']}/pagerduty_nagios.pl flush" | |
+ mailto 'root@localhost' | |
+ command "#{node['nagios']['plugin_dir']}/notify_pagerduty.pl flush" | |
end | |
diff --git a/recipes/server.rb b/recipes/server.rb | |
index 6c0db1a..4bedaf2 100644 | |
--- a/recipes/server.rb | |
+++ b/recipes/server.rb | |
@@ -7,7 +7,7 @@ | |
# Recipe:: server | |
# | |
# Copyright 2009, 37signals | |
-# Copyright 2009-2011, Opscode, Inc | |
+# Copyright 2009-2013, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
@@ -22,11 +22,11 @@ | |
# limitations under the License. | |
# install nrpe first so the nagios user is available before we template files using that user | |
-include_recipe "nagios::client" | |
+include_recipe 'nagios::client' | |
# workaround to allow for a nagios server install from source using the override attribute on debian/ubuntu (COOK-2350) | |
-if platform_family?('debian') && node['nagios']['server']['install_method'] == "source" | |
- nagios_service_name = "nagios" | |
+if platform_family?('debian') && node['nagios']['server']['install_method'] == 'source' | |
+ nagios_service_name = node['nagios']['server']['name'] | |
else | |
nagios_service_name = node['nagios']['server']['service_name'] | |
end | |
@@ -36,19 +36,19 @@ web_srv = node['nagios']['server']['web_server'].to_sym | |
case web_srv | |
when :nginx | |
- Chef::Log.info "Setting up Nagios server via NGINX" | |
+ Chef::Log.info 'Setting up Nagios server via NGINX' | |
include_recipe 'nagios::nginx' | |
- web_user = node["nginx"]["user"] | |
- web_group = node["nginx"]["group"] || web_user | |
+ web_user = node['nginx']['user'] | |
+ web_group = node['nginx']['group'] || web_user | |
when :apache | |
- Chef::Log.info "Setting up Nagios server via Apache2" | |
+ Chef::Log.info 'Setting up Nagios server via Apache2' | |
include_recipe 'nagios::apache' | |
- web_user = node["apache"]["user"] | |
- web_group = node["apache"]["group"] || web_user | |
+ web_user = node['apache']['user'] | |
+ web_group = node['apache']['group'] || web_user | |
else | |
- Chef::Log.fatal("Unknown web server option provided for Nagios server: " << | |
+ Chef::Log.fatal('Unknown web server option provided for Nagios server: ' << | |
"#{node['nagios']['server']['web_server']} provided. Allowed: :nginx or :apache") | |
- raise 'Unknown web server option provided for Nagios server' | |
+ fail 'Unknown web server option provided for Nagios server' | |
end | |
# find nagios web interface users from the defined data bag | |
@@ -62,34 +62,34 @@ rescue Net::HTTPServerException | |
end | |
case node['nagios']['server_auth_method'] | |
-when "openid" | |
+when 'openid' | |
if web_srv == :apache | |
- include_recipe "apache2::mod_auth_openid" | |
+ include_recipe 'apache2::mod_auth_openid' | |
else | |
- Chef::Log.fatal("OpenID authentication for Nagios is not supported on NGINX") | |
+ Chef::Log.fatal('OpenID authentication for Nagios is not supported on NGINX') | |
Chef::Log.fatal("Set node['nagios']['server_auth_method'] attribute in your role: #{node['nagios']['server_role']}") | |
- raise | |
+ fail | |
end | |
-when "cas" | |
+when 'cas' | |
if web_srv == :apache | |
- include_recipe "apache2::mod_auth_cas" | |
+ include_recipe 'apache2::mod_auth_cas' | |
else | |
- Chef::Log.fatal("CAS authentication for Nagios is not supported on NGINX") | |
+ Chef::Log.fatal('CAS authentication for Nagios is not supported on NGINX') | |
Chef::Log.fatal("Set node['nagios']['server_auth_method'] attribute in your role: #{node['nagios']['server_role']}") | |
- raise | |
+ fail | |
end | |
-when "ldap" | |
- if(web_srv == :apache) | |
- include_recipe "apache2::mod_authnz_ldap" | |
+when 'ldap' | |
+ if web_srv == :apache | |
+ include_recipe 'apache2::mod_authnz_ldap' | |
else | |
- Chef::Log.fatal("LDAP authentication for Nagios is not supported on NGINX") | |
+ Chef::Log.fatal('LDAP authentication for Nagios is not supported on NGINX') | |
Chef::Log.fatal("Set node['nagios']['server_auth_method'] attribute in your role: #{node['nagios']['server_role']}") | |
- raise | |
+ fail | |
end | |
else | |
directory node['nagios']['conf_dir'] | |
template "#{node['nagios']['conf_dir']}/htpasswd.users" do | |
- source "htpasswd.users.erb" | |
+ source 'htpasswd.users.erb' | |
owner node['nagios']['user'] | |
group web_group | |
mode 00640 | |
@@ -101,18 +101,18 @@ end | |
include_recipe "nagios::server_#{node['nagios']['server']['install_method']}" | |
# find nodes to monitor. Search in all environments if multi_environment_monitoring is enabled | |
-Chef::Log.info("Beginning search for nodes. This may take some time depending on your node count") | |
-nodes = Array.new | |
-hostgroups = Array.new | |
+Chef::Log.info('Beginning search for nodes. This may take some time depending on your node count') | |
+nodes = [] | |
+hostgroups = [] | |
if node['nagios']['multi_environment_monitoring'] | |
- nodes = search(:node, "hostname:[* TO *]") | |
+ nodes = search(:node, 'hostname:*') | |
else | |
- nodes = search(:node, "hostname:[* TO *] AND chef_environment:#{node.chef_environment}") | |
+ nodes = search(:node, "hostname:* AND chef_environment:#{node.chef_environment}") | |
end | |
if nodes.empty? | |
- Chef::Log.info("No nodes returned from search, using this node so hosts.cfg has data") | |
+ Chef::Log.info('No nodes returned from search, using this node so hosts.cfg has data') | |
nodes << node | |
end | |
@@ -120,8 +120,8 @@ end | |
nodes.sort! { |a, b| a.name <=> b.name } | |
# maps nodes into nagios hostgroups | |
-service_hosts= Hash.new | |
-search(:role, "*:*") do |r| | |
+service_hosts = {} | |
+search(:role, '*:*') do |r| | |
hostgroups << r.name | |
nodes.select { |n| n['roles'].include?(r.name) }.each do |n| | |
service_hosts[r.name] = n[node['nagios']['host_name_attribute']] | |
@@ -130,7 +130,7 @@ end | |
# if using multi environment monitoring add all environments to the array of hostgroups | |
if node['nagios']['multi_environment_monitoring'] | |
- search(:environment, "*:*") do |e| | |
+ search(:environment, '*:*') do |e| | |
hostgroups << e.name | |
nodes.select { |n| n.chef_environment == e.name }.each do |n| | |
service_hosts[e.name] = n[node['nagios']['host_name_attribute']] | |
@@ -140,9 +140,7 @@ end | |
# Add all unique platforms to the array of hostgroups | |
nodes.each do |n| | |
- if !hostgroups.include?(n['os']) | |
- hostgroups << n['os'] | |
- end | |
+ hostgroups << n['os'] unless hostgroups.include?(n['os']) | |
end | |
nagios_bags = NagiosDataBags.new | |
@@ -159,16 +157,14 @@ servicedependencies = nagios_bags.get('nagios_servicedependencies') | |
# Add unmanaged host hostgroups to the hostgroups array if they don't already exist | |
unmanaged_hosts.each do |host| | |
host['hostgroups'].each do |hg| | |
- if !hostgroups.include?(hg) | |
- hostgroups << hg | |
- end | |
+ hostgroups << hg unless hostgroups.include?(hg) | |
end | |
end | |
# Load search defined Nagios hostgroups from the nagios_hostgroups data bag and find nodes | |
-hostgroup_nodes= Hash.new | |
-hostgroup_list = Array.new | |
-if nagios_bags.bag_list.include?("nagios_hostgroups") | |
+hostgroup_nodes = {} | |
+hostgroup_list = [] | |
+if nagios_bags.bag_list.include?('nagios_hostgroups') | |
search(:nagios_hostgroups, '*:*') do |hg| | |
hostgroup_list << hg['hostgroup_name'] | |
temp_hostgroup_array = Array.new | |
@@ -181,12 +177,12 @@ if nagios_bags.bag_list.include?("nagios_hostgroups") | |
temp_hostgroup_array << n[node['nagios']['host_name_attribute']] | |
end | |
end | |
- hostgroup_nodes[hg['hostgroup_name']] = temp_hostgroup_array.join(",") | |
+ hostgroup_nodes[hg['hostgroup_name']] = temp_hostgroup_array.join(',') | |
end | |
end | |
# pick up base contacts | |
-members = Array.new | |
+members = [] | |
sysadmins.each do |s| | |
members << s['id'] | |
end | |
@@ -198,9 +194,8 @@ if node['nagios']['additional_contacts'] | |
end | |
end | |
-public_domain = node['public_domain'] || node['domain'] | |
- | |
-nagios_conf "nagios" do | |
+nagios_conf node['nagios']['server']['name'] do | |
+ source 'nagios.cfg.erb' | |
config_subdir false | |
end | |
@@ -222,9 +217,9 @@ directory "#{node['nagios']['state_dir']}/rw" do | |
mode 02710 | |
end | |
-execute "archive-default-nagios-object-definitions" do | |
- command "mv #{node['nagios']['config_dir']}/*_nagios*.cfg #{node['nagios']['conf_dir']}/dist" | |
- not_if { Dir.glob("#{node['nagios']['config_dir']}/*_nagios*.cfg").empty? } | |
+execute 'archive-default-nagios-object-definitions' do | |
+ command "mv #{node['nagios']['config_dir']}/*_#{node['nagios']['server']['name']}*.cfg #{node['nagios']['conf_dir']}/dist" | |
+ not_if { Dir.glob("#{node['nagios']['config_dir']}/*_#{node['nagios']['server']['name']}*.cfg").empty? } | |
end | |
directory "#{node['nagios']['conf_dir']}/certificates" do | |
@@ -233,7 +228,7 @@ directory "#{node['nagios']['conf_dir']}/certificates" do | |
mode 00700 | |
end | |
-bash "Create SSL Certificates" do | |
+bash 'Create SSL Certificates' do | |
cwd "#{node['nagios']['conf_dir']}/certificates" | |
code <<-EOH | |
umask 077 | |
@@ -241,39 +236,43 @@ bash "Create SSL Certificates" do | |
openssl req -subj "#{node['nagios']['ssl_req']}" -new -x509 -nodes -sha1 -days 3650 -key nagios-server.key > nagios-server.crt | |
cat nagios-server.key nagios-server.crt > nagios-server.pem | |
EOH | |
- not_if { ::File.exists?("#{node['nagios']['ssl_cert_file']}") } | |
+ not_if { ::File.exists?(node['nagios']['ssl_cert_file']) } | |
end | |
-%w{ nagios cgi }.each do |conf| | |
- nagios_conf conf do | |
+nagios_conf node['nagios']['server']['name'] do | |
config_subdir false | |
+ source 'nagios.cfg.erb' | |
variables(:nagios_service_name => nagios_service_name) | |
end | |
+ | |
+nagios_conf 'cgi' do | |
+ config_subdir false | |
+ variables(:nagios_service_name => nagios_service_name) | |
end | |
-nagios_conf "timeperiods" | |
+nagios_conf 'timeperiods' | |
-nagios_conf "templates" do | |
+nagios_conf 'templates' do | |
variables(:templates => templates) | |
end | |
-nagios_conf "commands" do | |
+nagios_conf 'commands' do | |
variables(:services => services, | |
:eventhandlers => eventhandlers) | |
end | |
-nagios_conf "services" do | |
+nagios_conf 'services' do | |
variables(:service_hosts => service_hosts, | |
:services => services, | |
:search_hostgroups => hostgroup_list, | |
:hostgroups => hostgroups) | |
end | |
-nagios_conf "servicegroups" do | |
+nagios_conf 'servicegroups' do | |
variables(:servicegroups => servicegroups) | |
end | |
-nagios_conf "contacts" do | |
+nagios_conf 'contacts' do | |
variables(:admins => sysadmins, | |
:members => members, | |
:contacts => contacts, | |
@@ -281,30 +280,30 @@ nagios_conf "contacts" do | |
:serviceescalations => serviceescalations) | |
end | |
-nagios_conf "hostgroups" do | |
+nagios_conf 'hostgroups' do | |
variables(:hostgroups => hostgroups, | |
:search_hostgroups => hostgroup_list, | |
:search_nodes => hostgroup_nodes) | |
end | |
-nagios_conf "hosts" do | |
+nagios_conf 'hosts' do | |
variables(:nodes => nodes, | |
:unmanaged_hosts => unmanaged_hosts, | |
:hostgroups => hostgroups) | |
end | |
-nagios_conf "servicedependencies" do | |
+nagios_conf 'servicedependencies' do | |
variables(:servicedependencies => servicedependencies) | |
end | |
-service "nagios" do | |
+service 'nagios' do | |
service_name nagios_service_name | |
supports :status => true, :restart => true, :reload => true | |
action [:enable, :start] | |
end | |
# Add the NRPE check to monitor the Nagios server | |
-nagios_nrpecheck "check_nagios" do | |
+nagios_nrpecheck 'check_nagios' do | |
command "#{node['nagios']['plugin_dir']}/check_nagios" | |
parameters "-F #{node["nagios"]["cache_dir"]}/status.dat -e 4 -C /usr/sbin/#{nagios_service_name}" | |
action :add | |
diff --git a/recipes/server_package.rb b/recipes/server_package.rb | |
index a028086..df0a7e7 100644 | |
--- a/recipes/server_package.rb | |
+++ b/recipes/server_package.rb | |
@@ -3,7 +3,7 @@ | |
# Cookbook Name:: nagios | |
# Recipe:: server_package | |
# | |
-# Copyright 2011, Opscode, Inc | |
+# Copyright 2011-2013, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
@@ -25,18 +25,14 @@ if node['platform_family'] == 'debian' | |
random_initial_password = rand(36**16).to_s(36) | |
%w{adminpassword adminpassword-repeat}.each do |setting| | |
- execute "preseed nagiosadmin password" do | |
- command "echo nagios3-cgi nagios3/#{setting} password #{random_initial_password} | debconf-set-selections" | |
- not_if 'dpkg -l nagios3' | |
+ execute "debconf-set-selections::#{node['nagios']['server']['vname']}-cgi::#{node['nagios']['server']['vname']}/#{setting}" do | |
+ command "echo #{node['nagios']['server']['vname']}-cgi #{node['nagios']['server']['vname']}/#{setting} password #{random_initial_password} | debconf-set-selections" | |
+ not_if "dpkg -l #{node['nagios']['server']['vname']}" | |
end | |
end | |
end | |
-%w{ | |
- nagios3 | |
- nagios-nrpe-plugin | |
- nagios-images | |
-}.each do |pkg| | |
+node['nagios']['server']['packages'].each do |pkg| | |
package pkg | |
end | |
diff --git a/recipes/server_source.rb b/recipes/server_source.rb | |
index 705f26d..e1f779d 100644 | |
--- a/recipes/server_source.rb | |
+++ b/recipes/server_source.rb | |
@@ -3,7 +3,7 @@ | |
# Cookbook Name:: nagios | |
# Recipe:: server_source | |
# | |
-# Copyright 2011, Opscode, Inc | |
+# Copyright 2011-2013, Opscode, Inc | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
@@ -20,23 +20,23 @@ | |
# Package pre-reqs | |
-include_recipe "build-essential" | |
-include_recipe "php" | |
-include_recipe "php::module_gd" | |
+include_recipe 'build-essential' | |
+include_recipe 'php' | |
+include_recipe 'php::module_gd' | |
web_srv = node['nagios']['server']['web_server'].to_sym | |
case web_srv | |
when :apache | |
- include_recipe "nagios::apache" | |
+ include_recipe 'nagios::apache' | |
else | |
- include_recipe "nagios::nginx" | |
+ include_recipe 'nagios::nginx' | |
end | |
pkgs = value_for_platform_family( | |
- [ "rhel","fedora" ] => %w{ openssl-devel gd-devel tar }, | |
- "debian" => %w{ libssl-dev libgd2-xpm-dev bsd-mailx tar }, | |
- "default" => %w{ libssl-dev libgd2-xpm-dev bsd-mailx tar } | |
+ %w{ rhel fedora } => %w{ openssl-devel gd-devel tar }, | |
+ 'debian' => %w{ libssl-dev libgd2-xpm-dev bsd-mailx tar }, | |
+ 'default' => %w{ libssl-dev libgd2-xpm-dev bsd-mailx tar } | |
) | |
pkgs.each do |pkg| | |
@@ -55,21 +55,21 @@ end | |
version = node['nagios']['server']['version'] | |
-remote_file "#{Chef::Config[:file_cache_path]}/nagios-#{version}.tar.gz" do | |
- source "#{node['nagios']['server']['url']}/nagios-#{version}.tar.gz" | |
+remote_file "#{Chef::Config[:file_cache_path]}/#{node['nagios']['server']['name']}-#{version}.tar.gz" do | |
+ source "#{node['nagios']['server']['url']}/#{node['nagios']['server']['name']}-#{version}.tar.gz" | |
checksum node['nagios']['server']['checksum'] | |
action :create_if_missing | |
end | |
-bash "compile-nagios" do | |
+bash 'compile-nagios' do | |
cwd Chef::Config[:file_cache_path] | |
code <<-EOH | |
- tar zxvf nagios-#{version}.tar.gz | |
- cd nagios | |
+ tar zxvf #{node['nagios']['server']['name']}-#{version}.tar.gz | |
+ cd #{node['nagios']['server']['src_dir']} | |
./configure --prefix=/usr \ | |
--mandir=/usr/share/man \ | |
--bindir=/usr/sbin \ | |
- --sbindir=/usr/lib/cgi-bin/nagios3 \ | |
+ --sbindir=/usr/lib/cgi-bin/#{node['nagios']['server']['vname']} \ | |
--datadir=#{node['nagios']['docroot']} \ | |
--sysconfdir=#{node['nagios']['conf_dir']} \ | |
--infodir=/usr/share/info \ | |
@@ -81,23 +81,23 @@ bash "compile-nagios" do | |
--with-command-user=#{node['nagios']['user']} \ | |
--with-command-group=#{node['nagios']['group']} \ | |
--with-init-dir=/etc/init.d \ | |
- --with-lockfile=#{node['nagios']['run_dir']}/nagios3.pid \ | |
+ --with-lockfile=#{node['nagios']['run_dir']}/#{node['nagios']['server']['vname']}.pid \ | |
--with-mail=/usr/bin/mail \ | |
--with-perlcache \ | |
- --with-htmurl=/nagios3 \ | |
- --with-cgiurl=/cgi-bin/nagios3 | |
+ --with-htmurl=/#{node['nagios']['server']['vname']} \ | |
+ --with-cgiurl=/cgi-bin/#{node['nagios']['server']['vname']} | |
make all | |
make install | |
make install-init | |
make install-config | |
make install-commandmode | |
EOH | |
- creates "/usr/sbin/nagios" | |
+ creates "/usr/sbin/#{node['nagios']['server']['name']}" | |
end | |
-directory "#{node['nagios']['conf_dir']}/conf.d" do | |
- owner "root" | |
- group "root" | |
+directory node['nagios']['config_dir'] do | |
+ owner 'root' | |
+ group 'root' | |
mode 00755 | |
end | |
@@ -111,7 +111,7 @@ end | |
end | |
-directory "/usr/lib/nagios3" do | |
+directory "/usr/lib/#{node['nagios']['server']['vname']}" do | |
owner node['nagios']['user'] | |
group node['nagios']['group'] | |
mode 00755 | |
@@ -122,14 +122,14 @@ link "#{node['nagios']['conf_dir']}/stylesheets" do | |
end | |
# if nrpe client is not being installed by source then we need the NRPE plugin | |
-if node['nagios']['client']['install_method'] == "package" | |
+if node['nagios']['client']['install_method'] == 'package' | |
- include_recipe "nagios::nrpe_source" | |
+ include_recipe 'nagios::nrpe_source' | |
end | |
if web_srv == :apache | |
- apache_module "cgi" do | |
+ apache_module 'cgi' do | |
enable :true | |
end | |
end | |
diff --git a/spec/client_spec.rb b/spec/client_spec.rb | |
index b068b92..65d2b43 100644 | |
--- a/spec/client_spec.rb | |
+++ b/spec/client_spec.rb | |
@@ -6,18 +6,16 @@ describe 'nagios::client' do | |
it 'adds addresses to the allowed hosts when defined' do | |
Chef::Recipe.any_instance.stub(:search) | |
- chef_run = runner({ | |
- :nagios => { | |
- :allowed_hosts => %w(test.host) | |
- } | |
- }).converge 'nagios::client' | |
+ chef_run = runner( | |
+ :nagios => { :allowed_hosts => %w(test.host) } | |
+ ).converge 'nagios::client' | |
expect(chef_run).to create_file_with_content "#{chef_run.node['nagios']['nrpe']['conf_dir']}/nrpe.cfg", 'allowed_hosts=127.0.0.1,test.host' | |
end | |
it 'does not blow up when the search returns no results' do | |
- Chef::REST.any_instance.stub(:get_rest).and_return({"rows"=>[], "start"=>0, "total"=>0}) | |
+ Chef::REST.any_instance.stub(:get_rest).and_return('rows' => [], 'start' => 0, 'total' => 0) | |
- lambda { chef_run }.should_not raise_error | |
+ expect { chef_run }.to_not raise_error | |
end | |
end | |
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb | |
index 028aa55..d305614 100644 | |
--- a/spec/spec_helper.rb | |
+++ b/spec/spec_helper.rb | |
@@ -1,10 +1,13 @@ | |
require 'chefspec' | |
+require 'berkshelf' | |
+ | |
+Berkshelf.ui.mute do | |
+ Berkshelf::Berksfile.from_file('Berksfile').install(path: 'vendor/cookbooks/') | |
+end | |
def runner(attributes = {}, environment = 'test') | |
- cookbook_paths = %W(#{File.expand_path("..", Dir.pwd)} #{File.expand_path(Dir.pwd)}/cookbooks) | |
- | |
# A workaround so that ChefSpec can work with Chef environments (from https://github.com/acrmp/chefspec/issues/54) | |
- @runner ||= ChefSpec::ChefRunner.new(:cookbook_path => cookbook_paths, :platform => 'ubuntu', :version => '10.04') do |node| | |
+ @runner ||= ChefSpec::ChefRunner.new(:platform => 'ubuntu', :version => '10.04') do |node| | |
env = Chef::Environment.new | |
env.name environment | |
node.stub(:chef_environment).and_return env.name | |
diff --git a/templates/default/apache2.conf.erb b/templates/default/apache2.conf.erb | |
index e611b87..6687677 100644 | |
--- a/templates/default/apache2.conf.erb | |
+++ b/templates/default/apache2.conf.erb | |
@@ -6,18 +6,18 @@ | |
ServerName <%= @nagios_url %> | |
<% else %> | |
ServerName <%= node['fqdn'] %> | |
- ServerAlias nagios nagios.<%= node.chef_environment =~ /^_default$/ ? "default" : node.chef_environment%>.<%= @public_domain %> | |
+ ServerAlias <%= node['nagios']['server']['name'] %> <%= node['nagios']['server']['name'] %>.<%= node.chef_environment =~ /^_default$/ ? "default" : node.chef_environment%>.<%= @public_domain %> | |
<% end %> | |
DocumentRoot <%= node['nagios']['docroot'] %> | |
CustomLog <%= node['nagios']['log_dir'] %>/apache_access.log combined | |
ErrorLog <%= node['nagios']['log_dir'] %>/apache_error.log | |
- ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3 | |
- ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3 | |
+ ScriptAlias /cgi-bin/<%= node['nagios']['server']['vname'] %> /usr/lib/cgi-bin/<%= node['nagios']['server']['vname'] %> | |
+ ScriptAlias /<%= node['nagios']['server']['vname'] %>/cgi-bin /usr/lib/cgi-bin/<%= node['nagios']['server']['vname'] %> | |
- Alias /stylesheets /etc/nagios3/stylesheets | |
- Alias /nagios3/stylesheets /etc/nagios3/stylesheets | |
- Alias /nagios3 <%= node['nagios']['docroot'] %> | |
+ Alias /stylesheets /etc/<%= node['nagios']['server']['vname'] %>/stylesheets | |
+ Alias /<%= node['nagios']['server']['vname'] %>/stylesheets /etc/<%= node['nagios']['server']['vname'] %>/stylesheets | |
+ Alias /<%= node['nagios']['server']['vname'] %> <%= node['nagios']['docroot'] %> | |
<% if @https -%> | |
SSLEngine On | |
@@ -70,7 +70,7 @@ | |
RewriteEngine On | |
<% if node['nagios']['server']['redirect_root'] -%> | |
- RewriteRule ^/$ /nagios3 [R=301,L] | |
+ RewriteRule ^/$ /<%= node['nagios']['server']['vname'] %> [R=301,L] | |
<% end -%> | |
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/ | |
RewriteRule ^(.*)index\.html$ $1 [R=301,L] | |
diff --git a/templates/default/cgi.cfg.erb b/templates/default/cgi.cfg.erb | |
index d2a4a95..554c80c 100644 | |
--- a/templates/default/cgi.cfg.erb | |
+++ b/templates/default/cgi.cfg.erb | |
@@ -5,7 +5,7 @@ | |
# The CGIs will read the main and host config files for any other | |
# data they might need. | |
-main_config_file=<%= node['nagios']['conf_dir'] %>/nagios.cfg | |
+main_config_file=<%= node['nagios']['conf_dir'] %>/<%= node['nagios']['server']['name'] %>.cfg | |
# PHYSICAL HTML PATH | |
# This is the path where the HTML files for Nagios reside. This | |
@@ -22,7 +22,7 @@ physical_html_path=<%= node['nagios']['docroot'] %> | |
# http://www.myhost.com/nagios, this value should be '/nagios' | |
# (without the quotes). | |
-url_html_path=/nagios3 | |
+url_html_path=/<%= node['nagios']['server']['vname'] %> | |
# CONTEXT-SENSITIVE HELP | |
# This option determines whether or not a context-sensitive | |
@@ -47,7 +47,7 @@ show_context_help=1 | |
# have to be tweaked a bit, as different versions of the plugin | |
# use different command line arguments/syntaxes. | |
-nagios_check_command=<%= node['nagios']['plugin_dir'] %>/check_nagios <%= node['nagios']['cache_dir'] %>/status.dat 5 '/usr/sbin/<%= @nagios_service_name %>' | |
+<%= node['nagios']['server']['name'] %>_check_command=<%= node['nagios']['plugin_dir'] %>/check_nagios <%= node['nagios']['cache_dir'] %>/status.dat 5 '/usr/sbin/<%= @nagios_service_name %>' | |
# AUTHENTICATION USAGE | |
# This option controls whether or not the CGIs will use any | |
diff --git a/templates/default/hostgroups.cfg.erb b/templates/default/hostgroups.cfg.erb | |
index cf3ba26..2ad846e 100644 | |
--- a/templates/default/hostgroups.cfg.erb | |
+++ b/templates/default/hostgroups.cfg.erb | |
@@ -5,12 +5,11 @@ | |
define hostgroup { | |
hostgroup_name all | |
alias all | |
- <% if node['nagios']['regexp_matching'] == 1 || node['nagios']['true_regexp_matching'] == 1 -%> | |
+<% if node['nagios']['regexp_matching'] == 1 -%> | |
members .* | |
<% else -%> | |
members * | |
<% end -%> | |
- | |
} | |
<% @hostgroups.sort.each do |h| -%> | |
diff --git a/templates/default/hosts.cfg.erb b/templates/default/hosts.cfg.erb | |
index b249940..fd3133e 100644 | |
--- a/templates/default/hosts.cfg.erb | |
+++ b/templates/default/hosts.cfg.erb | |
@@ -7,7 +7,7 @@ define host { | |
use server | |
address <%= node['ipaddress'] %> | |
host_name <%= node['nagios']['server']['normalize_hostname'] ? node[node['nagios']['host_name_attribute']].downcase : node[node['nagios']['host_name_attribute']] %> | |
- hostgroups <% if node['nagios']['multi_environment_monitoring'] -%><%= node.chef_environment %>,<% end -%>all,<%= node['os'] %>,<%= node['roles'].join(",") %><% if !node['roles'].include?(node['nagios']['server_role']) %>,<%= node['nagios']['server_role'] %><% end -%> | |
+ hostgroups <% if node['nagios']['multi_environment_monitoring'] -%><%= node.chef_environment %>,<% end -%>all,<%= node['os'] %>,<%= node['roles'].sort.join(",") %><% if !node['roles'].include?(node['nagios']['server_role']) %>,<%= node['nagios']['server_role'] %><% end -%> | |
} | |
<% @nodes.each do |n| -%> | |
@@ -34,13 +34,13 @@ define host { | |
<% if n['roles'].nil? || n['roles'].length == 0 -%> | |
hostgroups all,<%= n['os'] %>, <%= n.chef_environment %> | |
<% else -%> | |
- hostgroups all,<%= (n['roles'] & @hostgroups).join(",") %>,<%= n['os'] %>, <%= n.chef_environment %> | |
+ hostgroups all,<%= (n['roles'] & @hostgroups).sort.join(",") %>,<%= n['os'] %>, <%= n.chef_environment %> | |
<% end -%> | |
<% elsif -%> | |
<% if n['roles'].nil? || n['roles'].length == 0 -%> | |
hostgroups all,<%= n['os'] %> | |
<% else -%> | |
- hostgroups all,<%= (n['roles'] & @hostgroups).join(",") %>,<%= n['os'] %> | |
+ hostgroups all,<%= (n['roles'] & @hostgroups).sort.join(",") %>,<%= n['os'] %> | |
<% end -%> | |
<% end -%> | |
} | |
diff --git a/templates/default/nagios.cfg.erb b/templates/default/nagios.cfg.erb | |
index 7f9de2c..1f4cd73 100644 | |
--- a/templates/default/nagios.cfg.erb | |
+++ b/templates/default/nagios.cfg.erb | |
@@ -1,6 +1,6 @@ | |
# Autogenerated by Chef. | |
-log_file=<%= node['nagios']['log_dir'] %>/nagios.log | |
+log_file=<%= node['nagios']['log_dir'] %>/<%= node['nagios']['server']['name'] %>.log | |
admin_email=<%= node['nagios']['sysadmin_email'] %> | |
admin_pager=<%= node['nagios']['sysadmin_sms_email'] %> | |
@@ -13,17 +13,17 @@ precached_object_file=<%= node['nagios']['cache_dir'] %>/objects.precache | |
resource_file=<%= node['nagios']['conf_dir'] %>/resource.cfg | |
status_file=<%= node['nagios']['cache_dir'] %>/status.dat | |
status_update_interval=10 | |
-nagios_user=<%= node['nagios']['user'] %> | |
-nagios_group=<%= node['nagios']['group'] %> | |
+<%= node['nagios']['server']['name'] %>_user=<%= node['nagios']['user'] %> | |
+<%= node['nagios']['server']['name'] %>_group=<%= node['nagios']['group'] %> | |
check_external_commands=<%= nagios_boolean(node['nagios']['check_external_commands']) %> | |
# NOTE: Setting this value to -1 causes Nagios to check the external command file as often as possible. | |
command_check_interval=-1 | |
-command_file=<%= node['nagios']['state_dir'] %>/rw/nagios.cmd | |
+command_file=<%= node['nagios']['state_dir'] %>/rw/<%= node['nagios']['server']['name'] %>.cmd | |
external_command_buffer_slots=4096 | |
-lock_file=<%= node['nagios']['run_dir'] %>/nagios3.pid | |
-temp_file=<%= node['nagios']['cache_dir'] %>/nagios.tmp | |
+lock_file=<%= node['nagios']['run_dir'] %>/<%= node['nagios']['server']['vname'] %>.pid | |
+temp_file=<%= node['nagios']['cache_dir'] %>/<%= node['nagios']['server']['name'] %>.tmp | |
temp_path=/tmp | |
event_broker_options=-1 | |
@@ -139,7 +139,7 @@ illegal_object_name_chars=`~!$%^&*|'"<>?,()= | |
illegal_macro_output_chars=`~$&|'"<> | |
use_regexp_matching=<%= node['nagios']['regexp_matching'] %> | |
-use_true_regexp_matching=<%= node['nagios']['true_regexp_matching'] %> | |
+use_true_regexp_matching=0 | |
daemon_dumps_core=0 | |
@@ -152,5 +152,5 @@ enable_environment_macros=1 | |
debug_level=0 | |
debug_verbosity=1 | |
-debug_file=<% node["nagios"]["state_dir"] %>/nagios.debug | |
+debug_file=<% node["nagios"]["state_dir"] %>/<%= node['nagios']['server']['name'] %>.debug | |
max_debug_file_size=1000000 | |
diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb | |
index 561b3de..a86ac9b 100644 | |
--- a/templates/default/nginx.conf.erb | |
+++ b/templates/default/nginx.conf.erb | |
@@ -4,7 +4,7 @@ server { | |
<% if @nagios_url %> | |
server_name <%= @nagios_url %>; | |
<% else %> | |
- server_name nagios nagios.<%= @chef_env %>.<%= @public_domain %> <%= @fqdn %>; | |
+ server_name <%= node['nagios']['server']['name'] %> <%= node['nagios']['server']['name'] %>.<%= @chef_env %>.<%= @public_domain %> <%= @fqdn %>; | |
<% end %> | |
access_log <%= File.join(@log_dir, 'nginx_access.log') %>; | |
error_log <%= File.join(@log_dir, 'nginx_error.log') %>; | |
@@ -45,11 +45,11 @@ nginx_dispatch(:php, | |
%> | |
<% end %> | |
- location /nagios3/stylesheets { | |
- alias /etc/nagios3/stylesheets; | |
+ location /<%= node['nagios']['server']['vname'] %>/stylesheets { | |
+ alias /etc/<%= node['nagios']['server']['vname'] %>/stylesheets; | |
} | |
- location /nagios3 { | |
+ location /<%= node['nagios']['server']['vname'] %> { | |
alias <%= @docroot %>; | |
} | |
diff --git a/templates/default/pagerduty.cfg.erb b/templates/default/pagerduty.cfg.erb | |
index b028811..43a7e0f 100644 | |
--- a/templates/default/pagerduty.cfg.erb | |
+++ b/templates/default/pagerduty.cfg.erb | |
@@ -7,19 +7,19 @@ define contact { | |
alias PagerDuty Pseudo-Contact | |
service_notification_period 24x7 | |
host_notification_period 24x7 | |
- service_notification_options w,u,c,r | |
- host_notification_options d,r | |
+ service_notification_options <%= node["nagios"]["pagerduty"]["service_notification_options"] %> | |
+ host_notification_options <%= node["nagios"]["pagerduty"]["host_notification_options"] %> | |
service_notification_commands notify-service-by-pagerduty | |
host_notification_commands notify-host-by-pagerduty | |
- pager <%= node["nagios"]["pagerduty_key"] %> | |
+ pager <%= node["nagios"]["pagerduty"]["key"] %> | |
} | |
define command { | |
command_name notify-service-by-pagerduty | |
- command_line <%= node['nagios']['plugin_dir'] %>/pagerduty_nagios.pl enqueue -f pd_nagios_object=service | |
+ command_line <%= node['nagios']['plugin_dir'] %>/notify_pagerduty.pl enqueue -f pd_nagios_object=service | |
} | |
define command { | |
command_name notify-host-by-pagerduty | |
- command_line <%= node['nagios']['plugin_dir'] %>/pagerduty_nagios.pl enqueue -f pd_nagios_object=host | |
+ command_line <%= node['nagios']['plugin_dir'] %>/notify_pagerduty.pl enqueue -f pd_nagios_object=host | |
} | |
diff --git a/templates/default/templates.cfg.erb b/templates/default/templates.cfg.erb | |
index 1ff1431..d69f0fa 100644 | |
--- a/templates/default/templates.cfg.erb | |
+++ b/templates/default/templates.cfg.erb | |
@@ -43,13 +43,13 @@ define host { | |
define host { | |
name server | |
use default-host | |
- check_period 24x7 | |
+ check_period <%= nagios_attr(:default_host)[:check_period] %> | |
check_interval <%= nagios_interval(nagios_attr(:default_host)[:check_interval]) %> | |
retry_interval <%= nagios_interval(nagios_attr(:default_host)[:retry_interval]) %> | |
max_check_attempts <%= nagios_attr(:default_host)[:max_check_attempts] %> | |
- check_command check-host-alive | |
+ check_command <%= nagios_attr(:default_host)[:check_command] %> | |
notification_interval <%= nagios_interval(nagios_attr(:default_host)[:notification_interval]) %> | |
- notification_options d,u,r | |
+ notification_options <%= nagios_attr(:default_host)[:notification_options] %> | |
contact_groups <%= nagios_attr(:default_contact_groups).join(",") %> | |
register 0 | |
} | |
diff --git a/test/kitchen/Kitchenfile b/test/kitchen/Kitchenfile | |
deleted file mode 100644 | |
index 8a61779..0000000 | |
--- a/test/kitchen/Kitchenfile | |
+++ /dev/null | |
@@ -1,3 +0,0 @@ | |
-cookbook "nagios" do | |
- runtimes [] | |
-end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment