OSDN Git Service

add nagios-grid cookbook. nagios-grid-0.1.0
authorwhitestar <whitestar@gaea.test>
Wed, 17 Aug 2016 11:41:05 +0000 (20:41 +0900)
committerwhitestar <whitestar@gaea.test>
Wed, 17 Aug 2016 11:41:05 +0000 (20:41 +0900)
30 files changed:
cookbooks/nagios-grid/.rubocop.yml [new file with mode: 0644]
cookbooks/nagios-grid/CHANGELOG.md [new file with mode: 0644]
cookbooks/nagios-grid/Gemfile [new file with mode: 0644]
cookbooks/nagios-grid/README.md [new file with mode: 0644]
cookbooks/nagios-grid/Rakefile [new file with mode: 0644]
cookbooks/nagios-grid/attributes/default.rb [new file with mode: 0644]
cookbooks/nagios-grid/metadata.rb [new file with mode: 0644]
cookbooks/nagios-grid/recipes/default.rb [new file with mode: 0644]
cookbooks/nagios-grid/recipes/nagios-base.rb [new file with mode: 0644]
cookbooks/nagios-grid/recipes/nagios-nrpe-server.rb [new file with mode: 0644]
cookbooks/nagios-grid/spec/recipes/default_spec.rb [new file with mode: 0644]
cookbooks/nagios-grid/spec/spec_helper.rb [new file with mode: 0644]
cookbooks/nagios-grid/templates/centos/etc/httpd/conf.d/nagios.conf [new file with mode: 0644]
cookbooks/nagios-grid/templates/centos/etc/nagios/cgi.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/centos/etc/nagios/nagios.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios/check_logs/check_logs.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios/nrpe_local.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/apache2.conf [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/base/checkcommands-generic.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/base/hosts-generic.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/base/services-generic.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/cgi.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/nagios.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/site/checkcommands.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/site/contacts.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/site/hosts.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/site/services.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios3/site/timeperiods.cfg [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/usr/lib/nagios/plugins/check_logs.pl [new file with mode: 0755]
cookbooks/nagios-grid/templates/default/usr/lib/nagios/plugins/check_smart.pl [new file with mode: 0755]

diff --git a/cookbooks/nagios-grid/.rubocop.yml b/cookbooks/nagios-grid/.rubocop.yml
new file mode 100644 (file)
index 0000000..e833998
--- /dev/null
@@ -0,0 +1,30 @@
+AllCops:
+  Exclude:
+    - vendor/**/*
+
+AlignParameters:
+  Enabled: false
+LineLength:
+  Enabled: false
+Lint/UnusedBlockArgument:
+  Enabled: false
+Metrics/AbcSize:
+  Enabled: false
+SingleSpaceBeforeFirstArg:
+  Enabled: false
+Style/BlockComments:
+  Enabled: false
+Style/BlockDelimiters:
+  Enabled: false
+Style/ExtraSpacing:
+  Enabled: false
+Style/FileName:
+  Enabled: false
+Style/LeadingCommentSpace:
+  Enabled: false
+Style/RescueModifier:
+  Enabled: false
+Style/WordArray:
+  Enabled: false
+TrailingComma:
+  EnforcedStyleForMultiline: comma
diff --git a/cookbooks/nagios-grid/CHANGELOG.md b/cookbooks/nagios-grid/CHANGELOG.md
new file mode 100644 (file)
index 0000000..b61fe10
--- /dev/null
@@ -0,0 +1,6 @@
+nagios-grid CHANGELOG
+=====================
+
+0.1.0
+-----
+- Initial release of nagios-grid
diff --git a/cookbooks/nagios-grid/Gemfile b/cookbooks/nagios-grid/Gemfile
new file mode 100644 (file)
index 0000000..907b097
--- /dev/null
@@ -0,0 +1,3 @@
+source 'https://rubygems.org'
+
+#gem 'foodcritic'
diff --git a/cookbooks/nagios-grid/README.md b/cookbooks/nagios-grid/README.md
new file mode 100644 (file)
index 0000000..7f72233
--- /dev/null
@@ -0,0 +1,108 @@
+nagios-grid Cookbook
+====================
+
+This cookbook provides some recipes for Nagios setup.
+
+Requirements
+------------
+
+None.
+
+Attributes
+----------
+
+|Key|Type|Description, example|Default|
+|:--|:--|:--|:--|
+|`['nagios']['base_cfg_dir']`|String|base conf. directory.|`'base'`|
+|`['nagios']['site_cfg_dir']`|String|site conf. directory.|`'site'`|
+|`['nagios']['autostart']`|Boolean||`true`|
+|`['nagios']['autoreload']`|Boolean||`true`|
+|`['nagios']['with_pnp4nagios']`|Boolean||`false`|
+|`['nagios']['check_external_commands']`|String|check_external_commands property in nagios.cfg|`'0'`|
+|`['nagios']['command_file']`|String|command_file property in nagios.cfg|see default.rb|
+|`['nagios']['use_regexp_matching']`|String|use_regexp_matching property in nagios.cfg|`'0'`|
+|`['nagios']['cgi']['authorized_for_system_information']`|String|CGI authorization property.|`'nagiosadmin'`|
+|`['nagios']['cgi']['authorized_for_configuration_information']`|String|CGI authorization property.|`'nagiosadmin'`|
+|`['nagios']['cgi']['authorized_for_system_commands']`|String|CGI authorization property.|`'nagiosadmin'`|
+|`['nagios']['cgi']['authorized_for_all_services']`|String|CGI authorization property.|`'nagiosadmin'`|
+|`['nagios']['cgi']['authorized_for_all_hosts']`|String|CGI authorization property.|`'nagiosadmin'`|
+|`['nagios']['cgi']['authorized_for_all_service_commands']`|String|CGI authorization property.|`'nagiosadmin'`|
+|`['nagios']['cgi']['authorized_for_all_host_commands']`|String|CGI authorization property.|`'nagiosadmin'`|
+|`['nagios']['cgi']['result_limit']`|String|result set limitation.|`'100'`|
+|`['nagios']['web']['Require']`|Array|Apache >= 2.3|`['all granted',]`|
+|`['nagios']['web']['Order']`|String|Apache < 2.3|`'Allow,Deny'`|
+|`['nagios']['web']['Deny']`|Array|Apache < 2.3|`[]`|
+|`['nagios']['web']['Allow']`|Array|Apache < 2.3|`['From All',]`|
+|`['nagios']['web']['AuthType']`|String|'none' or 'Basic' or 'Kerberos'|`'Basic'`|
+|`['nagios']['web']['mod_auth_basic']['AuthUserFile']`|String||see default.rb|
+|`['nagios']['web']['mod_auth_kerb']['KrbAuthRealms']`|String||`'LOCALDOMAIN'`|
+|`['nagios']['web']['mod_auth_kerb']['KrbServiceName']`|String||`'HTTP'`|
+|`['nagios']['web']['mod_auth_kerb']['Krb5Keytab']`|String||`'/etc/krb5.keytab'`|
+|`['nagios']['web']['mod_auth_kerb']['KrbMethodNegotiate']`|String||`'on'`|
+|`['nagios']['web']['mod_auth_kerb']['KrbMethodK5Passwd']`|String||`'off'`|
+|`['nagios']['objects']['default_contact_groups']`|String||`'admins'`|
+|`['nagios']['objects']['check_ldap']['base']`|String||`'dc=example,dc=com'`|
+|`['nagios']['objects']['commands']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['hosts']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['hostgroups']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['hostdependencies']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['hostescalations']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['hostextinfos']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['services']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['servicegroups']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['servicedependencies']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['serviceescalations']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['serviceextinfos']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['contacts']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['contactgroups']`|Array|for full customization.|`[]`|
+|`['nagios']['objects']['timeperiods']`|Array|for full customization.|`[]`|
+|`['nagios']['NagAconda']['version']`|String|for check_ganglia_metric|`'0.1.4'`|
+|`['nagios']['check_ganglia_metric']['enabled']`|Boolean||`false`|
+|`['nagios']['check_ganglia_metric']['gmetad_host']`|String||`'localhost'`|
+|`['nagios']['nrpe']['allowed_hosts']`|String||`'127.0.0.1'`|
+|`['nagios']['nrpe']['with_smartmontools']`|Boolean||`false`|
+|`['nagios']['nrpe']['check_total_procs']['warn']`|String||`'100'`|
+|`['nagios']['nrpe']['check_total_procs']['crit']`|String||`'200'`|
+|`['nagios']['nrpe']['check_disk#{(0..3)}']['warn']`|String||`'20%'`|
+|`['nagios']['nrpe']['check_disk#{(0..3)}']['crit']`|String||`'10%'`|
+|`['nagios']['nrpe']['check_disk#{(0..3)}']['path']`|String||`'/'`|
+|`['nagios']['nrpe']['check_disk#{(0..3)}']['extra_opts']`|String||`''`|
+|`['nagios']['nrpe']['check_smart#{(0..3)}']['device']`|String||`'/dev/sda'`|
+|`['nagios']['nrpe']['check_dig']['host']`|String||`'127.0.0.1'`|
+|`['nagios']['nrpe']['check_dig']['lookup']`|String||`'host-a.example.com'`|
+|`['nagios']['nrpe']['check_dig_in']['host']`|String||`'127.0.0.1'`|
+|`['nagios']['nrpe']['check_dig_in']['lookup']`|String||`'host-b.example.com'`|
+|`['nagios']['nrpe']['check_dig_ex']['host']`|String||`'127.0.0.1'`|
+|`['nagios']['nrpe']['check_dig_ex']['lookup']`|String||`'www.google.com'`|
+|`['nagios']['nrpe']['check_logs']['log_files']`|Array|see default.rb|`[]`|
+
+Usage
+-----
+#### nagios-grid::default
+- does nothing.
+
+#### nagios-grid::nagios-base
+- Nagios base installation.
+
+#### nagios-grid::nagios-nrpe-server
+- installs Nagios NRPE Server.
+
+License and Authors
+-------------------
+- Author:: whitestar at osdn.jp
+
+```text
+Copyright 2016, whitestar
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
diff --git a/cookbooks/nagios-grid/Rakefile b/cookbooks/nagios-grid/Rakefile
new file mode 100644 (file)
index 0000000..b05b9e3
--- /dev/null
@@ -0,0 +1,24 @@
+require 'rspec/core/rake_task'
+require 'rubocop/rake_task'
+require 'foodcritic'
+
+namespace :style do
+  desc 'Run Ruby style checks'
+  RuboCop::RakeTask.new(:ruby)
+
+  desc 'Run Chef style checks'
+  FoodCritic::Rake::LintTask.new(:chef) do |t|
+    t.options = {
+      fail_tags: ['any'],
+      tags: ['~FC001'],
+    }
+  end
+end
+
+desc 'Run all style checks'
+task style: ['style:chef', 'style:ruby']
+
+desc 'Run ChefSpec examples'
+RSpec::Core::RakeTask.new(:spec)
+
+task default: ['style', 'spec']
diff --git a/cookbooks/nagios-grid/attributes/default.rb b/cookbooks/nagios-grid/attributes/default.rb
new file mode 100644 (file)
index 0000000..ec9c4a2
--- /dev/null
@@ -0,0 +1,144 @@
+#
+# Cookbook Name:: nagios-grid
+# Attributes:: default
+#
+# Copyright 2016, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+default['nagios']['base_cfg_dir'] = 'base'
+default['nagios']['site_cfg_dir'] = 'site'
+default['nagios']['autostart'] = true
+default['nagios']['autoreload'] = true
+default['nagios']['with_pnp4nagios'] = false
+
+# nagios.cfg
+default['nagios']['check_external_commands'] = '0'
+default['nagios']['command_file'] = node.value_for_platform_family(
+  'debian' => '/var/lib/nagios3/rw/nagios.cmd',
+  'rhel' => '/var/spool/nagios/cmd/nagios.cmd',
+)
+default['nagios']['use_regexp_matching'] = '0'
+
+# cgi
+default['nagios']['cgi'] = {
+  'authorized_for_system_information'        => 'nagiosadmin',
+  'authorized_for_configuration_information' => 'nagiosadmin',
+  'authorized_for_system_commands'           => 'nagiosadmin',
+  'authorized_for_all_services'              => 'nagiosadmin',
+  'authorized_for_all_hosts'                 => 'nagiosadmin',
+  'authorized_for_all_service_commands'      => 'nagiosadmin',
+  'authorized_for_all_host_commands'         => 'nagiosadmin',
+  'result_limit' => '100',
+}
+
+# Web UI
+## >= 2.3
+default['nagios']['web']['Require'] = [
+  'all granted',
+]
+## < 2.3
+default['nagios']['web']['Order'] = 'Allow,Deny'  # e.g. 'Deny,Allow'
+default['nagios']['web']['Deny'] = []  # ['From All']
+default['nagios']['web']['Allow'] = [
+  'From All',
+  # e.g.
+  #'from 127.0.0.1',
+  #'from ::1'
+]
+## AuthType: 'none'|'Basic'|'Kerberos'
+default['nagios']['web']['AuthType'] = 'Basic'
+### if AuthType == Basic
+default['nagios']['web']['mod_auth_basic']['AuthUserFile'] = node.value_for_platform_family(
+  'debian' => '/etc/nagios3/htpasswd.users',
+  'rhel'   => '/etc/nagios/passwd',
+)
+### if AuthType == Kerberos
+default['nagios']['web']['mod_auth_kerb']['KrbAuthRealms'] = 'LOCALDOMAIN'
+default['nagios']['web']['mod_auth_kerb']['KrbServiceName'] = 'HTTP'
+default['nagios']['web']['mod_auth_kerb']['Krb5Keytab'] = '/etc/krb5.keytab'
+default['nagios']['web']['mod_auth_kerb']['KrbMethodNegotiate'] = 'on'
+default['nagios']['web']['mod_auth_kerb']['KrbMethodK5Passwd'] = 'off'
+
+# objects
+## default template base
+default['nagios']['objects']['default_contact_groups'] = 'admins'
+default['nagios']['objects']['check_ldap'] = {
+  'base' => 'dc=example,dc=com',
+}
+## full customization
+default['nagios']['objects']['commands'] = []
+default['nagios']['objects']['hosts'] = []
+default['nagios']['objects']['hostgroups'] = []
+default['nagios']['objects']['hostdependencies'] = []
+default['nagios']['objects']['hostescalations'] = []
+default['nagios']['objects']['hostextinfos'] = []
+default['nagios']['objects']['services'] = []
+default['nagios']['objects']['servicegroups'] = []
+default['nagios']['objects']['servicedependencies'] = []
+default['nagios']['objects']['serviceescalations'] = []
+default['nagios']['objects']['serviceextinfos'] = []
+default['nagios']['objects']['contacts'] = []
+default['nagios']['objects']['contactgroups'] = []
+default['nagios']['objects']['timeperiods'] = []
+
+# for check_ganglia_metric
+default['nagios']['NagAconda']['version'] = '0.1.4'
+#default['nagios']['NagAconda']['version'] = '0.2.1'
+default['nagios']['check_ganglia_metric']['enabled'] = false
+default['nagios']['check_ganglia_metric']['gmetad_host'] = 'localhost'
+
+# NRPE
+default['nagios']['nrpe']['allowed_hosts'] = '127.0.0.1'
+default['nagios']['nrpe']['with_smartmontools'] = false
+default['nagios']['nrpe']['check_total_procs'] = {
+  'warn' => '100',
+  'crit' => '200',
+}
+(0..3).each {|num|
+  default['nagios']['nrpe']["check_disk#{num}"] = {
+    'warn' => '20%',
+    'crit' => '10%',
+    'path' => '/',
+    'extra_opts' => '',
+  }
+}
+(0..3).each {|num|
+  default['nagios']['nrpe']["check_smart#{num}"] = {
+    'device' => '/dev/sda',
+  }
+}
+default['nagios']['nrpe']['check_dig'] = {
+  'host' => '127.0.0.1',
+  'lookup' => 'host-a.example.com',
+}
+default['nagios']['nrpe']['check_dig_in'] = {
+  'host' => '127.0.0.1',
+  'lookup' => 'host-b.example.com',
+}
+default['nagios']['nrpe']['check_dig_ex'] = {
+  'host' => '127.0.0.1',
+  'lookup' => 'www.google.com',
+}
+default['nagios']['nrpe']['check_logs']['log_files'] = [
+=begin
+  {
+    'file_name' => '/var/log/messages',
+    'reg_exp' => '(WARNING|CRITICAL)',
+    'lines' => 2,               #optional number of output lines  after match
+    'new_line_reg_exp' => '^',  #optional new line regex to stop output lines
+    'seek_file_suffix' => '2'   #optional seek file suffix
+  }
+=end
+]
diff --git a/cookbooks/nagios-grid/metadata.rb b/cookbooks/nagios-grid/metadata.rb
new file mode 100644 (file)
index 0000000..5681f8b
--- /dev/null
@@ -0,0 +1,7 @@
+name             'nagios-grid'
+maintainer       'whitestar'
+maintainer_email ''
+license          'Apache 2.0'
+description      'Installs/Configures nagios-grid'
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version          '0.1.0'
diff --git a/cookbooks/nagios-grid/recipes/default.rb b/cookbooks/nagios-grid/recipes/default.rb
new file mode 100644 (file)
index 0000000..6d151c0
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# Cookbook Name:: nagios-grid
+# Recipe:: default
+#
+# Copyright 2016, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
diff --git a/cookbooks/nagios-grid/recipes/nagios-base.rb b/cookbooks/nagios-grid/recipes/nagios-base.rb
new file mode 100644 (file)
index 0000000..e412eef
--- /dev/null
@@ -0,0 +1,240 @@
+#
+# Cookbook Name:: nagios-grid
+# Recipe:: nagios-base
+#
+# Copyright 2016, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+root_cfg_dir = nil
+base_cfg_dir = nil
+site_cfg_dir = nil
+nagios_pkgs = nil
+nagios_service = nil
+httpd_service = nil
+
+case node['platform_family']
+when 'debian'
+  root_cfg_dir = '/etc/nagios3'
+  nagios_pkgs = [
+    # Note: PHP is not php5 but php7.0 in Ubuntu 16.04 or later
+    'nagios3',
+    'nagios-plugins',
+    'nagios-images',
+  ]
+  if node['nagios']['with_pnp4nagios'] && node['platform'] == 'debian'
+    # this recipe does not support pnp4nagios on Ubuntu!
+    nagios_pkgs += [
+      # Debian and Ubuntu 15.10, 14.04, 12.04 only.
+      'pnp4nagios',
+      # Debian and Ubuntu 15.10 wily only.
+      'pnp4nagios-web-config-nagios3',
+    ]
+  end
+  if node['nagios']['web']['AuthType'] == 'Kerberos'
+    nagios_pkgs.push('libapache2-mod-auth-kerb')
+  end
+  nagios_service = 'nagios3'
+  httpd_service = 'apache2'
+  httpd_nagios_conf = "#{root_cfg_dir}/apache2.conf"
+when 'rhel'
+  root_cfg_dir = '/etc/nagios'
+  nagios_pkgs = [
+    'nagios',
+    'nagios-plugins',
+  ]
+  nagios_pkgs += \
+    %w(load users ping ssh ntp http disk swap procs file_age).map {|item|
+      "nagios-plugins-#{item}"
+    }
+  if node['nagios']['with_pnp4nagios']
+    include_recipe 'yum-epel'
+    nagios_pkgs += [
+      'pnp4nagios',
+    ]
+  end
+  if node['nagios']['web']['AuthType'] == 'Kerberos'
+    nagios_pkgs.push('mod_auth_kerb')
+  end
+  nagios_service = 'nagios'
+  httpd_service = 'httpd'
+  httpd_nagios_conf = '/etc/httpd/conf.d/nagios.conf'
+end
+
+relative_root_cfg_dir = root_cfg_dir.sub(%r{^/}, '')
+base_cfg_dir = "#{root_cfg_dir}/#{node['nagios']['base_cfg_dir']}"
+site_cfg_dir = "#{root_cfg_dir}/#{node['nagios']['site_cfg_dir']}"
+
+nagios_pkgs.each {|pkg|
+  resources(package: pkg) rescue package pkg do
+    action :install
+  end
+}
+
+nagios_action = nil
+if node['nagios']['autostart']
+  nagios_action = [:enable, :start]
+else
+  nagios_action = [:disable]
+end
+
+service nagios_service do
+  action nagios_action
+  supports status: true, restart: true, reload: true
+end
+
+[
+  'nagios.cfg',
+  'cgi.cfg',
+].each {|cfg_file|
+  template "/#{relative_root_cfg_dir}/#{cfg_file}" do
+    source  "#{relative_root_cfg_dir}/#{cfg_file}"
+    owner 'root'
+    group 'root'
+    mode '0644'
+    notifies :reload, "service[#{nagios_service}]" if node['nagios']['autoreload']
+  end
+}
+
+directory base_cfg_dir do
+  owner 'root'
+  group 'root'
+  mode '0755'
+end
+
+[
+  'checkcommands-generic.cfg',
+  #'contacts.cfg',
+  'hosts-generic.cfg',
+  'services-generic.cfg',
+].each {|tpl|
+  template "#{base_cfg_dir}/#{tpl}" do
+    source  "etc/nagios3/base/#{tpl}"
+    owner 'root'
+    group 'root'
+    mode '0644'
+    notifies :reload, "service[#{nagios_service}]" if node['nagios']['autoreload']
+  end
+}
+
+directory site_cfg_dir do
+  owner 'root'
+  group 'root'
+  mode '0755'
+end
+
+[
+  'hosts.cfg',
+  'services.cfg',
+  'contacts.cfg',
+  'timeperiods.cfg',
+  'checkcommands.cfg',
+].each {|cfg_file|
+  template "#{site_cfg_dir}/#{cfg_file}" do
+    source "etc/nagios3/site/#{cfg_file}"
+    owner 'root'
+    group 'root'
+    mode '0644'
+    notifies :reload, "service[#{nagios_service}]" if node['nagios']['autoreload']
+  end
+}
+
+resources(service: httpd_service) rescue service httpd_service do
+  action [:enable]
+  supports status: true, restart: true, reload: true
+end
+
+template httpd_nagios_conf do
+  source httpd_nagios_conf.sub(%r{^/}, '')
+  owner 'root'
+  group 'root'
+  mode '0644'
+  notifies :restart, "service[#{httpd_service}]"
+end
+
+if node['nagios']['check_external_commands'] == '1'
+  case node['platform_family']
+  when 'debian'
+=begin
+External Commands
+^^^^^^^^^^^^^^^^^
+Nagios 3 is not configured to look for external commands in the
+default configuration as a security feature. To enable external
+commands, you need to allow the web server write access to the
+nagios command pipe.  the simplest way of doing this is to
+set check_external_commands=1 in your nagios configuration,
+and then change the permissions in a way which will be maintained
+across package upgrades (otherwise dpkg will overwrite your
+permission changes).  The following is the recommended approach:
+
+- activate external command checks in the nagios configuration. this
+  can be done by setting check_external_commands=1 in the file
+  /etc/nagios3/nagios.cfg.
+
+- perform the following commands to change directory permissions and
+  to make the changes permanent:
+
+/etc/init.d/nagios3 stop
+dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
+dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
+/etc/init.d/nagios3 start
+=end
+    override_nagios3_rw = 'nagios www-data 2710 /var/lib/nagios3/rw'
+    override_nagios3    = 'nagios nagios    751 /var/lib/nagios3'
+    bash 'modify_permissions_for_check_external_commands' do
+      code <<-EOC
+        dpkg-statoverride --update --add #{override_nagios3_rw}
+        dpkg-statoverride --update --add #{override_nagios3}
+      EOC
+      not_if "dpkg-statoverride --list | grep '#{override_nagios3_rw}'"
+      not_if "dpkg-statoverride --list | grep '#{override_nagios3}'"
+      notifies :restart, "service[#{nagios_service}]" if node['nagios']['autoreload']
+    end
+  when 'rhel'
+    bash 'modify_permissions_for_check_external_commands' do
+      code <<-EOC
+        chown nagios:apache /var/spool/nagios/cmd
+        chmod 2710 /var/spool/nagios/cmd
+        chmod  751 /var/spool/nagios
+      EOC
+      not_if "ls -dl /var/spool/nagios/cmd | grep 'drwx--s---' | grep 'nagios apache'"
+      not_if "ls -dl /var/spool/nagios     | grep 'drwxr-x--x'"
+      notifies :restart, "service[#{nagios_service}]" if node['nagios']['autoreload']
+    end
+  end
+end
+
+# extra check commands
+if node['nagios']['check_ganglia_metric']['enabled']
+  pkg = 'python-setuptools'
+  resources(package: pkg) rescue package pkg do
+    action :install
+  end
+
+  bash 'easy_install_upgrade_distribute' do
+    code <<-EOC
+      easy_install -U distribute
+    EOC
+    only_if { node.platform_family?('rhel') }
+  end
+
+  easy_install_package 'check_ganglia_metric' do
+    action :install
+  end
+
+  easy_install_package 'NagAconda' do
+    version node['nagios']['NagAconda']['version']
+    action :install
+  end
+end
diff --git a/cookbooks/nagios-grid/recipes/nagios-nrpe-server.rb b/cookbooks/nagios-grid/recipes/nagios-nrpe-server.rb
new file mode 100644 (file)
index 0000000..55e0772
--- /dev/null
@@ -0,0 +1,77 @@
+#
+# Cookbook Name:: nagios-grid
+# Recipe:: nagios-nrpe-server
+#
+# Copyright 2016, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+[
+  'nagios-nrpe-server',
+  'nagios-plugins',
+  'nagios-plugins-contrib',  # for check_memory
+  'libnagios-plugin-perl',   # for check_memory
+].each {|pkg|
+  resources(package: pkg) rescue package pkg do
+    action :install
+  end
+}
+
+pkg = 'smartmontools'
+act = (node['nagios']['nrpe']['with_smartmontools'] ? :install : :remove)
+resources(package: pkg) rescue package pkg do
+  action act
+end
+
+[
+  'nagios-nrpe-server',
+].each {|nagios_service|
+  service nagios_service do
+    action [:enable, :start]
+    supports status: true, restart: true, reload: true
+  end
+}
+
+template '/etc/nagios/nrpe_local.cfg' do
+  source  'etc/nagios/nrpe_local.cfg'
+  owner 'root'
+  group 'root'
+  mode '0644'
+  notifies :reload, 'service[nagios-nrpe-server]'
+end
+
+[
+  'check_logs.pl',
+  'check_smart.pl',
+].each {|cmd|
+  template "/usr/lib/nagios/plugins/#{cmd}" do
+    source  "usr/lib/nagios/plugins/#{cmd}"
+    owner 'root'
+    group 'root'
+    mode '0755'
+  end
+}
+
+directory '/etc/nagios/check_logs' do
+  owner 'root'
+  group 'root'
+  mode '0755'
+end
+
+template '/etc/nagios/check_logs/check_logs.cfg' do
+  source  'etc/nagios/check_logs/check_logs.cfg'
+  owner 'root'
+  group 'root'
+  mode '0644'
+end
diff --git a/cookbooks/nagios-grid/spec/recipes/default_spec.rb b/cookbooks/nagios-grid/spec/recipes/default_spec.rb
new file mode 100644 (file)
index 0000000..852fe4a
--- /dev/null
@@ -0,0 +1,20 @@
+require_relative '../spec_helper'
+
+describe 'nagios-grid::default' do
+  subject { ChefSpec::Runner.new.converge(described_recipe) }
+
+  # Write quick specs using `it` blocks with implied subjects
+  it { should do_something('...') }
+
+  # Write full examples using the `expect` syntax
+  it 'does something' do
+    expect(subject).to do_something('...')
+  end
+
+  # Use an explicit subject
+  let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
+
+  it 'does something' do
+    expect(chef_run).to do_something('...')
+  end
+end
diff --git a/cookbooks/nagios-grid/spec/spec_helper.rb b/cookbooks/nagios-grid/spec/spec_helper.rb
new file mode 100644 (file)
index 0000000..1995e2b
--- /dev/null
@@ -0,0 +1,25 @@
+# Added by ChefSpec
+require 'chefspec'
+
+# Uncomment to use ChefSpec's Berkshelf extension
+# require 'chefspec/berkshelf'
+
+RSpec.configure do |config|
+  # Specify the path for Chef Solo to find cookbooks
+  # config.cookbook_path = '/var/cookbooks'
+
+  # Specify the path for Chef Solo to find roles
+  # config.role_path = '/var/roles'
+
+  # Specify the Chef log_level (default: :warn)
+  # config.log_level = :debug
+
+  # Specify the path to a local JSON file with Ohai data
+  # config.path = 'ohai.json'
+
+  # Specify the operating platform to mock Ohai data from
+  # config.platform = 'ubuntu'
+
+  # Specify the operating version to mock Ohai data from
+  # config.version = '12.04'
+end
diff --git a/cookbooks/nagios-grid/templates/centos/etc/httpd/conf.d/nagios.conf b/cookbooks/nagios-grid/templates/centos/etc/httpd/conf.d/nagios.conf
new file mode 100644 (file)
index 0000000..2fb7406
--- /dev/null
@@ -0,0 +1,78 @@
+# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
+# Last Modified: 11-26-2005
+#
+# This file contains examples of entries that need
+# to be incorporated into your Apache web server
+# configuration file.  Customize the paths, etc. as
+# needed to fit your system.
+
+ScriptAlias /nagios/cgi-bin/ "/usr/lib/nagios/cgi-bin/"
+
+<Directory "/usr/lib/nagios/cgi-bin/">
+#  SSLRequireSSL
+   Options ExecCGI
+   AllowOverride None
+   Order <%= node['nagios']['web']['Order'] %>
+<% node['nagios']['web']['Deny'].each do |from_where| -%>
+   Deny <%= from_where %>
+<% end -%>
+<% node['nagios']['web']['Allow'].each do |from_where| -%>
+   Allow <%= from_where %>
+<% end -%>
+
+   AuthName "Nagios Access"
+<%
+case node['nagios']['web']['AuthType']
+  when 'Basic'
+-%>
+   AuthType Basic
+   AuthUserFile <%= node['nagios']['web']['mod_auth_basic']['AuthUserFile'] %>
+   Require valid-user
+<%
+  when 'Kerberos'
+-%>
+   AuthType Kerberos
+   KrbAuthRealms <%= node['nagios']['web']['mod_auth_kerb']['KrbAuthRealms'] %>
+   KrbServiceName <%= node['nagios']['web']['mod_auth_kerb']['KrbServiceName'] %>
+   Krb5Keytab <%= node['nagios']['web']['mod_auth_kerb']['Krb5Keytab'] %>
+   KrbMethodNegotiate <%= node['nagios']['web']['mod_auth_kerb']['KrbMethodNegotiate'] %>
+   KrbMethodK5Passwd <%= node['nagios']['web']['mod_auth_kerb']['KrbMethodK5Passwd'] %>
+   Require valid-user
+<% end -%>
+</Directory>
+
+Alias /nagios "/usr/share/nagios/html"
+
+<Directory "/usr/share/nagios/html">
+#  SSLRequireSSL
+   Options None
+   AllowOverride None
+   Order <%= node['nagios']['web']['Order'] %>
+<% node['nagios']['web']['Deny'].each do |from_where| -%>
+   Deny <%= from_where %>
+<% end -%>
+<% node['nagios']['web']['Allow'].each do |from_where| -%>
+   Allow <%= from_where %>
+<% end -%>
+
+   AuthName "Nagios Access"
+<%
+case node['nagios']['web']['AuthType']
+  when 'Basic'
+-%>
+   AuthType Basic
+   AuthUserFile <%= node['nagios']['web']['mod_auth_basic']['AuthUserFile'] %>
+   Require valid-user
+<%
+  when 'Kerberos'
+-%>
+   AuthType Kerberos
+   KrbAuthRealms <%= node['nagios']['web']['mod_auth_kerb']['KrbAuthRealms'] %>
+   KrbServiceName <%= node['nagios']['web']['mod_auth_kerb']['KrbServiceName'] %>
+   Krb5Keytab <%= node['nagios']['web']['mod_auth_kerb']['Krb5Keytab'] %>
+   KrbMethodNegotiate <%= node['nagios']['web']['mod_auth_kerb']['KrbMethodNegotiate'] %>
+   KrbMethodK5Passwd <%= node['nagios']['web']['mod_auth_kerb']['KrbMethodK5Passwd'] %>
+   Require valid-user
+<% end -%>
+</Directory>
+
diff --git a/cookbooks/nagios-grid/templates/centos/etc/nagios/cgi.cfg b/cookbooks/nagios-grid/templates/centos/etc/nagios/cgi.cfg
new file mode 100644 (file)
index 0000000..babd887
--- /dev/null
@@ -0,0 +1,364 @@
+#################################################################
+#
+# CGI.CFG - Sample CGI Configuration File for Nagios 3.5.0
+#
+# Last Modified: 06-17-2009
+#
+#################################################################
+
+
+# MAIN CONFIGURATION FILE
+# This tells the CGIs where to find your main configuration file.
+# The CGIs will read the main and host config files for any other
+# data they might need.
+
+main_config_file=/etc/nagios/nagios.cfg
+
+
+
+# PHYSICAL HTML PATH
+# This is the path where the HTML files for Nagios reside.  This
+# value is used to locate the logo images needed by the statusmap
+# and statuswrl CGIs.
+
+physical_html_path=/usr/share/nagios/html
+
+
+
+# URL HTML PATH
+# This is the path portion of the URL that corresponds to the
+# physical location of the Nagios HTML files (as defined above).
+# This value is used by the CGIs to locate the online documentation
+# and graphics.  If you access the Nagios pages with an URL like
+# http://www.myhost.com/nagios, this value should be '/nagios'
+# (without the quotes).
+
+url_html_path=/nagios
+
+
+
+# CONTEXT-SENSITIVE HELP
+# This option determines whether or not a context-sensitive
+# help icon will be displayed for most of the CGIs.
+# Values: 0 = disables context-sensitive help
+#         1 = enables context-sensitive help
+
+show_context_help=0
+
+
+
+# PENDING STATES OPTION
+# This option determines what states should be displayed in the web
+# interface for hosts/services that have not yet been checked.
+# Values: 0 = leave hosts/services that have not been check yet in their original state
+#         1 = mark hosts/services that have not been checked yet as PENDING
+
+use_pending_states=1
+
+
+
+
+# AUTHENTICATION USAGE
+# This option controls whether or not the CGIs will use any 
+# authentication when displaying host and service information, as
+# well as committing commands to Nagios for processing.  
+#
+# Read the HTML documentation to learn how the authorization works!
+#
+# NOTE: It is a really *bad* idea to disable authorization, unless
+# you plan on removing the command CGI (cmd.cgi)!  Failure to do
+# so will leave you wide open to kiddies messing with Nagios and
+# possibly hitting you with a denial of service attack by filling up
+# your drive by continuously writing to your command file!
+#
+# Setting this value to 0 will cause the CGIs to *not* use
+# authentication (bad idea), while any other value will make them
+# use the authentication functions (the default).
+
+use_authentication=1
+
+
+
+
+# x509 CERT AUTHENTICATION
+# When enabled, this option allows you to use x509 cert (SSL)
+# authentication in the CGIs.  This is an advanced option and should
+# not be enabled unless you know what you're doing.
+
+use_ssl_authentication=0
+
+
+
+
+# DEFAULT USER
+# Setting this variable will define a default user name that can
+# access pages without authentication.  This allows people within a
+# secure domain (i.e., behind a firewall) to see the current status
+# without authenticating.  You may want to use this to avoid basic
+# authentication if you are not using a secure server since basic
+# authentication transmits passwords in the clear.
+#
+# Important:  Do not define a default username unless you are
+# running a secure web server and are sure that everyone who has
+# access to the CGIs has been authenticated in some manner!  If you
+# define this variable, anyone who has not authenticated to the web
+# server will inherit all rights you assign to this user!
+#default_user_name=guest
+
+
+
+# SYSTEM/PROCESS INFORMATION ACCESS
+# This option is a comma-delimited list of all usernames that
+# have access to viewing the Nagios process information as
+# provided by the Extended Information CGI (extinfo.cgi).  By
+# default, *no one* has access to this unless you choose to
+# not use authorization.  You may use an asterisk (*) to
+# authorize any user who has authenticated to the web server.
+
+authorized_for_system_information=<%= node['nagios']['authorized_for_system_information'] %>
+
+
+
+# CONFIGURATION INFORMATION ACCESS
+# This option is a comma-delimited list of all usernames that
+# can view ALL configuration information (hosts, commands, etc).
+# By default, users can only view configuration information
+# for the hosts and services they are contacts for. You may use
+# an asterisk (*) to authorize any user who has authenticated
+# to the web server.
+
+authorized_for_configuration_information=<%= node['nagios']['authorized_for_configuration_information'] %>
+
+
+
+# SYSTEM/PROCESS COMMAND ACCESS
+# This option is a comma-delimited list of all usernames that
+# can issue shutdown and restart commands to Nagios via the
+# command CGI (cmd.cgi).  Users in this list can also change
+# the program mode to active or standby. By default, *no one*
+# has access to this unless you choose to not use authorization.
+# You may use an asterisk (*) to authorize any user who has
+# authenticated to the web server.
+
+authorized_for_system_commands=<%= node['nagios']['authorized_for_system_commands'] %>
+
+
+
+# GLOBAL HOST/SERVICE VIEW ACCESS
+# These two options are comma-delimited lists of all usernames that
+# can view information for all hosts and services that are being
+# monitored.  By default, users can only view information
+# for hosts or services that they are contacts for (unless you
+# you choose to not use authorization). You may use an asterisk (*)
+# to authorize any user who has authenticated to the web server.
+
+
+authorized_for_all_services=<%= node['nagios']['authorized_for_all_services'] %>
+authorized_for_all_hosts=<%= node['nagios']['authorized_for_all_hosts'] %>
+
+
+
+# GLOBAL HOST/SERVICE COMMAND ACCESS
+# These two options are comma-delimited lists of all usernames that
+# can issue host or service related commands via the command
+# CGI (cmd.cgi) for all hosts and services that are being monitored. 
+# By default, users can only issue commands for hosts or services 
+# that they are contacts for (unless you you choose to not use 
+# authorization).  You may use an asterisk (*) to authorize any
+# user who has authenticated to the web server.
+
+authorized_for_all_service_commands=<%= node['nagios']['authorized_for_all_service_commands'] %>
+authorized_for_all_host_commands=<%= node['nagios']['authorized_for_all_host_commands'] %>
+
+
+
+# READ-ONLY USERS
+# A comma-delimited list of usernames that have read-only rights in
+# the CGIs.  This will block any service or host commands normally shown
+# on the extinfo CGI pages.  It will also block comments from being shown
+# to read-only users.
+
+#authorized_for_read_only=user1,user2
+
+
+
+
+# STATUSMAP BACKGROUND IMAGE
+# This option allows you to specify an image to be used as a 
+# background in the statusmap CGI.  It is assumed that the image
+# resides in the HTML images path (i.e. /usr/local/nagios/share/images).
+# This path is automatically determined by appending "/images"
+# to the path specified by the 'physical_html_path' directive.
+# Note:  The image file may be in GIF, PNG, JPEG, or GD2 format.
+# However, I recommend that you convert your image to GD2 format
+# (uncompressed), as this will cause less CPU load when the CGI
+# generates the image.
+
+#statusmap_background_image=smbackground.gd2
+
+
+
+
+# STATUSMAP TRANSPARENCY INDEX COLOR
+# These options set the r,g,b values of the background color used the statusmap CGI,
+# so normal browsers that can't show real png transparency set the desired color as
+# a background color instead (to make it look pretty).  
+# Defaults to white: (R,G,B) = (255,255,255).
+
+#color_transparency_index_r=255
+#color_transparency_index_g=255
+#color_transparency_index_b=255
+
+
+
+
+# DEFAULT STATUSMAP LAYOUT METHOD
+# This option allows you to specify the default layout method
+# the statusmap CGI should use for drawing hosts.  If you do
+# not use this option, the default is to use user-defined
+# coordinates.  Valid options are as follows:
+#      0 = User-defined coordinates
+#      1 = Depth layers
+#       2 = Collapsed tree
+#       3 = Balanced tree
+#       4 = Circular
+#       5 = Circular (Marked Up)
+
+default_statusmap_layout=5
+
+
+
+# DEFAULT STATUSWRL LAYOUT METHOD
+# This option allows you to specify the default layout method
+# the statuswrl (VRML) CGI should use for drawing hosts.  If you
+# do not use this option, the default is to use user-defined
+# coordinates.  Valid options are as follows:
+#      0 = User-defined coordinates
+#       2 = Collapsed tree
+#       3 = Balanced tree
+#       4 = Circular
+
+default_statuswrl_layout=4
+
+
+
+# STATUSWRL INCLUDE
+# This option allows you to include your own objects in the 
+# generated VRML world.  It is assumed that the file
+# resides in the HTML path (i.e. /usr/local/nagios/share).
+
+#statuswrl_include=myworld.wrl
+
+
+
+# PING SYNTAX
+# This option determines what syntax should be used when
+# attempting to ping a host from the WAP interface (using
+# the statuswml CGI.  You must include the full path to
+# the ping binary, along with all required options.  The
+# $HOSTADDRESS$ macro is substituted with the address of
+# the host before the command is executed.
+# Please note that the syntax for the ping binary is
+# notorious for being different on virtually ever *NIX
+# OS and distribution, so you may have to tweak this to
+# work on your system.
+
+ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$
+
+
+
+# REFRESH RATE
+# This option allows you to specify the refresh rate in seconds
+# of various CGIs (status, statusmap, extinfo, and outages).  
+
+refresh_rate=90
+
+# DEFAULT PAGE LIMIT
+# This option allows you to specify the default number of results 
+# displayed on the status.cgi.  This number can be adjusted from
+# within the UI after the initial page load. Setting this to 0
+# will show all results.  
+
+result_limit=100
+
+
+# ESCAPE HTML TAGS
+# This option determines whether HTML tags in host and service
+# status output is escaped in the web interface.  If enabled,
+# your plugin output will not be able to contain clickable links.
+
+escape_html_tags=1
+
+
+
+
+# SOUND OPTIONS
+# These options allow you to specify an optional audio file
+# that should be played in your browser window when there are
+# problems on the network.  The audio files are used only in
+# the status CGI.  Only the sound for the most critical problem
+# will be played.  Order of importance (higher to lower) is as
+# follows: unreachable hosts, down hosts, critical services,
+# warning services, and unknown services. If there are no
+# visible problems, the sound file optionally specified by
+# 'normal_sound' variable will be played.
+#
+#
+# <varname>=<sound_file>
+#
+# Note: All audio files must be placed in the /media subdirectory
+# under the HTML path (i.e. /usr/local/nagios/share/media/).
+
+#host_unreachable_sound=hostdown.wav
+#host_down_sound=hostdown.wav
+#service_critical_sound=critical.wav
+#service_warning_sound=warning.wav
+#service_unknown_sound=warning.wav
+#normal_sound=noproblem.wav
+
+
+
+# URL TARGET FRAMES
+# These options determine the target frames in which notes and 
+# action URLs will open.
+
+action_url_target=_blank
+notes_url_target=_blank
+
+
+
+
+# LOCK AUTHOR NAMES OPTION
+# This option determines whether users can change the author name 
+# when submitting comments, scheduling downtime.  If disabled, the 
+# author names will be locked into their contact name, as defined in Nagios.
+# Values: 0 = allow editing author names
+#         1 = lock author names (disallow editing)
+
+lock_author_names=1
+
+
+
+
+# SPLUNK INTEGRATION OPTIONS
+# These options allow you to enable integration with Splunk
+# in the web interface.  If enabled, you'll be presented with
+# "Splunk It" links in various places in the CGIs (log file,
+# alert history, host/service detail, etc).  Useful if you're
+# trying to research why a particular problem occurred.
+# For more information on Splunk, visit http://www.splunk.com/
+
+# This option determines whether the Splunk integration is enabled
+# Values: 0 = disable Splunk integration
+#         1 = enable Splunk integration
+
+#enable_splunk_integration=1
+
+
+# This option should be the URL used to access your instance of Splunk
+
+#splunk_url=http://127.0.0.1:8000/
+
+
+
diff --git a/cookbooks/nagios-grid/templates/centos/etc/nagios/nagios.cfg b/cookbooks/nagios-grid/templates/centos/etc/nagios/nagios.cfg
new file mode 100644 (file)
index 0000000..194b539
--- /dev/null
@@ -0,0 +1,1341 @@
+##############################################################################
+#
+# NAGIOS.CFG - Sample Main Config File for Nagios 3.4.1
+#
+# Read the documentation for more information on this configuration
+# file.  I've provided some comments here, but things may not be so
+# clear without further explanation.
+#
+# Last Modified: 12-14-2008
+#
+##############################################################################
+
+
+# LOG FILE
+# This is the main log file where service and host events are logged
+# for historical purposes.  This should be the first option specified 
+# in the config file!!!
+
+log_file=/var/log/nagios/nagios.log
+
+
+
+# OBJECT CONFIGURATION FILE(S)
+# These are the object configuration files in which you define hosts,
+# host groups, contacts, contact groups, services, etc.
+# You can split your object definitions across several config files
+# if you wish (as shown below), or keep them all in a single config file.
+
+# You can specify individual object config files as shown below:
+cfg_file=/etc/nagios/objects/commands.cfg
+cfg_file=/etc/nagios/objects/contacts.cfg
+cfg_file=/etc/nagios/objects/timeperiods.cfg
+cfg_file=/etc/nagios/objects/templates.cfg
+
+# Definitions for monitoring the local (Linux) host
+cfg_file=/etc/nagios/objects/localhost.cfg
+
+# Definitions for monitoring a Windows machine
+#cfg_file=/etc/nagios/objects/windows.cfg
+
+# Definitions for monitoring a router/switch
+#cfg_file=/etc/nagios/objects/switch.cfg
+
+# Definitions for monitoring a network printer
+#cfg_file=/etc/nagios/objects/printer.cfg
+
+
+# You can also tell Nagios to process all config files (with a .cfg
+# extension) in a particular directory by using the cfg_dir
+# directive as shown below:
+
+#cfg_dir=/etc/nagios/servers
+#cfg_dir=/etc/nagios/printers
+#cfg_dir=/etc/nagios/switches
+#cfg_dir=/etc/nagios/routers
+
+cfg_dir=/etc/nagios/conf.d
+cfg_dir=<%= @cfg_dir %>
+
+
+
+
+# OBJECT CACHE FILE
+# This option determines where object definitions are cached when
+# Nagios starts/restarts.  The CGIs read object definitions from 
+# this cache file (rather than looking at the object config files
+# directly) in order to prevent inconsistencies that can occur
+# when the config files are modified after Nagios starts.
+
+object_cache_file=/var/log/nagios/objects.cache
+
+
+
+# PRE-CACHED OBJECT FILE
+# This options determines the location of the precached object file.
+# If you run Nagios with the -p command line option, it will preprocess
+# your object configuration file(s) and write the cached config to this
+# file.  You can then start Nagios with the -u option to have it read
+# object definitions from this precached file, rather than the standard
+# object configuration files (see the cfg_file and cfg_dir options above).
+# Using a precached object file can speed up the time needed to (re)start 
+# the Nagios process if you've got a large and/or complex configuration.
+# Read the documentation section on optimizing Nagios to find our more
+# about how this feature works.
+
+precached_object_file=/var/log/nagios/objects.precache
+
+
+
+# RESOURCE FILE
+# This is an optional resource file that contains $USERx$ macro
+# definitions. Multiple resource files can be specified by using
+# multiple resource_file definitions.  The CGIs will not attempt to
+# read the contents of resource files, so information that is
+# considered to be sensitive (usernames, passwords, etc) can be
+# defined as macros in this file and restrictive permissions (600)
+# can be placed on this file.
+
+resource_file=/etc/nagios/private/resource.cfg
+
+
+
+# STATUS FILE
+# This is where the current status of all monitored services and
+# hosts is stored.  Its contents are read and processed by the CGIs.
+# The contents of the status file are deleted every time Nagios
+#  restarts.
+
+status_file=/var/log/nagios/status.dat
+
+
+
+# STATUS FILE UPDATE INTERVAL
+# This option determines the frequency (in seconds) that
+# Nagios will periodically dump program, host, and 
+# service status data.
+
+status_update_interval=10
+
+
+
+# NAGIOS USER
+# This determines the effective user that Nagios should run as.  
+# You can either supply a username or a UID.
+
+nagios_user=nagios
+
+
+
+# NAGIOS GROUP
+# This determines the effective group that Nagios should run as.  
+# You can either supply a group name or a GID.
+
+nagios_group=nagios
+
+
+
+# EXTERNAL COMMAND OPTION
+# This option allows you to specify whether or not Nagios should check
+# for external commands (in the command file defined below).  By default
+# Nagios will *not* check for external commands, just to be on the
+# cautious side.  If you want to be able to use the CGI command interface
+# you will have to enable this.
+# Values: 0 = disable commands, 1 = enable commands
+
+check_external_commands=<%= node['nagios']['check_external_commands'] %>
+
+
+
+# EXTERNAL COMMAND CHECK INTERVAL
+# This is the interval at which Nagios should check for external commands.
+# This value works of the interval_length you specify later.  If you leave
+# that at its default value of 60 (seconds), a value of 1 here will cause
+# Nagios to check for external commands every minute.  If you specify a
+# number followed by an "s" (i.e. 15s), this will be interpreted to mean
+# actual seconds rather than a multiple of the interval_length variable.
+# Note: In addition to reading the external command file at regularly 
+# scheduled intervals, Nagios will also check for external commands after
+# event handlers are executed.
+# NOTE: Setting this value to -1 causes Nagios to check the external
+# command file as often as possible.
+
+#command_check_interval=15s
+command_check_interval=-1
+
+
+
+# EXTERNAL COMMAND FILE
+# This is the file that Nagios checks for external command requests.
+# It is also where the command CGI will write commands that are submitted
+# by users, so it must be writeable by the user that the web server
+# is running as (usually 'nobody').  Permissions should be set at the 
+# directory level instead of on the file, as the file is deleted every
+# time its contents are processed.
+
+command_file=<%= node['nagios']['command_file'] %>
+
+
+
+# EXTERNAL COMMAND BUFFER SLOTS
+# This settings is used to tweak the number of items or "slots" that
+# the Nagios daemon should allocate to the buffer that holds incoming 
+# external commands before they are processed.  As external commands 
+# are processed by the daemon, they are removed from the buffer.  
+
+external_command_buffer_slots=4096
+
+
+
+# LOCK FILE
+# This is the lockfile that Nagios will use to store its PID number
+# in when it is running in daemon mode.
+
+lock_file=/var/run/nagios.pid
+
+
+
+# TEMP FILE
+# This is a temporary file that is used as scratch space when Nagios
+# updates the status log, cleans the comment file, etc.  This file
+# is created, used, and deleted throughout the time that Nagios is
+# running.
+
+temp_file=/var/log/nagios/nagios.tmp
+
+
+
+# TEMP PATH
+# This is path where Nagios can create temp files for service and
+# host check results, etc.
+
+temp_path=/tmp
+
+
+
+# EVENT BROKER OPTIONS
+# Controls what (if any) data gets sent to the event broker.
+# Values:  0      = Broker nothing
+#         -1      = Broker everything
+#         <other> = See documentation
+
+event_broker_options=-1
+
+
+
+# EVENT BROKER MODULE(S)
+# This directive is used to specify an event broker module that should
+# by loaded by Nagios at startup.  Use multiple directives if you want
+# to load more than one module.  Arguments that should be passed to
+# the module at startup are seperated from the module path by a space.
+#
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#
+# Do NOT overwrite modules while they are being used by Nagios or Nagios
+# will crash in a fiery display of SEGFAULT glory.  This is a bug/limitation
+# either in dlopen(), the kernel, and/or the filesystem.  And maybe Nagios...
+#
+# The correct/safe way of updating a module is by using one of these methods:
+#    1. Shutdown Nagios, replace the module file, restart Nagios
+#    2. Delete the original module file, move the new module file into place, restart Nagios
+#
+# Example:
+#
+#   broker_module=<modulepath> [moduleargs]
+
+#broker_module=/somewhere/module1.o
+#broker_module=/somewhere/module2.o arg1 arg2=3 debug=0
+
+
+
+# LOG ROTATION METHOD
+# This is the log rotation method that Nagios should use to rotate
+# the main log file. Values are as follows..
+#      n       = None - don't rotate the log
+#      h       = Hourly rotation (top of the hour)
+#      d       = Daily rotation (midnight every day)
+#      w       = Weekly rotation (midnight on Saturday evening)
+#      m       = Monthly rotation (midnight last day of month)
+
+log_rotation_method=d
+
+
+
+# LOG ARCHIVE PATH
+# This is the directory where archived (rotated) log files should be 
+# placed (assuming you've chosen to do log rotation).
+
+log_archive_path=/var/log/nagios/archives
+
+
+
+# LOGGING OPTIONS
+# If you want messages logged to the syslog facility, as well as the
+# Nagios log file set this option to 1.  If not, set it to 0.
+
+use_syslog=1
+
+
+
+# NOTIFICATION LOGGING OPTION
+# If you don't want notifications to be logged, set this value to 0.
+# If notifications should be logged, set the value to 1.
+
+log_notifications=1
+
+
+
+# SERVICE RETRY LOGGING OPTION
+# If you don't want service check retries to be logged, set this value
+# to 0.  If retries should be logged, set the value to 1.
+
+log_service_retries=1
+
+
+
+# HOST RETRY LOGGING OPTION
+# If you don't want host check retries to be logged, set this value to
+# 0.  If retries should be logged, set the value to 1.
+
+log_host_retries=1
+
+
+
+# EVENT HANDLER LOGGING OPTION
+# If you don't want host and service event handlers to be logged, set
+# this value to 0.  If event handlers should be logged, set the value
+# to 1.
+
+log_event_handlers=1
+
+
+
+# INITIAL STATES LOGGING OPTION
+# If you want Nagios to log all initial host and service states to
+# the main log file (the first time the service or host is checked)
+# you can enable this option by setting this value to 1.  If you
+# are not using an external application that does long term state
+# statistics reporting, you do not need to enable this option.  In
+# this case, set the value to 0.
+
+log_initial_states=0
+
+
+
+# EXTERNAL COMMANDS LOGGING OPTION
+# If you don't want Nagios to log external commands, set this value
+# to 0.  If external commands should be logged, set this value to 1.
+# Note: This option does not include logging of passive service
+# checks - see the option below for controlling whether or not
+# passive checks are logged.
+
+log_external_commands=1
+
+
+
+# PASSIVE CHECKS LOGGING OPTION
+# If you don't want Nagios to log passive host and service checks, set
+# this value to 0.  If passive checks should be logged, set
+# this value to 1.
+
+log_passive_checks=1
+
+
+
+# GLOBAL HOST AND SERVICE EVENT HANDLERS
+# These options allow you to specify a host and service event handler
+# command that is to be run for every host or service state change.
+# The global event handler is executed immediately prior to the event
+# handler that you have optionally specified in each host or
+# service definition. The command argument is the short name of a
+# command definition that you define in your host configuration file.
+# Read the HTML docs for more information.
+
+#global_host_event_handler=somecommand
+#global_service_event_handler=somecommand
+
+
+
+# SERVICE INTER-CHECK DELAY METHOD
+# This is the method that Nagios should use when initially
+# "spreading out" service checks when it starts monitoring.  The
+# default is to use smart delay calculation, which will try to
+# space all service checks out evenly to minimize CPU load.
+# Using the dumb setting will cause all checks to be scheduled
+# at the same time (with no delay between them)!  This is not a
+# good thing for production, but is useful when testing the
+# parallelization functionality.
+#      n       = None - don't use any delay between checks
+#      d       = Use a "dumb" delay of 1 second between checks
+#      s       = Use "smart" inter-check delay calculation
+#       x.xx    = Use an inter-check delay of x.xx seconds
+
+service_inter_check_delay_method=s
+
+
+
+# MAXIMUM SERVICE CHECK SPREAD
+# This variable determines the timeframe (in minutes) from the
+# program start time that an initial check of all services should
+# be completed.  Default is 30 minutes.
+
+max_service_check_spread=30
+
+
+
+# SERVICE CHECK INTERLEAVE FACTOR
+# This variable determines how service checks are interleaved.
+# Interleaving the service checks allows for a more even
+# distribution of service checks and reduced load on remote
+# hosts.  Setting this value to 1 is equivalent to how versions
+# of Nagios previous to 0.0.5 did service checks.  Set this
+# value to s (smart) for automatic calculation of the interleave
+# factor unless you have a specific reason to change it.
+#       s       = Use "smart" interleave factor calculation
+#       x       = Use an interleave factor of x, where x is a
+#                 number greater than or equal to 1.
+
+service_interleave_factor=s
+
+
+
+# HOST INTER-CHECK DELAY METHOD
+# This is the method that Nagios should use when initially
+# "spreading out" host checks when it starts monitoring.  The
+# default is to use smart delay calculation, which will try to
+# space all host checks out evenly to minimize CPU load.
+# Using the dumb setting will cause all checks to be scheduled
+# at the same time (with no delay between them)!
+#      n       = None - don't use any delay between checks
+#      d       = Use a "dumb" delay of 1 second between checks
+#      s       = Use "smart" inter-check delay calculation
+#       x.xx    = Use an inter-check delay of x.xx seconds
+
+host_inter_check_delay_method=s
+
+
+
+# MAXIMUM HOST CHECK SPREAD
+# This variable determines the timeframe (in minutes) from the
+# program start time that an initial check of all hosts should
+# be completed.  Default is 30 minutes.
+
+max_host_check_spread=30
+
+
+
+# MAXIMUM CONCURRENT SERVICE CHECKS
+# This option allows you to specify the maximum number of 
+# service checks that can be run in parallel at any given time.
+# Specifying a value of 1 for this variable essentially prevents
+# any service checks from being parallelized.  A value of 0
+# will not restrict the number of concurrent checks that are
+# being executed.
+
+max_concurrent_checks=0
+
+
+
+# HOST AND SERVICE CHECK REAPER FREQUENCY
+# This is the frequency (in seconds!) that Nagios will process
+# the results of host and service checks.
+
+check_result_reaper_frequency=10
+
+
+
+
+# MAX CHECK RESULT REAPER TIME
+# This is the max amount of time (in seconds) that  a single
+# check result reaper event will be allowed to run before 
+# returning control back to Nagios so it can perform other
+# duties.
+
+max_check_result_reaper_time=30
+
+
+
+
+# CHECK RESULT PATH
+# This is directory where Nagios stores the results of host and
+# service checks that have not yet been processed.
+#
+# Note: Make sure that only one instance of Nagios has access
+# to this directory!  
+
+check_result_path=/var/log/nagios/spool/checkresults
+
+
+
+
+# MAX CHECK RESULT FILE AGE
+# This option determines the maximum age (in seconds) which check
+# result files are considered to be valid.  Files older than this 
+# threshold will be mercilessly deleted without further processing.
+
+max_check_result_file_age=3600
+
+
+
+
+# CACHED HOST CHECK HORIZON
+# This option determines the maximum amount of time (in seconds)
+# that the state of a previous host check is considered current.
+# Cached host states (from host checks that were performed more
+# recently that the timeframe specified by this value) can immensely
+# improve performance in regards to the host check logic.
+# Too high of a value for this option may result in inaccurate host
+# states being used by Nagios, while a lower value may result in a
+# performance hit for host checks.  Use a value of 0 to disable host
+# check caching.
+
+cached_host_check_horizon=15
+
+
+
+# CACHED SERVICE CHECK HORIZON
+# This option determines the maximum amount of time (in seconds)
+# that the state of a previous service check is considered current.
+# Cached service states (from service checks that were performed more
+# recently that the timeframe specified by this value) can immensely
+# improve performance in regards to predictive dependency checks.
+# Use a value of 0 to disable service check caching.
+
+cached_service_check_horizon=15
+
+
+
+# ENABLE PREDICTIVE HOST DEPENDENCY CHECKS
+# This option determines whether or not Nagios will attempt to execute
+# checks of hosts when it predicts that future dependency logic test
+# may be needed.  These predictive checks can help ensure that your
+# host dependency logic works well.
+# Values:
+#  0 = Disable predictive checks
+#  1 = Enable predictive checks (default)
+
+enable_predictive_host_dependency_checks=1
+
+
+
+# ENABLE PREDICTIVE SERVICE DEPENDENCY CHECKS
+# This option determines whether or not Nagios will attempt to execute
+# checks of service when it predicts that future dependency logic test
+# may be needed.  These predictive checks can help ensure that your
+# service dependency logic works well.
+# Values:
+#  0 = Disable predictive checks
+#  1 = Enable predictive checks (default)
+
+enable_predictive_service_dependency_checks=1
+
+
+
+# SOFT STATE DEPENDENCIES
+# This option determines whether or not Nagios will use soft state 
+# information when checking host and service dependencies. Normally 
+# Nagios will only use the latest hard host or service state when 
+# checking dependencies. If you want it to use the latest state (regardless
+# of whether its a soft or hard state type), enable this option. 
+# Values:
+#  0 = Don't use soft state dependencies (default) 
+#  1 = Use soft state dependencies 
+
+soft_state_dependencies=0
+
+
+
+# TIME CHANGE ADJUSTMENT THRESHOLDS
+# These options determine when Nagios will react to detected changes
+# in system time (either forward or backwards).
+
+#time_change_threshold=900
+
+
+
+# AUTO-RESCHEDULING OPTION
+# This option determines whether or not Nagios will attempt to
+# automatically reschedule active host and service checks to
+# "smooth" them out over time.  This can help balance the load on
+# the monitoring server.  
+# WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE
+# PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY
+
+auto_reschedule_checks=0
+
+
+
+# AUTO-RESCHEDULING INTERVAL
+# This option determines how often (in seconds) Nagios will
+# attempt to automatically reschedule checks.  This option only
+# has an effect if the auto_reschedule_checks option is enabled.
+# Default is 30 seconds.
+# WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE
+# PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY
+
+auto_rescheduling_interval=30
+
+
+
+# AUTO-RESCHEDULING WINDOW
+# This option determines the "window" of time (in seconds) that
+# Nagios will look at when automatically rescheduling checks.
+# Only host and service checks that occur in the next X seconds
+# (determined by this variable) will be rescheduled. This option
+# only has an effect if the auto_reschedule_checks option is
+# enabled.  Default is 180 seconds (3 minutes).
+# WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE
+# PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY
+
+auto_rescheduling_window=180
+
+
+
+# SLEEP TIME
+# This is the number of seconds to sleep between checking for system
+# events and service checks that need to be run.
+
+sleep_time=0.25
+
+
+
+# TIMEOUT VALUES
+# These options control how much time Nagios will allow various
+# types of commands to execute before killing them off.  Options
+# are available for controlling maximum time allotted for
+# service checks, host checks, event handlers, notifications, the
+# ocsp command, and performance data commands.  All values are in
+# seconds.
+
+service_check_timeout=60
+host_check_timeout=30
+event_handler_timeout=30
+notification_timeout=30
+ocsp_timeout=5
+perfdata_timeout=5
+
+
+
+# RETAIN STATE INFORMATION
+# This setting determines whether or not Nagios will save state
+# information for services and hosts before it shuts down.  Upon
+# startup Nagios will reload all saved service and host state
+# information before starting to monitor.  This is useful for 
+# maintaining long-term data on state statistics, etc, but will
+# slow Nagios down a bit when it (re)starts.  Since its only
+# a one-time penalty, I think its well worth the additional
+# startup delay.
+
+retain_state_information=1
+
+
+
+# STATE RETENTION FILE
+# This is the file that Nagios should use to store host and
+# service state information before it shuts down.  The state 
+# information in this file is also read immediately prior to
+# starting to monitor the network when Nagios is restarted.
+# This file is used only if the retain_state_information
+# variable is set to 1.
+
+state_retention_file=/var/log/nagios/retention.dat
+
+
+
+# RETENTION DATA UPDATE INTERVAL
+# This setting determines how often (in minutes) that Nagios
+# will automatically save retention data during normal operation.
+# If you set this value to 0, Nagios will not save retention
+# data at regular interval, but it will still save retention
+# data before shutting down or restarting.  If you have disabled
+# state retention, this option has no effect.
+
+retention_update_interval=60
+
+
+
+# USE RETAINED PROGRAM STATE
+# This setting determines whether or not Nagios will set 
+# program status variables based on the values saved in the
+# retention file.  If you want to use retained program status
+# information, set this value to 1.  If not, set this value
+# to 0.
+
+use_retained_program_state=1
+
+
+
+# USE RETAINED SCHEDULING INFO
+# This setting determines whether or not Nagios will retain
+# the scheduling info (next check time) for hosts and services
+# based on the values saved in the retention file.  If you
+# If you want to use retained scheduling info, set this
+# value to 1.  If not, set this value to 0.
+
+use_retained_scheduling_info=1
+
+
+
+# RETAINED ATTRIBUTE MASKS (ADVANCED FEATURE)
+# The following variables are used to specify specific host and
+# service attributes that should *not* be retained by Nagios during
+# program restarts.
+#
+# The values of the masks are bitwise ANDs of values specified
+# by the "MODATTR_" definitions found in include/common.h.  
+# For example, if you do not want the current enabled/disabled state
+# of flap detection and event handlers for hosts to be retained, you
+# would use a value of 24 for the host attribute mask...
+# MODATTR_EVENT_HANDLER_ENABLED (8) + MODATTR_FLAP_DETECTION_ENABLED (16) = 24
+
+# This mask determines what host attributes are not retained
+retained_host_attribute_mask=0
+
+# This mask determines what service attributes are not retained
+retained_service_attribute_mask=0
+
+# These two masks determine what process attributes are not retained.
+# There are two masks, because some process attributes have host and service
+# options.  For example, you can disable active host checks, but leave active
+# service checks enabled.
+retained_process_host_attribute_mask=0
+retained_process_service_attribute_mask=0
+
+# These two masks determine what contact attributes are not retained.
+# There are two masks, because some contact attributes have host and
+# service options.  For example, you can disable host notifications for
+# a contact, but leave service notifications enabled for them.
+retained_contact_host_attribute_mask=0
+retained_contact_service_attribute_mask=0
+
+
+
+# INTERVAL LENGTH
+# This is the seconds per unit interval as used in the
+# host/contact/service configuration files.  Setting this to 60 means
+# that each interval is one minute long (60 seconds).  Other settings
+# have not been tested much, so your mileage is likely to vary...
+
+interval_length=60
+
+
+
+# CHECK FOR UPDATES
+# This option determines whether Nagios will automatically check to
+# see if new updates (releases) are available.  It is recommend that you
+# enable this option to ensure that you stay on top of the latest critical
+# patches to Nagios.  Nagios is critical to you - make sure you keep it in
+# good shape.  Nagios will check once a day for new updates. Data collected
+# by Nagios Enterprises from the update check is processed in accordance 
+# with our privacy policy - see http://api.nagios.org for details.
+
+check_for_updates=1
+
+
+
+# BARE UPDATE CHECK
+# This option deterines what data Nagios will send to api.nagios.org when
+# it checks for updates.  By default, Nagios will send information on the 
+# current version of Nagios you have installed, as well as an indicator as
+# to whether this was a new installation or not.  Nagios Enterprises uses
+# this data to determine the number of users running specific version of 
+# Nagios.  Enable this option if you do not want this information to be sent.
+
+bare_update_check=0
+
+
+
+# AGGRESSIVE HOST CHECKING OPTION
+# If you don't want to turn on aggressive host checking features, set
+# this value to 0 (the default).  Otherwise set this value to 1 to
+# enable the aggressive check option.  Read the docs for more info
+# on what aggressive host check is or check out the source code in
+# base/checks.c
+
+use_aggressive_host_checking=0
+
+
+
+# SERVICE CHECK EXECUTION OPTION
+# This determines whether or not Nagios will actively execute
+# service checks when it initially starts.  If this option is 
+# disabled, checks are not actively made, but Nagios can still
+# receive and process passive check results that come in.  Unless
+# you're implementing redundant hosts or have a special need for
+# disabling the execution of service checks, leave this enabled!
+# Values: 1 = enable checks, 0 = disable checks
+
+execute_service_checks=1
+
+
+
+# PASSIVE SERVICE CHECK ACCEPTANCE OPTION
+# This determines whether or not Nagios will accept passive
+# service checks results when it initially (re)starts.
+# Values: 1 = accept passive checks, 0 = reject passive checks
+
+accept_passive_service_checks=1
+
+
+
+# HOST CHECK EXECUTION OPTION
+# This determines whether or not Nagios will actively execute
+# host checks when it initially starts.  If this option is 
+# disabled, checks are not actively made, but Nagios can still
+# receive and process passive check results that come in.  Unless
+# you're implementing redundant hosts or have a special need for
+# disabling the execution of host checks, leave this enabled!
+# Values: 1 = enable checks, 0 = disable checks
+
+execute_host_checks=1
+
+
+
+# PASSIVE HOST CHECK ACCEPTANCE OPTION
+# This determines whether or not Nagios will accept passive
+# host checks results when it initially (re)starts.
+# Values: 1 = accept passive checks, 0 = reject passive checks
+
+accept_passive_host_checks=1
+
+
+
+# NOTIFICATIONS OPTION
+# This determines whether or not Nagios will sent out any host or
+# service notifications when it is initially (re)started.
+# Values: 1 = enable notifications, 0 = disable notifications
+
+enable_notifications=1
+
+
+
+# EVENT HANDLER USE OPTION
+# This determines whether or not Nagios will run any host or
+# service event handlers when it is initially (re)started.  Unless
+# you're implementing redundant hosts, leave this option enabled.
+# Values: 1 = enable event handlers, 0 = disable event handlers
+
+enable_event_handlers=1
+
+
+
+# PROCESS PERFORMANCE DATA OPTION
+# This determines whether or not Nagios will process performance
+# data returned from service and host checks.  If this option is
+# enabled, host performance data will be processed using the
+# host_perfdata_command (defined below) and service performance
+# data will be processed using the service_perfdata_command (also
+# defined below).  Read the HTML docs for more information on
+# performance data.
+# Values: 1 = process performance data, 0 = do not process performance data
+
+process_performance_data=0
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS
+# These commands are run after every host and service check is
+# performed.  These commands are executed only if the
+# enable_performance_data option (above) is set to 1.  The command
+# argument is the short name of a command definition that you 
+# define in your host configuration file.  Read the HTML docs for
+# more information on performance data.
+
+#host_perfdata_command=process-host-perfdata
+#service_perfdata_command=process-service-perfdata
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILES
+# These files are used to store host and service performance data.
+# Performance data is only written to these files if the
+# enable_performance_data option (above) is set to 1.
+
+#host_perfdata_file=/tmp/host-perfdata
+#service_perfdata_file=/tmp/service-perfdata
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILE TEMPLATES
+# These options determine what data is written (and how) to the
+# performance data files.  The templates may contain macros, special
+# characters (\t for tab, \r for carriage return, \n for newline)
+# and plain text.  A newline is automatically added after each write
+# to the performance data file.  Some examples of what you can do are
+# shown below.
+
+#host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$
+#service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILE MODES
+# This option determines whether or not the host and service
+# performance data files are opened in write ("w") or append ("a")
+# mode. If you want to use named pipes, you should use the special
+# pipe ("p") mode which avoid blocking at startup, otherwise you will
+# likely want the defult append ("a") mode.
+
+#host_perfdata_file_mode=a
+#service_perfdata_file_mode=a
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING INTERVAL
+# These options determine how often (in seconds) the host and service
+# performance data files are processed using the commands defined
+# below.  A value of 0 indicates the files should not be periodically
+# processed.
+
+#host_perfdata_file_processing_interval=0
+#service_perfdata_file_processing_interval=0
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING COMMANDS
+# These commands are used to periodically process the host and
+# service performance data files.  The interval at which the
+# processing occurs is determined by the options above.
+
+#host_perfdata_file_processing_command=process-host-perfdata-file
+#service_perfdata_file_processing_command=process-service-perfdata-file
+
+
+
+# OBSESS OVER SERVICE CHECKS OPTION
+# This determines whether or not Nagios will obsess over service
+# checks and run the ocsp_command defined below.  Unless you're
+# planning on implementing distributed monitoring, do not enable
+# this option.  Read the HTML docs for more information on
+# implementing distributed monitoring.
+# Values: 1 = obsess over services, 0 = do not obsess (default)
+
+obsess_over_services=0
+
+
+
+# OBSESSIVE COMPULSIVE SERVICE PROCESSOR COMMAND
+# This is the command that is run for every service check that is
+# processed by Nagios.  This command is executed only if the
+# obsess_over_services option (above) is set to 1.  The command 
+# argument is the short name of a command definition that you
+# define in your host configuration file. Read the HTML docs for
+# more information on implementing distributed monitoring.
+
+#ocsp_command=somecommand
+
+
+
+# OBSESS OVER HOST CHECKS OPTION
+# This determines whether or not Nagios will obsess over host
+# checks and run the ochp_command defined below.  Unless you're
+# planning on implementing distributed monitoring, do not enable
+# this option.  Read the HTML docs for more information on
+# implementing distributed monitoring.
+# Values: 1 = obsess over hosts, 0 = do not obsess (default)
+
+obsess_over_hosts=0
+
+
+
+# OBSESSIVE COMPULSIVE HOST PROCESSOR COMMAND
+# This is the command that is run for every host check that is
+# processed by Nagios.  This command is executed only if the
+# obsess_over_hosts option (above) is set to 1.  The command 
+# argument is the short name of a command definition that you
+# define in your host configuration file. Read the HTML docs for
+# more information on implementing distributed monitoring.
+
+#ochp_command=somecommand
+
+
+
+# TRANSLATE PASSIVE HOST CHECKS OPTION
+# This determines whether or not Nagios will translate
+# DOWN/UNREACHABLE passive host check results into their proper
+# state for this instance of Nagios.  This option is useful
+# if you have distributed or failover monitoring setup.  In
+# these cases your other Nagios servers probably have a different
+# "view" of the network, with regards to the parent/child relationship
+# of hosts.  If a distributed monitoring server thinks a host
+# is DOWN, it may actually be UNREACHABLE from the point of
+# this Nagios instance.  Enabling this option will tell Nagios
+# to translate any DOWN or UNREACHABLE host states it receives
+# passively into the correct state from the view of this server.
+# Values: 1 = perform translation, 0 = do not translate (default)
+
+translate_passive_host_checks=0
+
+
+
+# PASSIVE HOST CHECKS ARE SOFT OPTION
+# This determines whether or not Nagios will treat passive host
+# checks as being HARD or SOFT.  By default, a passive host check
+# result will put a host into a HARD state type.  This can be changed
+# by enabling this option.
+# Values: 0 = passive checks are HARD, 1 = passive checks are SOFT
+
+passive_host_checks_are_soft=0
+
+
+
+# ORPHANED HOST/SERVICE CHECK OPTIONS
+# These options determine whether or not Nagios will periodically 
+# check for orphaned host service checks.  Since service checks are
+# not rescheduled until the results of their previous execution 
+# instance are processed, there exists a possibility that some
+# checks may never get rescheduled.  A similar situation exists for
+# host checks, although the exact scheduling details differ a bit
+# from service checks.  Orphaned checks seem to be a rare
+# problem and should not happen under normal circumstances.
+# If you have problems with service checks never getting
+# rescheduled, make sure you have orphaned service checks enabled.
+# Values: 1 = enable checks, 0 = disable checks
+
+check_for_orphaned_services=1
+check_for_orphaned_hosts=1
+
+
+
+# SERVICE FRESHNESS CHECK OPTION
+# This option determines whether or not Nagios will periodically
+# check the "freshness" of service results.  Enabling this option
+# is useful for ensuring passive checks are received in a timely
+# manner.
+# Values: 1 = enabled freshness checking, 0 = disable freshness checking
+
+check_service_freshness=1
+
+
+
+# SERVICE FRESHNESS CHECK INTERVAL
+# This setting determines how often (in seconds) Nagios will
+# check the "freshness" of service check results.  If you have
+# disabled service freshness checking, this option has no effect.
+
+service_freshness_check_interval=60
+
+
+
+# SERVICE CHECK TIMEOUT STATE
+# This setting determines the state Nagios will report when a
+# service check times out - that is does not respond within
+# service_check_timeout seconds.  This can be useful if a
+# machine is running at too high a load and you do not want
+# to consider a failed service check to be critical (the default).
+# Valid settings are:
+# c - Critical (default)
+# u - Unknown
+# w - Warning
+# o - OK
+
+service_check_timeout_state=c
+
+
+
+# HOST FRESHNESS CHECK OPTION
+# This option determines whether or not Nagios will periodically
+# check the "freshness" of host results.  Enabling this option
+# is useful for ensuring passive checks are received in a timely
+# manner.
+# Values: 1 = enabled freshness checking, 0 = disable freshness checking
+
+check_host_freshness=0
+
+
+
+# HOST FRESHNESS CHECK INTERVAL
+# This setting determines how often (in seconds) Nagios will
+# check the "freshness" of host check results.  If you have
+# disabled host freshness checking, this option has no effect.
+
+host_freshness_check_interval=60
+
+
+
+
+# ADDITIONAL FRESHNESS THRESHOLD LATENCY
+# This setting determines the number of seconds that Nagios
+# will add to any host and service freshness thresholds that
+# it calculates (those not explicitly specified by the user).
+
+additional_freshness_latency=15
+
+
+
+
+# FLAP DETECTION OPTION
+# This option determines whether or not Nagios will try
+# and detect hosts and services that are "flapping".  
+# Flapping occurs when a host or service changes between
+# states too frequently.  When Nagios detects that a 
+# host or service is flapping, it will temporarily suppress
+# notifications for that host/service until it stops
+# flapping.  Flap detection is very experimental, so read
+# the HTML documentation before enabling this feature!
+# Values: 1 = enable flap detection
+#         0 = disable flap detection (default)
+
+enable_flap_detection=1
+
+
+
+# FLAP DETECTION THRESHOLDS FOR HOSTS AND SERVICES
+# Read the HTML documentation on flap detection for
+# an explanation of what this option does.  This option
+# has no effect if flap detection is disabled.
+
+low_service_flap_threshold=5.0
+high_service_flap_threshold=20.0
+low_host_flap_threshold=5.0
+high_host_flap_threshold=20.0
+
+
+
+# DATE FORMAT OPTION
+# This option determines how short dates are displayed. Valid options
+# include:
+#      us              (MM-DD-YYYY HH:MM:SS)
+#      euro            (DD-MM-YYYY HH:MM:SS)
+#      iso8601         (YYYY-MM-DD HH:MM:SS)
+#      strict-iso8601  (YYYY-MM-DDTHH:MM:SS)
+#
+
+date_format=us
+
+
+
+
+# TIMEZONE OFFSET
+# This option is used to override the default timezone that this
+# instance of Nagios runs in.  If not specified, Nagios will use
+# the system configured timezone.
+#
+# NOTE: In order to display the correct timezone in the CGIs, you
+# will also need to alter the Apache directives for the CGI path 
+# to include your timezone.  Example:
+#
+#   <Directory "/usr/local/nagios/sbin/">
+#      SetEnv TZ "Australia/Brisbane"
+#      ...
+#   </Directory>
+
+#use_timezone=US/Mountain
+#use_timezone=Australia/Brisbane
+
+
+
+
+# P1.PL FILE LOCATION
+# This value determines where the p1.pl perl script (used by the
+# embedded Perl interpreter) is located.  If you didn't compile
+# Nagios with embedded Perl support, this option has no effect.
+
+p1_file=/usr/sbin/p1.pl
+
+
+
+# EMBEDDED PERL INTERPRETER OPTION
+# This option determines whether or not the embedded Perl interpreter
+# will be enabled during runtime.  This option has no effect if Nagios
+# has not been compiled with support for embedded Perl.
+# Values: 0 = disable interpreter, 1 = enable interpreter
+
+enable_embedded_perl=1
+
+
+
+# EMBEDDED PERL USAGE OPTION
+# This option determines whether or not Nagios will process Perl plugins
+# and scripts with the embedded Perl interpreter if the plugins/scripts
+# do not explicitly indicate whether or not it is okay to do so. Read
+# the HTML documentation on the embedded Perl interpreter for more 
+# information on how this option works.
+
+use_embedded_perl_implicitly=1
+
+
+
+# ILLEGAL OBJECT NAME CHARACTERS
+# This option allows you to specify illegal characters that cannot
+# be used in host names, service descriptions, or names of other
+# object types.
+
+illegal_object_name_chars=`~!$%^&*|'"<>?,()=
+
+
+
+# ILLEGAL MACRO OUTPUT CHARACTERS
+# This option allows you to specify illegal characters that are
+# stripped from macros before being used in notifications, event
+# handlers, etc.  This DOES NOT affect macros used in service or
+# host check commands.
+# The following macros are stripped of the characters you specify:
+#      $HOSTOUTPUT$
+#      $HOSTPERFDATA$
+#      $HOSTACKAUTHOR$
+#      $HOSTACKCOMMENT$
+#      $SERVICEOUTPUT$
+#      $SERVICEPERFDATA$
+#      $SERVICEACKAUTHOR$
+#      $SERVICEACKCOMMENT$
+
+illegal_macro_output_chars=`~$&|'"<>
+
+
+
+# REGULAR EXPRESSION MATCHING
+# This option controls whether or not regular expression matching
+# takes place in the object config files.  Regular expression
+# matching is used to match host, hostgroup, service, and service
+# group names/descriptions in some fields of various object types.
+# Values: 1 = enable regexp matching, 0 = disable regexp matching
+
+use_regexp_matching=<%= node['nagios']['use_regexp_matching'] %>
+
+
+
+# "TRUE" REGULAR EXPRESSION MATCHING
+# This option controls whether or not "true" regular expression 
+# matching takes place in the object config files.  This option
+# only has an effect if regular expression matching is enabled
+# (see above).  If this option is DISABLED, regular expression
+# matching only occurs if a string contains wildcard characters
+# (* and ?).  If the option is ENABLED, regexp matching occurs
+# all the time (which can be annoying).
+# Values: 1 = enable true matching, 0 = disable true matching
+
+use_true_regexp_matching=0
+
+
+
+# ADMINISTRATOR EMAIL/PAGER ADDRESSES
+# The email and pager address of a global administrator (likely you).
+# Nagios never uses these values itself, but you can access them by
+# using the $ADMINEMAIL$ and $ADMINPAGER$ macros in your notification
+# commands.
+
+admin_email=nagios@localhost
+admin_pager=pagenagios@localhost
+
+
+
+# DAEMON CORE DUMP OPTION
+# This option determines whether or not Nagios is allowed to create
+# a core dump when it runs as a daemon.  Note that it is generally
+# considered bad form to allow this, but it may be useful for
+# debugging purposes.  Enabling this option doesn't guarantee that
+# a core file will be produced, but that's just life...
+# Values: 1 - Allow core dumps
+#         0 - Do not allow core dumps (default)
+
+daemon_dumps_core=0
+
+
+
+# LARGE INSTALLATION TWEAKS OPTION
+# This option determines whether or not Nagios will take some shortcuts
+# which can save on memory and CPU usage in large Nagios installations.
+# Read the documentation for more information on the benefits/tradeoffs
+# of enabling this option.
+# Values: 1 - Enabled tweaks
+#         0 - Disable tweaks (default)
+
+use_large_installation_tweaks=0
+
+
+
+# ENABLE ENVIRONMENT MACROS
+# This option determines whether or not Nagios will make all standard
+# macros available as environment variables when host/service checks
+# and system commands (event handlers, notifications, etc.) are
+# executed.  Enabling this option can cause performance issues in 
+# large installations, as it will consume a bit more memory and (more
+# importantly) consume more CPU.
+# Values: 1 - Enable environment variable macros (default)
+#         0 - Disable environment variable macros
+
+enable_environment_macros=1
+
+
+
+# CHILD PROCESS MEMORY OPTION
+# This option determines whether or not Nagios will free memory in
+# child processes (processed used to execute system commands and host/
+# service checks).  If you specify a value here, it will override
+# program defaults.
+# Value: 1 - Free memory in child processes
+#        0 - Do not free memory in child processes
+
+#free_child_process_memory=1
+
+
+
+# CHILD PROCESS FORKING BEHAVIOR
+# This option determines how Nagios will fork child processes
+# (used to execute system commands and host/service checks).  Normally
+# child processes are fork()ed twice, which provides a very high level
+# of isolation from problems.  Fork()ing once is probably enough and will
+# save a great deal on CPU usage (in large installs), so you might
+# want to consider using this.  If you specify a value here, it will
+# program defaults.
+# Value: 1 - Child processes fork() twice
+#        0 - Child processes fork() just once
+
+#child_processes_fork_twice=1
+
+
+
+# DEBUG LEVEL
+# This option determines how much (if any) debugging information will
+# be written to the debug file.  OR values together to log multiple
+# types of information.
+# Values: 
+#          -1 = Everything
+#          0 = Nothing
+#         1 = Functions
+#          2 = Configuration
+#          4 = Process information
+#         8 = Scheduled events
+#          16 = Host/service checks
+#          32 = Notifications
+#          64 = Event broker
+#          128 = External commands
+#          256 = Commands
+#          512 = Scheduled downtime
+#          1024 = Comments
+#          2048 = Macros
+
+debug_level=0
+
+
+
+# DEBUG VERBOSITY
+# This option determines how verbose the debug log out will be.
+# Values: 0 = Brief output
+#         1 = More detailed
+#         2 = Very detailed
+
+debug_verbosity=1
+
+
+
+# DEBUG FILE
+# This option determines where Nagios should write debugging information.
+
+debug_file=/var/log/nagios/nagios.debug
+
+
+
+# MAX DEBUG FILE SIZE
+# This option determines the maximum size (in bytes) of the debug file.  If
+# the file grows larger than this size, it will be renamed with a .old
+# extension.  If a file already exists with a .old extension it will
+# automatically be deleted.  This helps ensure your disk space usage doesn't
+# get out of control when debugging Nagios.
+
+max_debug_file_size=1000000
+
+
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios/check_logs/check_logs.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios/check_logs/check_logs.cfg
new file mode 100644 (file)
index 0000000..cded20b
--- /dev/null
@@ -0,0 +1,30 @@
+# $Id$
+
+$seek_file_template='/var/lib/nagios/$log_file.check_log.seek';
+
+# Required log files array
+@log_files = (
+    {
+        'file_name' => '/var/log/messages',
+        'reg_exp' => '(WARNING|CRITICAL)',
+#        'lines' => 2,               #optional number of output lines  after match
+#        'new_line_reg_exp' => '^',  #optional new line regex to stop output lines
+#        'seek_file_suffix' => '2'   #optional seek file suffix
+    },
+<%
+node['nagios']['nrpe']['check_logs']['log_files'].each {|log_file|
+-%>
+    {
+<%
+  log_file.each {|key, value|
+-%>
+        '<%= key %>' => '<%= value %>',
+<%
+  }
+-%>
+    },
+<%
+}
+-%>
+);
+1;
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios/nrpe_local.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios/nrpe_local.cfg
new file mode 100644 (file)
index 0000000..f5387a4
--- /dev/null
@@ -0,0 +1,64 @@
+# $Id$
+
+allowed_hosts=<%= node['nagios']['nrpe']['allowed_hosts'] %>
+
+command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w <%= node['nagios']['nrpe']['check_total_procs']['warn'] %> -c <%= node['nagios']['nrpe']['check_total_procs']['crit'] %>
+command[check_memory]=/usr/lib/nagios/plugins/check_memory
+
+command[check_apt]=/usr/lib/nagios/plugins/check_apt
+
+# Disk
+<%
+(0..3).each {|num|
+  target = node['nagios']['nrpe']["check_disk#{num}"]
+-%>
+command[check_disk<%= num %>]=/usr/lib/nagios/plugins/check_disk -w <%= target['warn'] %> -c <%= target['crit']%> -p <%= target['path'] %> <%= target['extra_opts'] %>
+<%
+}
+-%>
+<%
+(0..3).each {|num|
+  target = node['nagios']['nrpe']["check_smart#{num}"]
+-%>
+command[check_smart<%= num %>]=sudo /usr/lib/nagios/plugins/check_ide_smart -n -d <%= target['device'] %>
+<%
+}
+-%>
+command[check_smart_devs]=sudo /usr/lib/nagios/plugins/check_smart.pl -g '/dev/sd[a-c]' -i scsi
+
+# DNS lookup
+<%
+dig = node['nagios']['nrpe']['check_dig']
+dig_in = node['nagios']['nrpe']['check_dig_in']
+dig_ex = node['nagios']['nrpe']['check_dig_ex']
+-%>
+command[check_dig]=/usr/lib/nagios/plugins/check_dig -H <%= dig['host'] %> -l <%= dig['lookup'] %>
+command[check_dig_in]=/usr/lib/nagios/plugins/check_dig -H <%= dig_in['host'] %> -l <%= dig_in['lookup'] %>
+command[check_dig_ex]=/usr/lib/nagios/plugins/check_dig -H <%= dig_ex['host'] %> -l <%= dig_ex['lookup'] %>
+
+# APC
+command[check_apc_status]=/usr/lib/nagios/plugins/check_apc status
+command[check_apc_load]=/usr/lib/nagios/plugins/check_apc load 75 85
+command[check_apc_bcharge]=/usr/lib/nagios/plugins/check_apc bcharge 60 40
+command[check_apc_time]=/usr/lib/nagios/plugins/check_apc time 10 5
+
+# Local messages logs
+command[check_logs]=/usr/lib/nagios/plugins/check_logs.pl -c /etc/nagios/check_logs/check_logs.cfg
+
+# Local Mail Queue
+command[check_mailq_exim]=sudo /usr/lib/nagios/plugins/check_mailq -w 5 -c 10 -M exim
+command[check_mailq_postfix]=/usr/lib/nagios/plugins/check_mailq -w 5 -c 10 -M postfix
+command[check_mailq_qmail]=/usr/lib/nagios/plugins/check_mailq -w 5 -c 10 -M qmail
+command[check_mailq_sendmail]=/usr/lib/nagios/plugins/check_mailq -w 5 -c 10 -M sendmail
+
+# Local MySQL
+command[check_mysql_heartbeat]=/usr/lib/nagios/plugins/check_mysql_heartbeat.pl -H localhost -w 60 -c 90
+
+# Local JBoss
+#command[check_jboss_freemem]=/usr/lib/nagios/plugins/check_jbossjmx localhost 4 "jboss.system:type=ServerInfo" FreeMemory 33554432 16777216 -r
+#command[check_jboss_freemem]=/usr/lib/nagios/plugins/negate /usr/lib/nagios/plugins/check_jbossjmx localhost 4 "jboss.system:type=ServerInfo" FreeMemory 134217728 16777216
+#command[check_jboss_jk_curthread]=/usr/lib/nagios/plugins/check_jbossjmx localhost 4 "jboss.web:name=jk-127.0.0.1-8009,type=ThreadPool" currentThreadCount 100 200
+#command[check_jboss_ds_conn1]=/usr/lib/nagios/plugins/check_jbossjmx localhost 4 "jboss.jca:name=env/jdbc/accountbook,service=ManagedConnectionPool" InUseConnectionCount 50 90
+#command[check_jboss_ds_conn2]=/usr/lib/nagios/plugins/check_jbossjmx localhost 4 "jboss.jca:name=env/jdbc/accountbook,service=ManagedConnectionPool" InUseConnectionCount 50 90
+command[check_jboss_logs]=/usr/lib/nagios/plugins/check_logs.pl -c /etc/nagios/check_logs/jboss_check_logs.cfg
+
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/apache2.conf b/cookbooks/nagios-grid/templates/default/etc/nagios3/apache2.conf
new file mode 100644 (file)
index 0000000..58b8a42
--- /dev/null
@@ -0,0 +1,94 @@
+# apache configuration for nagios 3.x
+# note to users of nagios 1.x and 2.x:
+#      throughout this file are commented out sections which preserve
+#      backwards compatibility with bookmarks/config for older nagios versios.
+#      simply look for lines following "nagios 1.x:" and "nagios 2.x" comments.
+
+ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
+ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
+# nagios 1.x:
+#ScriptAlias /cgi-bin/nagios /usr/lib/cgi-bin/nagios3
+#ScriptAlias /nagios/cgi-bin /usr/lib/cgi-bin/nagios3
+# nagios 2.x: 
+#ScriptAlias /cgi-bin/nagios2 /usr/lib/cgi-bin/nagios3
+#ScriptAlias /nagios2/cgi-bin /usr/lib/cgi-bin/nagios3
+
+# Where the stylesheets (config files) reside
+Alias /nagios3/stylesheets /etc/nagios3/stylesheets
+# nagios 1.x:
+#Alias /nagios/stylesheets /etc/nagios3/stylesheets
+# nagios 2.x:
+#Alias /nagios2/stylesheets /etc/nagios3/stylesheets
+
+# Where the HTML pages live
+Alias /nagios3 /usr/share/nagios3/htdocs
+# nagios 2.x: 
+#Alias /nagios2 /usr/share/nagios3/htdocs
+# nagios 1.x:
+#Alias /nagios /usr/share/nagios3/htdocs
+
+<DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
+       Options FollowSymLinks
+
+       DirectoryIndex index.php index.html
+
+       AllowOverride AuthConfig
+
+
+    <IfVersion < 2.3>
+        Order <%= node['nagios']['web']['Order'] %>
+<% node['nagios']['web']['Deny'].each do |from_where| -%>
+        Deny <%= from_where %>
+<% end -%>
+<% node['nagios']['web']['Allow'].each do |from_where| -%>
+        Allow <%= from_where %>
+<% end -%>
+    </IfVersion>
+
+    <IfVersion >= 2.3>
+<% node['nagios']['web']['Require'].each do |condition| -%>
+        Require <%= condition %>
+<% end -%>
+    </IfVersion>
+
+       #AuthName "Nagios Access"
+       #AuthType Basic
+       #AuthUserFile /etc/nagios3/htpasswd.users
+       # nagios 1.x:
+       #AuthUserFile /etc/nagios/htpasswd.users
+       #require valid-user
+<%
+case node['nagios']['web']['AuthType']
+  when 'Basic'
+-%>
+       AuthName "Nagios Access"
+       AuthType Basic
+       AuthUserFile <%= node['nagios']['web']['mod_auth_basic']['AuthUserFile'] %>
+       Require valid-user
+<%
+  when 'Kerberos'
+-%>
+       AuthName "Nagios Access"
+       AuthType Kerberos
+       KrbAuthRealms <%= node['nagios']['web']['mod_auth_kerb']['KrbAuthRealms'] %>
+       KrbServiceName <%= node['nagios']['web']['mod_auth_kerb']['KrbServiceName'] %>
+       Krb5Keytab <%= node['nagios']['web']['mod_auth_kerb']['Krb5Keytab'] %>
+       KrbMethodNegotiate <%= node['nagios']['web']['mod_auth_kerb']['KrbMethodNegotiate'] %>
+       KrbMethodK5Passwd <%= node['nagios']['web']['mod_auth_kerb']['KrbMethodK5Passwd'] %>
+       Require valid-user
+<% end -%>
+</DirectoryMatch>
+
+<Directory /usr/share/nagios3/htdocs>
+       Options +ExecCGI
+</Directory>
+
+# Enable this ScriptAlias if you want to enable the grouplist patch.
+# See http://apan.sourceforge.net/download.html for more info
+# It allows you to see a clickable list of all hostgroups in the
+# left pane of the Nagios web interface
+# XXX This is not tested for nagios 2.x use at your own peril
+#ScriptAlias /nagios3/side.html /usr/lib/cgi-bin/nagios3/grouplist.cgi
+# nagios 1.x:
+#ScriptAlias /nagios/side.html /usr/lib/cgi-bin/nagios3/grouplist.cgi
+
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/base/checkcommands-generic.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/base/checkcommands-generic.cfg
new file mode 100644 (file)
index 0000000..7730f10
--- /dev/null
@@ -0,0 +1,217 @@
+# $Id$
+
+define command {
+       command_name    check_file_age
+       command_line    $USER1$/check_file_age -f $ARG1$ -w $ARG2$ -c $ARG3$
+}
+
+define command {
+       command_name    check_ntp_time
+       command_line    $USER1$/check_ntp_time -H $HOSTADDRESS$
+}
+
+define command {
+       command_name    check_tcp_port_cert
+       command_line    $USER1$/check_tcp --ssl -H $HOSTADDRESS$ -p $ARG1$ -D $ARG2$
+}
+
+define command {
+       command_name    check_http_port
+       command_line    $USER1$/check_http -H $HOSTADDRESS$ -I $HOSTADDRESS$ -p $ARG1$
+}
+
+define command {
+       command_name    check_http_port_url
+       command_line    $USER1$/check_http -H $HOSTADDRESS$ -I $HOSTADDRESS$ -p $ARG1$ -u $ARG2$
+}
+
+define command {
+       command_name    check_https_port
+       command_line    $USER1$/check_http --ssl -H $HOSTADDRESS$ -I $HOSTADDRESS$ -p $ARG1$
+}
+
+define command {
+       command_name    check_https_port_url
+       command_line    $USER1$/check_http --ssl -H $HOSTADDRESS$ -I $HOSTADDRESS$ -p $ARG1$ -u $ARG2$
+}
+
+define command {
+       command_name    check_https_port_cert
+       command_line    $USER1$/check_http --ssl -H $HOSTADDRESS$ -I $HOSTADDRESS$ -p $ARG1$ -C $ARG2$
+}
+
+define command {
+       command_name    check_ldap3
+       command_line    $USER1$/check_ldap -H $HOSTADDRESS$ -b $ARG1$ -3
+}
+
+# this object already exists on the Debian wheezy.
+#define command {
+#      command_name    check_mysql_slave
+#      command_line    $USER1$/check_mysql -H $HOSTADDRESS$ -S
+#}
+
+# 'check_jbossjmx' command definition 
+define command {
+       command_name    check_jbossjmx 
+       command_line    $USER1$/check_jbossjmx $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ 
+}
+
+define command {
+       command_name    check_ups
+       command_line    $USER1$/check_ups -H $HOSTADDRESS$ -u $ARG1$ -T
+}
+
+# NRPE
+define command {
+       command_name    check_remote_apt
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_apt
+}
+
+define command {
+       command_name    check_remote_apc_status
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_apc_status
+}
+
+define command {
+       command_name    check_remote_apc_load
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_apc_load
+}
+
+define command {
+       command_name    check_remote_apc_bcharge
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_apc_bcharge
+}
+
+define command {
+       command_name    check_remote_apc_time
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_apc_time
+}
+
+define command {
+       command_name    check_remote_dig
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_dig
+}
+
+define command {
+       command_name    check_remote_dig_in
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_dig_in
+}
+
+define command {
+       command_name    check_remote_dig_ex
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_dig_ex
+}
+
+define command {
+       command_name    check_remote_logs
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_logs
+}
+
+define command {
+       command_name    check_remote_command
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
+}
+
+define command {
+       command_name    check_remote_users
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_users
+}
+
+define command {
+       command_name    check_remote_load
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_load
+}
+
+define command {
+       command_name    check_remote_memory
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_memory
+}
+
+<%
+(0..3).each {|num|
+-%>
+define command {
+       command_name    check_remote_disk<%= num %>
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_disk<%= num %>
+}
+
+<%
+}
+-%>
+<%
+(0..3).each {|num|
+-%>
+define command {
+       command_name    check_remote_smart<%= num %>
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_smart<%= num %>
+}
+
+<%
+}
+-%>
+define command {
+       command_name    check_remote_smart_devs
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_smart_devs
+}
+
+define command {
+       command_name    check_remote_zombie_procs
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_zombie_procs
+}
+
+define command {
+       command_name    check_remote_total_procs
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_total_procs
+}
+
+define command {
+       command_name    check_remote_mailq_exim
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_mailq_exim
+}
+
+define command {
+       command_name    check_remote_mailq_postfix
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_mailq_postfix
+}
+
+define command {
+       command_name    check_remote_mysql_heartbeat
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_mysql_heartbeat
+}
+
+define command {
+       command_name    check_remote_jboss_freemem
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_jboss_freemem
+}
+
+define command {
+       command_name    check_remote_jboss_jk_curthread
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_jboss_jk_curthread
+}
+
+define command {
+       command_name    check_remote_jboss_ds_conn1
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_jboss_ds_conn1
+}
+
+define command {
+       command_name    check_remote_jboss_ds_conn2
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_jboss_ds_conn2
+}
+
+define command {
+       command_name    check_remote_jboss_logs
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_jboss_logs
+}
+
+define command {
+       command_name    check_remote_xen_dom0 
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_xen_dom0
+}
+
+define command {
+       command_name    check_remote_xen_domU1 
+       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_xen_domU1
+}
+
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/base/hosts-generic.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/base/hosts-generic.cfg
new file mode 100644 (file)
index 0000000..eef4966
--- /dev/null
@@ -0,0 +1,18 @@
+# $Id$
+
+define host {
+       name        generic-base-host
+       use         generic-host
+
+       alias                   Base host
+       check_command           check-host-alive
+       max_check_attempts      20
+       notification_interval   60
+       notification_period     24x7
+       notification_options    d,u,r
+<% if node['nagios']['with_pnp4nagios'] then -%>
+       action_url              /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
+<% end -%>
+       register                0
+}
+
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/base/services-generic.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/base/services-generic.cfg
new file mode 100644 (file)
index 0000000..2d1fa69
--- /dev/null
@@ -0,0 +1,479 @@
+# $Id$
+
+define service {
+       name            generic-base-service
+       use             generic-service
+
+       is_volatile             0
+       check_period            24x7
+       max_check_attempts      3
+       normal_check_interval   2
+       retry_check_interval    1
+       contact_groups          <%= node['nagios']['objects']['default_contact_groups'] %>
+       notification_interval   240
+       notification_period     24x7
+       notification_options    w,u,c,r
+<% if node['nagios']['with_pnp4nagios'] then -%>
+       action_url      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
+<% end -%>
+       register                0
+}
+
+define service {
+       name            generic-ping-service
+       use             generic-base-service
+
+       service_description     PING
+       max_check_attempts      3
+       normal_check_interval   5
+       retry_check_interval    1
+       notification_options    c,r
+       check_command           check_ping!100.0,20%!500.0,60%
+       register                0
+}
+
+define service {
+       name            generic-tcp-port-cert-service
+       use             generic-base-service
+
+       service_description     TCP_Cert
+       check_command           check_tcp_port_cert!443!30
+       register                0
+}
+
+define service {
+       name            generic-ssh-service
+       use             generic-base-service
+
+       service_description     SSH
+       check_command           check_ssh
+       register                0
+}
+
+define service {
+       name            generic-http-service
+       use             generic-base-service
+
+       service_description     HTTP
+       check_command           check_http
+       register                0
+}
+
+define service {
+       name            generic-http-port-service
+       use             generic-http-service
+
+       service_description             HTTP_80
+       check_command                   check_http_port!80
+       register                0
+}
+
+define service {
+       name            generic-https-service
+       use             generic-base-service
+
+       service_description     HTTPS
+       check_command           check_https
+       register                0
+}
+
+define service {
+       name            generic-https-port-service
+       use             generic-https-service
+
+       service_description     HTTPS_443
+       check_command           check_https_port!443
+       register                0
+}
+
+define service {
+       name            generic-https-port-cert-service
+       use             generic-https-service
+
+       service_description     HTTPS_443_cert
+       check_command           check_https_port_cert!443!30
+       register                0
+}
+
+define service {
+       name            generic-https-port6280-cert-service
+       use             generic-https-service
+
+       service_description     HTTPS_6280_cert
+       check_command           check_https_port_cert!6280!30
+       register                0
+}
+
+# MySQL
+define service {
+       name            generic-mysql-service
+       use             generic-base-service
+
+       service_description     MySQL
+       check_command           check_mysql
+       register                0
+}
+
+define service {
+       name            generic-mysql-slave-service
+       use             generic-base-service
+
+       service_description     MySQL_Slave
+       check_command           check_mysql_slave
+       register                0
+}
+
+define service {
+       name            generic-remote-mysql-heartbeat-service
+       use             generic-mysql-service
+
+       service_description     MySQL_Heartbeat
+       normal_check_interval   1
+       check_command           check_remote_mysql_heartbeat
+       register                0
+}
+
+define service {
+       name            generic-ntp-service
+       use             generic-base-service
+
+       service_description     NTP
+       max_check_attempts      3
+       normal_check_interval   5
+       retry_check_interval    3
+       check_command           check_ntp_time
+       register                0
+}
+
+define service {
+       name            generic-smtp-service
+       use             generic-base-service
+
+       service_description     SMTP
+       check_command           check_smtp
+       register                0
+}
+
+define service {
+       name            generic-spop-service
+       use             generic-base-service
+
+       service_description     SPOP
+       check_command           check_spop
+       register                0
+}
+
+define service {
+       name            generic-simap-service
+       use             generic-base-service
+
+       service_description     SIMAP
+       check_command           check_simap
+       register                0
+}
+
+define service {
+       name            generic-ldap-service
+       use             generic-base-service
+
+       service_description     LDAP
+       check_command           check_ldap!<%= node['nagios']['objects']['check_ldap']['base'] %>
+       register                0
+}
+
+define service {
+       name            generic-ups-service
+       use             generic-base-service
+
+       service_description     UPS
+       check_command           check_ups!by80s
+       register                0
+}
+
+# NRPE
+define service {
+       name            generic-nrpe-service
+       use             generic-base-service
+
+       service_description     NRPE
+       max_check_attempts      3
+       normal_check_interval   5
+       retry_check_interval    1
+       check_command           check_remote_load
+       register                0
+}
+
+define service {
+       name            generic-remote-apt-service
+       use             generic-nrpe-service
+
+       service_description     APT
+       normal_check_interval   180
+       retry_check_interval    60
+       check_command           check_remote_apt
+       register                0
+}
+
+define service {
+       name            generic-remote-apc-status-service
+       use             generic-nrpe-service
+
+       service_description     APC_Status
+       check_command           check_remote_apc_status
+       register                0
+}
+
+define service {
+       name            generic-remote-apc-load-service
+       use             generic-nrpe-service
+
+       service_description     APC_Load
+       check_command           check_remote_apc_load
+       register                0
+}
+
+define service {
+       name            generic-remote-apc-bcharge-service
+       use             generic-nrpe-service
+
+       service_description     APC_BatteryCharge
+       check_command           check_remote_apc_bcharge
+       register                0
+}
+
+define service {
+       name            generic-remote-apc-time-service
+       use             generic-nrpe-service
+
+       service_description     APC_Time
+       check_command           check_remote_apc_time
+       register                0
+}
+
+define service {
+       name            generic-remote-dig-service
+       use             generic-nrpe-service
+
+       service_description     DIG
+       check_command           check_remote_dig
+       register                0
+}
+
+define service {
+       name            generic-remote-dig-in-service
+       use             generic-nrpe-service
+
+       service_description     DIG_IN
+       check_command           check_remote_dig_in     
+       register                0
+}
+
+define service {
+       name            generic-remote-dig-ex-service
+       use             generic-nrpe-service
+
+       service_description     DIG_EX
+       check_command           check_remote_dig_ex
+       register                0
+}
+
+define service {
+       name            generic-remote-logs-service
+       use             generic-nrpe-service
+
+       service_description     Logs
+       max_check_attempts      1
+       notification_options    w,u,c
+       check_command           check_remote_logs
+       register                0
+}
+
+define service {
+       name            generic-remote-load-service
+       use             generic-nrpe-service
+
+       service_description     Load_Avrg
+       check_command           check_remote_load
+       register                0
+}
+
+define service {
+       name            generic-remote-users-service
+       use             generic-nrpe-service
+
+       service_description     Users
+       check_command           check_remote_users
+       register                0
+}
+
+<%
+(0..3).each {|num|
+-%>
+define service {
+       name            generic-remote-disk<%= num %>-service
+       use             generic-nrpe-service
+
+       service_description     Disk<%= num %>
+       check_command           check_remote_disk<%= num %>
+       register                0
+}
+
+<%
+}
+-%>
+<%
+(0..3).each {|num|
+-%>
+define service {
+       name            generic-remote-smart<%= num %>-service
+       use             generic-nrpe-service
+
+       service_description     SMART<%= num %>
+       normal_check_interval   10
+       retry_check_interval    5
+       check_command           check_remote_smart<%= num %>
+       register                0
+}
+
+<%
+}
+-%>
+define service {
+       name            generic-remote-smart-devs-service
+       use             generic-nrpe-service
+
+       service_description     SMART_Devs
+       normal_check_interval   10
+       retry_check_interval    5
+       check_command           check_remote_smart_devs
+       register                0
+}
+
+define service {
+       name            generic-remote-zombie-procs-service
+       use             generic-nrpe-service
+
+       service_description     Zombie_Procs
+       check_command           check_remote_zombie_procs
+       register                0
+}
+
+define service {
+       name            generic-remote-total-procs-service
+       use             generic-nrpe-service
+
+       service_description     Total_Procs
+       check_command           check_remote_total_procs
+       register                0
+}
+
+define service {
+       name            generic-remote-memory-service
+       use             generic-nrpe-service
+
+       service_description     Memory
+       check_command           check_remote_memory
+       register                0
+}
+
+define service {
+       name            generic-remote-mailq-exim-service
+       use             generic-nrpe-service
+
+       service_description     Exim_Queue
+       check_command           check_remote_mailq_exim
+       register                0
+}
+
+define service {
+       name            generic-remote-mailq-postfix-service
+       use             generic-nrpe-service
+
+       service_description     Postfix_Queue
+       check_command           check_remote_mailq_postfix
+       register                0
+}
+
+define service {
+       name            generic-remote-xen-dom0-service
+       use             generic-nrpe-service
+
+       service_description     Xen_dom0
+       check_command           check_remote_xen_dom0
+       register                0
+}
+
+define service {
+       name            generic-remote-xen-domU1-service
+       use             generic-nrpe-service
+
+       service_description     Xen_domU1
+       check_command           check_remote_xen_domU1
+       register                0
+}
+
+# JBoss
+define service {
+       name                    generic-jboss-service
+       use                             generic-base-service
+
+       service_description     JBoss
+       register                0
+}
+
+define service{
+       name                    generic-remote-jboss-freemem-service
+       use                             generic-jboss-service
+
+       service_description     JBoss_FreeMem
+       check_command                   check_remote_jboss_freemem
+       register                0
+}
+
+define service{
+       name                    generic-remote-jboss-jk-curthread-service
+       use                             generic-jboss-service
+
+       service_description     JBoss_JK_CurThread
+       check_command                   check_remote_jboss_jk_curthread
+       register                0
+}
+
+define service{
+       name                    generic-remote-jboss-ds-conn1-service
+       use                             generic-jboss-service
+
+       service_description     JBoss_DS_Conn1
+       check_command                   check_remote_jboss_ds_conn1
+       register                0
+}
+
+define service{
+       name                    generic-remote-jboss-ds-conn2-service
+       use                             generic-jboss-service
+
+       service_description     JBoss_DS_Conn2
+       check_command                   check_remote_jboss_ds_conn2
+       register                0
+}
+
+define service{
+       name                    generic-remote-jboss-logs-service
+       use                             generic-jboss-service
+
+       service_description     JBoss_Logs
+       max_check_attempts      1
+       notification_options    w,u,c
+       check_command                   check_remote_jboss_logs
+       register                0
+}
+
+define service{
+       name                    generic-jbossjk-service
+       use                             generic-jboss-service
+
+       service_description             JBossJK
+       check_command                   check_jbossjmx!4!"jboss.web:name=jk-8009,type=ThreadPool"!currentThreadCount!100!200
+       register                        0
+}
+
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/cgi.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/cgi.cfg
new file mode 100644 (file)
index 0000000..100053b
--- /dev/null
@@ -0,0 +1,377 @@
+#################################################################
+#
+# CGI.CFG - Sample CGI Configuration File for Nagios 
+#
+#################################################################
+
+
+# MAIN CONFIGURATION FILE
+# This tells the CGIs where to find your main configuration file.
+# The CGIs will read the main and host config files for any other
+# data they might need.
+
+main_config_file=/etc/nagios3/nagios.cfg
+
+
+
+# PHYSICAL HTML PATH
+# This is the path where the HTML files for Nagios reside.  This
+# value is used to locate the logo images needed by the statusmap
+# and statuswrl CGIs.
+
+physical_html_path=/usr/share/nagios3/htdocs
+
+
+
+# URL HTML PATH
+# This is the path portion of the URL that corresponds to the
+# physical location of the Nagios HTML files (as defined above).
+# This value is used by the CGIs to locate the online documentation
+# and graphics.  If you access the Nagios pages with an URL like
+# http://www.myhost.com/nagios, this value should be '/nagios'
+# (without the quotes).
+
+url_html_path=/nagios3
+
+
+
+# CONTEXT-SENSITIVE HELP
+# This option determines whether or not a context-sensitive
+# help icon will be displayed for most of the CGIs.
+# Values: 0 = disables context-sensitive help
+#         1 = enables context-sensitive help
+
+show_context_help=1
+
+
+
+# PENDING STATES OPTION
+# This option determines what states should be displayed in the web
+# interface for hosts/services that have not yet been checked.
+# Values: 0 = leave hosts/services that have not been check yet in their original state
+#         1 = mark hosts/services that have not been checked yet as PENDING
+
+use_pending_states=1
+
+# NAGIOS PROCESS CHECK COMMAND
+# This is the full path and filename of the program used to check
+# the status of the Nagios process.  It is used only by the CGIs
+# and is completely optional.  However, if you don't use it, you'll
+# see warning messages in the CGIs about the Nagios process
+# not running and you won't be able to execute any commands from
+# the web interface.  The program should follow the same rules
+# as plugins; the return codes are the same as for the plugins,
+# it should have timeout protection, it should output something
+# to STDIO, etc.
+#
+# Note: The command line for the check_nagios plugin below may
+# have to be tweaked a bit, as different versions of the plugin
+# use different command line arguments/syntaxes.
+
+nagios_check_command=/usr/lib/nagios/plugins/check_nagios /var/cache/nagios3/status.dat 5 '/usr/sbin/nagios3'
+
+
+# AUTHENTICATION USAGE
+# This option controls whether or not the CGIs will use any 
+# authentication when displaying host and service information, as
+# well as committing commands to Nagios for processing.  
+#
+# Read the HTML documentation to learn how the authorization works!
+#
+# NOTE: It is a really *bad* idea to disable authorization, unless
+# you plan on removing the command CGI (cmd.cgi)!  Failure to do
+# so will leave you wide open to kiddies messing with Nagios and
+# possibly hitting you with a denial of service attack by filling up
+# your drive by continuously writing to your command file!
+#
+# Setting this value to 0 will cause the CGIs to *not* use
+# authentication (bad idea), while any other value will make them
+# use the authentication functions (the default).
+
+use_authentication=1
+
+
+
+
+# x509 CERT AUTHENTICATION
+# When enabled, this option allows you to use x509 cert (SSL)
+# authentication in the CGIs.  This is an advanced option and should
+# not be enabled unless you know what you're doing.
+
+use_ssl_authentication=0
+
+
+
+
+# DEFAULT USER
+# Setting this variable will define a default user name that can
+# access pages without authentication.  This allows people within a
+# secure domain (i.e., behind a firewall) to see the current status
+# without authenticating.  You may want to use this to avoid basic
+# authentication if you are not using a secure server since basic
+# authentication transmits passwords in the clear.
+#
+# Important:  Do not define a default username unless you are
+# running a secure web server and are sure that everyone who has
+# access to the CGIs has been authenticated in some manner!  If you
+# define this variable, anyone who has not authenticated to the web
+# server will inherit all rights you assign to this user!
+#default_user_name=guest
+
+
+
+# SYSTEM/PROCESS INFORMATION ACCESS
+# This option is a comma-delimited list of all usernames that
+# have access to viewing the Nagios process information as
+# provided by the Extended Information CGI (extinfo.cgi).  By
+# default, *no one* has access to this unless you choose to
+# not use authorization.  You may use an asterisk (*) to
+# authorize any user who has authenticated to the web server.
+
+authorized_for_system_information=<%= node['nagios']['cgi']['authorized_for_system_information'] %>
+
+
+
+# CONFIGURATION INFORMATION ACCESS
+# This option is a comma-delimited list of all usernames that
+# can view ALL configuration information (hosts, commands, etc).
+# By default, users can only view configuration information
+# for the hosts and services they are contacts for. You may use
+# an asterisk (*) to authorize any user who has authenticated
+# to the web server.
+
+authorized_for_configuration_information=<%= node['nagios']['cgi']['authorized_for_configuration_information'] %>
+
+
+
+# SYSTEM/PROCESS COMMAND ACCESS
+# This option is a comma-delimited list of all usernames that
+# can issue shutdown and restart commands to Nagios via the
+# command CGI (cmd.cgi).  Users in this list can also change
+# the program mode to active or standby. By default, *no one*
+# has access to this unless you choose to not use authorization.
+# You may use an asterisk (*) to authorize any user who has
+# authenticated to the web server.
+
+authorized_for_system_commands=<%= node['nagios']['cgi']['authorized_for_system_commands'] %>
+
+
+
+# GLOBAL HOST/SERVICE VIEW ACCESS
+# These two options are comma-delimited lists of all usernames that
+# can view information for all hosts and services that are being
+# monitored.  By default, users can only view information
+# for hosts or services that they are contacts for (unless you
+# you choose to not use authorization). You may use an asterisk (*)
+# to authorize any user who has authenticated to the web server.
+
+
+authorized_for_all_services=<%= node['nagios']['cgi']['authorized_for_all_services'] %>
+authorized_for_all_hosts=<%= node['nagios']['cgi']['authorized_for_all_hosts'] %>
+
+
+
+# GLOBAL HOST/SERVICE COMMAND ACCESS
+# These two options are comma-delimited lists of all usernames that
+# can issue host or service related commands via the command
+# CGI (cmd.cgi) for all hosts and services that are being monitored. 
+# By default, users can only issue commands for hosts or services 
+# that they are contacts for (unless you you choose to not use 
+# authorization).  You may use an asterisk (*) to authorize any
+# user who has authenticated to the web server.
+
+authorized_for_all_service_commands=<%= node['nagios']['cgi']['authorized_for_all_service_commands'] %>
+authorized_for_all_host_commands=<%= node['nagios']['cgi']['authorized_for_all_host_commands'] %>
+
+
+
+# READ-ONLY USERS
+# A comma-delimited list of usernames that have read-only rights in
+# the CGIs.  This will block any service or host commands normally shown
+# on the extinfo CGI pages.  It will also block comments from being shown
+# to read-only users.
+
+#authorized_for_read_only=user1,user2
+
+
+
+
+# STATUSMAP BACKGROUND IMAGE
+# This option allows you to specify an image to be used as a 
+# background in the statusmap CGI.  It is assumed that the image
+# resides in the HTML images path (i.e. /usr/local/nagios/share/images).
+# This path is automatically determined by appending "/images"
+# to the path specified by the 'physical_html_path' directive.
+# Note:  The image file may be in GIF, PNG, JPEG, or GD2 format.
+# However, I recommend that you convert your image to GD2 format
+# (uncompressed), as this will cause less CPU load when the CGI
+# generates the image.
+
+#statusmap_background_image=smbackground.gd2
+
+
+
+
+# STATUSMAP TRANSPARENCY INDEX COLOR
+# These options set the r,g,b values of the background color used the statusmap CGI,
+# so normal browsers that can't show real png transparency set the desired color as
+# a background color instead (to make it look pretty).  
+# Defaults to white: (R,G,B) = (255,255,255).
+
+#color_transparency_index_r=255
+#color_transparency_index_g=255
+#color_transparency_index_b=255
+
+
+
+
+# DEFAULT STATUSMAP LAYOUT METHOD
+# This option allows you to specify the default layout method
+# the statusmap CGI should use for drawing hosts.  If you do
+# not use this option, the default is to use user-defined
+# coordinates.  Valid options are as follows:
+#      0 = User-defined coordinates
+#      1 = Depth layers
+#       2 = Collapsed tree
+#       3 = Balanced tree
+#       4 = Circular
+#       5 = Circular (Marked Up)
+
+default_statusmap_layout=5
+
+
+
+# DEFAULT STATUSWRL LAYOUT METHOD
+# This option allows you to specify the default layout method
+# the statuswrl (VRML) CGI should use for drawing hosts.  If you
+# do not use this option, the default is to use user-defined
+# coordinates.  Valid options are as follows:
+#      0 = User-defined coordinates
+#       2 = Collapsed tree
+#       3 = Balanced tree
+#       4 = Circular
+
+default_statuswrl_layout=4
+
+
+
+# STATUSWRL INCLUDE
+# This option allows you to include your own objects in the 
+# generated VRML world.  It is assumed that the file
+# resides in the HTML path (i.e. /usr/local/nagios/share).
+
+#statuswrl_include=myworld.wrl
+
+
+
+# PING SYNTAX
+# This option determines what syntax should be used when
+# attempting to ping a host from the WAP interface (using
+# the statuswml CGI.  You must include the full path to
+# the ping binary, along with all required options.  The
+# $HOSTADDRESS$ macro is substituted with the address of
+# the host before the command is executed.
+# Please note that the syntax for the ping binary is
+# notorious for being different on virtually ever *NIX
+# OS and distribution, so you may have to tweak this to
+# work on your system.
+
+ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$
+
+
+
+# REFRESH RATE
+# This option allows you to specify the refresh rate in seconds
+# of various CGIs (status, statusmap, extinfo, and outages).  
+
+refresh_rate=90
+
+# DEFAULT PAGE LIMIT
+# This option allows you to specify the default number of results 
+# displayed on the status.cgi.  This number can be adjusted from
+# within the UI after the initial page load. Setting this to 0
+# will show all results.  
+
+result_limit=<%= node['nagios']['cgi']['result_limit'] %>
+
+
+# ESCAPE HTML TAGS
+# This option determines whether HTML tags in host and service
+# status output is escaped in the web interface.  If enabled,
+# your plugin output will not be able to contain clickable links.
+
+escape_html_tags=1
+
+
+
+
+# SOUND OPTIONS
+# These options allow you to specify an optional audio file
+# that should be played in your browser window when there are
+# problems on the network.  The audio files are used only in
+# the status CGI.  Only the sound for the most critical problem
+# will be played.  Order of importance (higher to lower) is as
+# follows: unreachable hosts, down hosts, critical services,
+# warning services, and unknown services. If there are no
+# visible problems, the sound file optionally specified by
+# 'normal_sound' variable will be played.
+#
+#
+# <varname>=<sound_file>
+#
+# Note: All audio files must be placed in the /media subdirectory
+# under the HTML path (i.e. /usr/local/nagios/share/media/).
+
+#host_unreachable_sound=hostdown.wav
+#host_down_sound=hostdown.wav
+#service_critical_sound=critical.wav
+#service_warning_sound=warning.wav
+#service_unknown_sound=warning.wav
+#normal_sound=noproblem.wav
+
+
+
+# URL TARGET FRAMES
+# These options determine the target frames in which notes and 
+# action URLs will open.
+
+action_url_target=_blank
+notes_url_target=_blank
+
+
+
+
+# LOCK AUTHOR NAMES OPTION
+# This option determines whether users can change the author name 
+# when submitting comments, scheduling downtime.  If disabled, the 
+# author names will be locked into their contact name, as defined in Nagios.
+# Values: 0 = allow editing author names
+#         1 = lock author names (disallow editing)
+
+lock_author_names=1
+
+
+
+
+# SPLUNK INTEGRATION OPTIONS
+# These options allow you to enable integration with Splunk
+# in the web interface.  If enabled, you'll be presented with
+# "Splunk It" links in various places in the CGIs (log file,
+# alert history, host/service detail, etc).  Useful if you're
+# trying to research why a particular problem occurred.
+# For more information on Splunk, visit http://www.splunk.com/
+
+# This option determines whether the Splunk integration is enabled
+# Values: 0 = disable Splunk integration
+#         1 = enable Splunk integration
+
+#enable_splunk_integration=1
+
+
+# This option should be the URL used to access your instance of Splunk
+
+#splunk_url=http://127.0.0.1:8000/
+
+
+
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/nagios.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/nagios.cfg
new file mode 100644 (file)
index 0000000..8e206fb
--- /dev/null
@@ -0,0 +1,1371 @@
+##############################################################################
+#
+# NAGIOS.CFG - Sample Main Config File for Nagios 
+#
+#
+##############################################################################
+
+
+# LOG FILE
+# This is the main log file where service and host events are logged
+# for historical purposes.  This should be the first option specified 
+# in the config file!!!
+
+log_file=/var/log/nagios3/nagios.log
+
+# Commands definitions
+cfg_file=/etc/nagios3/commands.cfg
+
+# Debian also defaults to using the check commands defined by the debian
+# nagios-plugins package
+cfg_dir=/etc/nagios-plugins/config
+
+# Debian uses by default a configuration directory where nagios3-common,
+# other packages and the local admin can dump or link configuration
+# files into.
+cfg_dir=/etc/nagios3/conf.d
+
+# OBJECT CONFIGURATION FILE(S)
+# These are the object configuration files in which you define hosts,
+# host groups, contacts, contact groups, services, etc.
+# You can split your object definitions across several config files
+# if you wish (as shown below), or keep them all in a single config file.
+
+# You can specify individual object config files as shown below:
+#cfg_file=/etc/nagios3/objects/commands.cfg
+#cfg_file=/etc/nagios3/objects/contacts.cfg
+#cfg_file=/etc/nagios3/objects/timeperiods.cfg
+#cfg_file=/etc/nagios3/objects/templates.cfg
+
+# Definitions for monitoring a Windows machine
+#cfg_file=/etc/nagios3/objects/windows.cfg
+
+# Definitions for monitoring a router/switch
+#cfg_file=/etc/nagios3/objects/switch.cfg
+
+# Definitions for monitoring a network printer
+#cfg_file=/etc/nagios3/objects/printer.cfg
+
+
+# You can also tell Nagios to process all config files (with a .cfg
+# extension) in a particular directory by using the cfg_dir
+# directive as shown below:
+
+#cfg_dir=/etc/nagios3/servers
+#cfg_dir=/etc/nagios3/printers
+#cfg_dir=/etc/nagios3/switches
+#cfg_dir=/etc/nagios3/routers
+cfg_dir=/etc/nagios3/<%= node['nagios']['base_cfg_dir'] %>
+cfg_dir=/etc/nagios3/<%= node['nagios']['site_cfg_dir'] %>
+
+
+
+# OBJECT CACHE FILE
+# This option determines where object definitions are cached when
+# Nagios starts/restarts.  The CGIs read object definitions from 
+# this cache file (rather than looking at the object config files
+# directly) in order to prevent inconsistencies that can occur
+# when the config files are modified after Nagios starts.
+
+object_cache_file=/var/cache/nagios3/objects.cache
+
+
+
+# PRE-CACHED OBJECT FILE
+# This options determines the location of the precached object file.
+# If you run Nagios with the -p command line option, it will preprocess
+# your object configuration file(s) and write the cached config to this
+# file.  You can then start Nagios with the -u option to have it read
+# object definitions from this precached file, rather than the standard
+# object configuration files (see the cfg_file and cfg_dir options above).
+# Using a precached object file can speed up the time needed to (re)start 
+# the Nagios process if you've got a large and/or complex configuration.
+# Read the documentation section on optimizing Nagios to find our more
+# about how this feature works.
+
+precached_object_file=/var/lib/nagios3/objects.precache
+
+
+
+# RESOURCE FILE
+# This is an optional resource file that contains $USERx$ macro
+# definitions. Multiple resource files can be specified by using
+# multiple resource_file definitions.  The CGIs will not attempt to
+# read the contents of resource files, so information that is
+# considered to be sensitive (usernames, passwords, etc) can be
+# defined as macros in this file and restrictive permissions (600)
+# can be placed on this file.
+
+resource_file=/etc/nagios3/resource.cfg
+
+
+
+# STATUS FILE
+# This is where the current status of all monitored services and
+# hosts is stored.  Its contents are read and processed by the CGIs.
+# The contents of the status file are deleted every time Nagios
+#  restarts.
+
+status_file=/var/cache/nagios3/status.dat
+
+
+
+# STATUS FILE UPDATE INTERVAL
+# This option determines the frequency (in seconds) that
+# Nagios will periodically dump program, host, and 
+# service status data.
+
+status_update_interval=10
+
+
+
+# NAGIOS USER
+# This determines the effective user that Nagios should run as.  
+# You can either supply a username or a UID.
+
+nagios_user=nagios
+
+
+
+# NAGIOS GROUP
+# This determines the effective group that Nagios should run as.  
+# You can either supply a group name or a GID.
+
+nagios_group=nagios
+
+
+
+# EXTERNAL COMMAND OPTION
+# This option allows you to specify whether or not Nagios should check
+# for external commands (in the command file defined below).  By default
+# Nagios will *not* check for external commands, just to be on the
+# cautious side.  If you want to be able to use the CGI command interface
+# you will have to enable this.
+# Values: 0 = disable commands, 1 = enable commands
+
+check_external_commands=<%= node['nagios']['check_external_commands'] %>
+
+
+
+# EXTERNAL COMMAND CHECK INTERVAL
+# This is the interval at which Nagios should check for external commands.
+# This value works of the interval_length you specify later.  If you leave
+# that at its default value of 60 (seconds), a value of 1 here will cause
+# Nagios to check for external commands every minute.  If you specify a
+# number followed by an "s" (i.e. 15s), this will be interpreted to mean
+# actual seconds rather than a multiple of the interval_length variable.
+# Note: In addition to reading the external command file at regularly 
+# scheduled intervals, Nagios will also check for external commands after
+# event handlers are executed.
+# NOTE: Setting this value to -1 causes Nagios to check the external
+# command file as often as possible.
+
+#command_check_interval=15s
+command_check_interval=-1
+
+
+
+# EXTERNAL COMMAND FILE
+# This is the file that Nagios checks for external command requests.
+# It is also where the command CGI will write commands that are submitted
+# by users, so it must be writeable by the user that the web server
+# is running as (usually 'nobody').  Permissions should be set at the 
+# directory level instead of on the file, as the file is deleted every
+# time its contents are processed.
+# Debian Users: In case you didn't read README.Debian yet, _NOW_ is the
+# time to do it.
+
+command_file=/var/lib/nagios3/rw/nagios.cmd
+
+
+
+# EXTERNAL COMMAND BUFFER SLOTS
+# This settings is used to tweak the number of items or "slots" that
+# the Nagios daemon should allocate to the buffer that holds incoming 
+# external commands before they are processed.  As external commands 
+# are processed by the daemon, they are removed from the buffer.  
+
+external_command_buffer_slots=4096
+
+
+
+# LOCK FILE
+# This is the lockfile that Nagios will use to store its PID number
+# in when it is running in daemon mode.
+
+lock_file=/var/run/nagios3/nagios3.pid
+
+
+
+# TEMP FILE
+# This is a temporary file that is used as scratch space when Nagios
+# updates the status log, cleans the comment file, etc.  This file
+# is created, used, and deleted throughout the time that Nagios is
+# running.
+
+temp_file=/var/cache/nagios3/nagios.tmp
+
+
+
+# TEMP PATH
+# This is path where Nagios can create temp files for service and
+# host check results, etc.
+
+temp_path=/tmp
+
+
+
+# EVENT BROKER OPTIONS
+# Controls what (if any) data gets sent to the event broker.
+# Values:  0      = Broker nothing
+#         -1      = Broker everything
+#         <other> = See documentation
+
+event_broker_options=-1
+
+
+
+# EVENT BROKER MODULE(S)
+# This directive is used to specify an event broker module that should
+# by loaded by Nagios at startup.  Use multiple directives if you want
+# to load more than one module.  Arguments that should be passed to
+# the module at startup are seperated from the module path by a space.
+#
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#
+# Do NOT overwrite modules while they are being used by Nagios or Nagios
+# will crash in a fiery display of SEGFAULT glory.  This is a bug/limitation
+# either in dlopen(), the kernel, and/or the filesystem.  And maybe Nagios...
+#
+# The correct/safe way of updating a module is by using one of these methods:
+#    1. Shutdown Nagios, replace the module file, restart Nagios
+#    2. Delete the original module file, move the new module file into place, restart Nagios
+#
+# Example:
+#
+#   broker_module=<modulepath> [moduleargs]
+
+#broker_module=/somewhere/module1.o
+#broker_module=/somewhere/module2.o arg1 arg2=3 debug=0
+
+
+
+# LOG ROTATION METHOD
+# This is the log rotation method that Nagios should use to rotate
+# the main log file. Values are as follows..
+#      n       = None - don't rotate the log
+#      h       = Hourly rotation (top of the hour)
+#      d       = Daily rotation (midnight every day)
+#      w       = Weekly rotation (midnight on Saturday evening)
+#      m       = Monthly rotation (midnight last day of month)
+
+log_rotation_method=d
+
+
+
+# LOG ARCHIVE PATH
+# This is the directory where archived (rotated) log files should be 
+# placed (assuming you've chosen to do log rotation).
+
+log_archive_path=/var/log/nagios3/archives
+
+
+
+# LOGGING OPTIONS
+# If you want messages logged to the syslog facility, as well as the
+# Nagios log file set this option to 1.  If not, set it to 0.
+
+use_syslog=1
+
+
+
+# NOTIFICATION LOGGING OPTION
+# If you don't want notifications to be logged, set this value to 0.
+# If notifications should be logged, set the value to 1.
+
+log_notifications=1
+
+
+
+# SERVICE RETRY LOGGING OPTION
+# If you don't want service check retries to be logged, set this value
+# to 0.  If retries should be logged, set the value to 1.
+
+log_service_retries=1
+
+
+
+# HOST RETRY LOGGING OPTION
+# If you don't want host check retries to be logged, set this value to
+# 0.  If retries should be logged, set the value to 1.
+
+log_host_retries=1
+
+
+
+# EVENT HANDLER LOGGING OPTION
+# If you don't want host and service event handlers to be logged, set
+# this value to 0.  If event handlers should be logged, set the value
+# to 1.
+
+log_event_handlers=1
+
+
+
+# INITIAL STATES LOGGING OPTION
+# If you want Nagios to log all initial host and service states to
+# the main log file (the first time the service or host is checked)
+# you can enable this option by setting this value to 1.  If you
+# are not using an external application that does long term state
+# statistics reporting, you do not need to enable this option.  In
+# this case, set the value to 0.
+
+log_initial_states=0
+
+
+
+# EXTERNAL COMMANDS LOGGING OPTION
+# If you don't want Nagios to log external commands, set this value
+# to 0.  If external commands should be logged, set this value to 1.
+# Note: This option does not include logging of passive service
+# checks - see the option below for controlling whether or not
+# passive checks are logged.
+
+log_external_commands=1
+
+
+
+# PASSIVE CHECKS LOGGING OPTION
+# If you don't want Nagios to log passive host and service checks, set
+# this value to 0.  If passive checks should be logged, set
+# this value to 1.
+
+log_passive_checks=1
+
+
+
+# GLOBAL HOST AND SERVICE EVENT HANDLERS
+# These options allow you to specify a host and service event handler
+# command that is to be run for every host or service state change.
+# The global event handler is executed immediately prior to the event
+# handler that you have optionally specified in each host or
+# service definition. The command argument is the short name of a
+# command definition that you define in your host configuration file.
+# Read the HTML docs for more information.
+
+#global_host_event_handler=somecommand
+#global_service_event_handler=somecommand
+
+
+
+# SERVICE INTER-CHECK DELAY METHOD
+# This is the method that Nagios should use when initially
+# "spreading out" service checks when it starts monitoring.  The
+# default is to use smart delay calculation, which will try to
+# space all service checks out evenly to minimize CPU load.
+# Using the dumb setting will cause all checks to be scheduled
+# at the same time (with no delay between them)!  This is not a
+# good thing for production, but is useful when testing the
+# parallelization functionality.
+#      n       = None - don't use any delay between checks
+#      d       = Use a "dumb" delay of 1 second between checks
+#      s       = Use "smart" inter-check delay calculation
+#       x.xx    = Use an inter-check delay of x.xx seconds
+
+service_inter_check_delay_method=s
+
+
+
+# MAXIMUM SERVICE CHECK SPREAD
+# This variable determines the timeframe (in minutes) from the
+# program start time that an initial check of all services should
+# be completed.  Default is 30 minutes.
+
+max_service_check_spread=30
+
+
+
+# SERVICE CHECK INTERLEAVE FACTOR
+# This variable determines how service checks are interleaved.
+# Interleaving the service checks allows for a more even
+# distribution of service checks and reduced load on remote
+# hosts.  Setting this value to 1 is equivalent to how versions
+# of Nagios previous to 0.0.5 did service checks.  Set this
+# value to s (smart) for automatic calculation of the interleave
+# factor unless you have a specific reason to change it.
+#       s       = Use "smart" interleave factor calculation
+#       x       = Use an interleave factor of x, where x is a
+#                 number greater than or equal to 1.
+
+service_interleave_factor=s
+
+
+
+# HOST INTER-CHECK DELAY METHOD
+# This is the method that Nagios should use when initially
+# "spreading out" host checks when it starts monitoring.  The
+# default is to use smart delay calculation, which will try to
+# space all host checks out evenly to minimize CPU load.
+# Using the dumb setting will cause all checks to be scheduled
+# at the same time (with no delay between them)!
+#      n       = None - don't use any delay between checks
+#      d       = Use a "dumb" delay of 1 second between checks
+#      s       = Use "smart" inter-check delay calculation
+#       x.xx    = Use an inter-check delay of x.xx seconds
+
+host_inter_check_delay_method=s
+
+
+
+# MAXIMUM HOST CHECK SPREAD
+# This variable determines the timeframe (in minutes) from the
+# program start time that an initial check of all hosts should
+# be completed.  Default is 30 minutes.
+
+max_host_check_spread=30
+
+
+
+# MAXIMUM CONCURRENT SERVICE CHECKS
+# This option allows you to specify the maximum number of 
+# service checks that can be run in parallel at any given time.
+# Specifying a value of 1 for this variable essentially prevents
+# any service checks from being parallelized.  A value of 0
+# will not restrict the number of concurrent checks that are
+# being executed.
+
+max_concurrent_checks=0
+
+
+
+# HOST AND SERVICE CHECK REAPER FREQUENCY
+# This is the frequency (in seconds!) that Nagios will process
+# the results of host and service checks.
+
+check_result_reaper_frequency=10
+
+
+
+
+# MAX CHECK RESULT REAPER TIME
+# This is the max amount of time (in seconds) that  a single
+# check result reaper event will be allowed to run before 
+# returning control back to Nagios so it can perform other
+# duties.
+
+max_check_result_reaper_time=30
+
+
+
+
+# CHECK RESULT PATH
+# This is directory where Nagios stores the results of host and
+# service checks that have not yet been processed.
+#
+# Note: Make sure that only one instance of Nagios has access
+# to this directory!  
+
+check_result_path=/var/lib/nagios3/spool/checkresults
+
+
+
+
+# MAX CHECK RESULT FILE AGE
+# This option determines the maximum age (in seconds) which check
+# result files are considered to be valid.  Files older than this 
+# threshold will be mercilessly deleted without further processing.
+
+max_check_result_file_age=3600
+
+
+
+
+# CACHED HOST CHECK HORIZON
+# This option determines the maximum amount of time (in seconds)
+# that the state of a previous host check is considered current.
+# Cached host states (from host checks that were performed more
+# recently that the timeframe specified by this value) can immensely
+# improve performance in regards to the host check logic.
+# Too high of a value for this option may result in inaccurate host
+# states being used by Nagios, while a lower value may result in a
+# performance hit for host checks.  Use a value of 0 to disable host
+# check caching.
+
+cached_host_check_horizon=15
+
+
+
+# CACHED SERVICE CHECK HORIZON
+# This option determines the maximum amount of time (in seconds)
+# that the state of a previous service check is considered current.
+# Cached service states (from service checks that were performed more
+# recently that the timeframe specified by this value) can immensely
+# improve performance in regards to predictive dependency checks.
+# Use a value of 0 to disable service check caching.
+
+cached_service_check_horizon=15
+
+
+
+# ENABLE PREDICTIVE HOST DEPENDENCY CHECKS
+# This option determines whether or not Nagios will attempt to execute
+# checks of hosts when it predicts that future dependency logic test
+# may be needed.  These predictive checks can help ensure that your
+# host dependency logic works well.
+# Values:
+#  0 = Disable predictive checks
+#  1 = Enable predictive checks (default)
+
+enable_predictive_host_dependency_checks=1
+
+
+
+# ENABLE PREDICTIVE SERVICE DEPENDENCY CHECKS
+# This option determines whether or not Nagios will attempt to execute
+# checks of service when it predicts that future dependency logic test
+# may be needed.  These predictive checks can help ensure that your
+# service dependency logic works well.
+# Values:
+#  0 = Disable predictive checks
+#  1 = Enable predictive checks (default)
+
+enable_predictive_service_dependency_checks=1
+
+
+
+# SOFT STATE DEPENDENCIES
+# This option determines whether or not Nagios will use soft state 
+# information when checking host and service dependencies. Normally 
+# Nagios will only use the latest hard host or service state when 
+# checking dependencies. If you want it to use the latest state (regardless
+# of whether its a soft or hard state type), enable this option. 
+# Values:
+#  0 = Don't use soft state dependencies (default) 
+#  1 = Use soft state dependencies 
+
+soft_state_dependencies=0
+
+
+
+# TIME CHANGE ADJUSTMENT THRESHOLDS
+# These options determine when Nagios will react to detected changes
+# in system time (either forward or backwards).
+
+#time_change_threshold=900
+
+
+
+# AUTO-RESCHEDULING OPTION
+# This option determines whether or not Nagios will attempt to
+# automatically reschedule active host and service checks to
+# "smooth" them out over time.  This can help balance the load on
+# the monitoring server.  
+# WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE
+# PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY
+
+auto_reschedule_checks=0
+
+
+
+# AUTO-RESCHEDULING INTERVAL
+# This option determines how often (in seconds) Nagios will
+# attempt to automatically reschedule checks.  This option only
+# has an effect if the auto_reschedule_checks option is enabled.
+# Default is 30 seconds.
+# WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE
+# PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY
+
+auto_rescheduling_interval=30
+
+
+
+# AUTO-RESCHEDULING WINDOW
+# This option determines the "window" of time (in seconds) that
+# Nagios will look at when automatically rescheduling checks.
+# Only host and service checks that occur in the next X seconds
+# (determined by this variable) will be rescheduled. This option
+# only has an effect if the auto_reschedule_checks option is
+# enabled.  Default is 180 seconds (3 minutes).
+# WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE
+# PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY
+
+auto_rescheduling_window=180
+
+
+
+# SLEEP TIME
+# This is the number of seconds to sleep between checking for system
+# events and service checks that need to be run.
+
+sleep_time=0.25
+
+
+
+# TIMEOUT VALUES
+# These options control how much time Nagios will allow various
+# types of commands to execute before killing them off.  Options
+# are available for controlling maximum time allotted for
+# service checks, host checks, event handlers, notifications, the
+# ocsp command, and performance data commands.  All values are in
+# seconds.
+
+service_check_timeout=60
+host_check_timeout=30
+event_handler_timeout=30
+notification_timeout=30
+ocsp_timeout=5
+perfdata_timeout=5
+
+
+
+# RETAIN STATE INFORMATION
+# This setting determines whether or not Nagios will save state
+# information for services and hosts before it shuts down.  Upon
+# startup Nagios will reload all saved service and host state
+# information before starting to monitor.  This is useful for 
+# maintaining long-term data on state statistics, etc, but will
+# slow Nagios down a bit when it (re)starts.  Since its only
+# a one-time penalty, I think its well worth the additional
+# startup delay.
+
+retain_state_information=1
+
+
+
+# STATE RETENTION FILE
+# This is the file that Nagios should use to store host and
+# service state information before it shuts down.  The state 
+# information in this file is also read immediately prior to
+# starting to monitor the network when Nagios is restarted.
+# This file is used only if the retain_state_information
+# variable is set to 1.
+
+state_retention_file=/var/lib/nagios3/retention.dat
+
+
+
+# RETENTION DATA UPDATE INTERVAL
+# This setting determines how often (in minutes) that Nagios
+# will automatically save retention data during normal operation.
+# If you set this value to 0, Nagios will not save retention
+# data at regular interval, but it will still save retention
+# data before shutting down or restarting.  If you have disabled
+# state retention, this option has no effect.
+
+retention_update_interval=60
+
+
+
+# USE RETAINED PROGRAM STATE
+# This setting determines whether or not Nagios will set 
+# program status variables based on the values saved in the
+# retention file.  If you want to use retained program status
+# information, set this value to 1.  If not, set this value
+# to 0.
+
+use_retained_program_state=1
+
+
+
+# USE RETAINED SCHEDULING INFO
+# This setting determines whether or not Nagios will retain
+# the scheduling info (next check time) for hosts and services
+# based on the values saved in the retention file.  If you
+# If you want to use retained scheduling info, set this
+# value to 1.  If not, set this value to 0.
+
+use_retained_scheduling_info=1
+
+
+
+# RETAINED ATTRIBUTE MASKS (ADVANCED FEATURE)
+# The following variables are used to specify specific host and
+# service attributes that should *not* be retained by Nagios during
+# program restarts.
+#
+# The values of the masks are bitwise ANDs of values specified
+# by the "MODATTR_" definitions found in include/common.h.  
+# For example, if you do not want the current enabled/disabled state
+# of flap detection and event handlers for hosts to be retained, you
+# would use a value of 24 for the host attribute mask...
+# MODATTR_EVENT_HANDLER_ENABLED (8) + MODATTR_FLAP_DETECTION_ENABLED (16) = 24
+
+# This mask determines what host attributes are not retained
+retained_host_attribute_mask=0
+
+# This mask determines what service attributes are not retained
+retained_service_attribute_mask=0
+
+# These two masks determine what process attributes are not retained.
+# There are two masks, because some process attributes have host and service
+# options.  For example, you can disable active host checks, but leave active
+# service checks enabled.
+retained_process_host_attribute_mask=0
+retained_process_service_attribute_mask=0
+
+# These two masks determine what contact attributes are not retained.
+# There are two masks, because some contact attributes have host and
+# service options.  For example, you can disable host notifications for
+# a contact, but leave service notifications enabled for them.
+retained_contact_host_attribute_mask=0
+retained_contact_service_attribute_mask=0
+
+
+
+# INTERVAL LENGTH
+# This is the seconds per unit interval as used in the
+# host/contact/service configuration files.  Setting this to 60 means
+# that each interval is one minute long (60 seconds).  Other settings
+# have not been tested much, so your mileage is likely to vary...
+
+interval_length=60
+
+
+
+# CHECK FOR UPDATES
+# This option determines whether Nagios will automatically check to
+# see if new updates (releases) are available.  It is recommend that you
+# enable this option to ensure that you stay on top of the latest critical
+# patches to Nagios.  Nagios is critical to you - make sure you keep it in
+# good shape.  Nagios will check once a day for new updates. Data collected
+# by Nagios Enterprises from the update check is processed in accordance 
+# with our privacy policy - see http://api.nagios.org for details.
+
+check_for_updates=1
+
+
+
+# BARE UPDATE CHECK
+# This option deterines what data Nagios will send to api.nagios.org when
+# it checks for updates.  By default, Nagios will send information on the 
+# current version of Nagios you have installed, as well as an indicator as
+# to whether this was a new installation or not.  Nagios Enterprises uses
+# this data to determine the number of users running specific version of 
+# Nagios.  Enable this option if you do not want this information to be sent.
+
+bare_update_check=0
+
+
+
+# AGGRESSIVE HOST CHECKING OPTION
+# If you don't want to turn on aggressive host checking features, set
+# this value to 0 (the default).  Otherwise set this value to 1 to
+# enable the aggressive check option.  Read the docs for more info
+# on what aggressive host check is or check out the source code in
+# base/checks.c
+
+use_aggressive_host_checking=0
+
+
+
+# SERVICE CHECK EXECUTION OPTION
+# This determines whether or not Nagios will actively execute
+# service checks when it initially starts.  If this option is 
+# disabled, checks are not actively made, but Nagios can still
+# receive and process passive check results that come in.  Unless
+# you're implementing redundant hosts or have a special need for
+# disabling the execution of service checks, leave this enabled!
+# Values: 1 = enable checks, 0 = disable checks
+
+execute_service_checks=1
+
+
+
+# PASSIVE SERVICE CHECK ACCEPTANCE OPTION
+# This determines whether or not Nagios will accept passive
+# service checks results when it initially (re)starts.
+# Values: 1 = accept passive checks, 0 = reject passive checks
+
+accept_passive_service_checks=1
+
+
+
+# HOST CHECK EXECUTION OPTION
+# This determines whether or not Nagios will actively execute
+# host checks when it initially starts.  If this option is 
+# disabled, checks are not actively made, but Nagios can still
+# receive and process passive check results that come in.  Unless
+# you're implementing redundant hosts or have a special need for
+# disabling the execution of host checks, leave this enabled!
+# Values: 1 = enable checks, 0 = disable checks
+
+execute_host_checks=1
+
+
+
+# PASSIVE HOST CHECK ACCEPTANCE OPTION
+# This determines whether or not Nagios will accept passive
+# host checks results when it initially (re)starts.
+# Values: 1 = accept passive checks, 0 = reject passive checks
+
+accept_passive_host_checks=1
+
+
+
+# NOTIFICATIONS OPTION
+# This determines whether or not Nagios will sent out any host or
+# service notifications when it is initially (re)started.
+# Values: 1 = enable notifications, 0 = disable notifications
+
+enable_notifications=1
+
+
+
+# EVENT HANDLER USE OPTION
+# This determines whether or not Nagios will run any host or
+# service event handlers when it is initially (re)started.  Unless
+# you're implementing redundant hosts, leave this option enabled.
+# Values: 1 = enable event handlers, 0 = disable event handlers
+
+enable_event_handlers=1
+
+
+
+# PROCESS PERFORMANCE DATA OPTION
+# This determines whether or not Nagios will process performance
+# data returned from service and host checks.  If this option is
+# enabled, host performance data will be processed using the
+# host_perfdata_command (defined below) and service performance
+# data will be processed using the service_perfdata_command (also
+# defined below).  Read the HTML docs for more information on
+# performance data.
+# Values: 1 = process performance data, 0 = do not process performance data
+
+<%
+process_performance_data = 0
+if node['nagios']['with_pnp4nagios'] then
+  process_performance_data = 1
+end
+-%>
+process_performance_data=<%= process_performance_data %>
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS
+# These commands are run after every host and service check is
+# performed.  These commands are executed only if the
+# enable_performance_data option (above) is set to 1.  The command
+# argument is the short name of a command definition that you 
+# define in your host configuration file.  Read the HTML docs for
+# more information on performance data.
+
+#host_perfdata_command=process-host-perfdata
+<% if node['nagios']['with_pnp4nagios'] then -%>
+host_perfdata_command=pnp-synchronous-host
+#host_perfdata_command=pnp-bulk-host
+#host_perfdata_command=pnp-bulknpcd-host
+<% end -%>
+#service_perfdata_command=process-service-perfdata
+<% if node['nagios']['with_pnp4nagios'] then -%>
+service_perfdata_command=pnp-synchronous-service
+#service_perfdata_command=pnp-bulk-service
+#service_perfdata_command=pnp-bulknpcd-service
+<% end -%>
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILES
+# These files are used to store host and service performance data.
+# Performance data is only written to these files if the
+# enable_performance_data option (above) is set to 1.
+
+#host_perfdata_file=/tmp/host-perfdata
+#service_perfdata_file=/tmp/service-perfdata
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILE TEMPLATES
+# These options determine what data is written (and how) to the
+# performance data files.  The templates may contain macros, special
+# characters (\t for tab, \r for carriage return, \n for newline)
+# and plain text.  A newline is automatically added after each write
+# to the performance data file.  Some examples of what you can do are
+# shown below.
+
+#host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$
+#service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILE MODES
+# This option determines whether or not the host and service
+# performance data files are opened in write ("w") or append ("a")
+# mode. If you want to use named pipes, you should use the special
+# pipe ("p") mode which avoid blocking at startup, otherwise you will
+# likely want the defult append ("a") mode.
+
+#host_perfdata_file_mode=a
+#service_perfdata_file_mode=a
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING INTERVAL
+# These options determine how often (in seconds) the host and service
+# performance data files are processed using the commands defined
+# below.  A value of 0 indicates the files should not be periodically
+# processed.
+
+#host_perfdata_file_processing_interval=0
+#service_perfdata_file_processing_interval=0
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING COMMANDS
+# These commands are used to periodically process the host and
+# service performance data files.  The interval at which the
+# processing occurs is determined by the options above.
+
+#host_perfdata_file_processing_command=process-host-perfdata-file
+#service_perfdata_file_processing_command=process-service-perfdata-file
+
+
+
+# HOST AND SERVICE PERFORMANCE DATA PROCESS EMPTY RESULTS
+# THese options determine wether the core will process empty perfdata
+# results or not. This is needed for distributed monitoring, and intentionally
+# turned on by default.
+# If you don't require empty perfdata - saving some cpu cycles
+# on unwanted macro calculation - you can turn that off. Be careful!
+# Values: 1 = enable, 0 = disable
+
+#host_perfdata_process_empty_results=1
+#service_perfdata_process_empty_results=1
+
+
+# OBSESS OVER SERVICE CHECKS OPTION
+# This determines whether or not Nagios will obsess over service
+# checks and run the ocsp_command defined below.  Unless you're
+# planning on implementing distributed monitoring, do not enable
+# this option.  Read the HTML docs for more information on
+# implementing distributed monitoring.
+# Values: 1 = obsess over services, 0 = do not obsess (default)
+
+obsess_over_services=0
+
+
+
+# OBSESSIVE COMPULSIVE SERVICE PROCESSOR COMMAND
+# This is the command that is run for every service check that is
+# processed by Nagios.  This command is executed only if the
+# obsess_over_services option (above) is set to 1.  The command 
+# argument is the short name of a command definition that you
+# define in your host configuration file. Read the HTML docs for
+# more information on implementing distributed monitoring.
+
+#ocsp_command=somecommand
+
+
+
+# OBSESS OVER HOST CHECKS OPTION
+# This determines whether or not Nagios will obsess over host
+# checks and run the ochp_command defined below.  Unless you're
+# planning on implementing distributed monitoring, do not enable
+# this option.  Read the HTML docs for more information on
+# implementing distributed monitoring.
+# Values: 1 = obsess over hosts, 0 = do not obsess (default)
+
+obsess_over_hosts=0
+
+
+
+# OBSESSIVE COMPULSIVE HOST PROCESSOR COMMAND
+# This is the command that is run for every host check that is
+# processed by Nagios.  This command is executed only if the
+# obsess_over_hosts option (above) is set to 1.  The command 
+# argument is the short name of a command definition that you
+# define in your host configuration file. Read the HTML docs for
+# more information on implementing distributed monitoring.
+
+#ochp_command=somecommand
+
+
+
+# TRANSLATE PASSIVE HOST CHECKS OPTION
+# This determines whether or not Nagios will translate
+# DOWN/UNREACHABLE passive host check results into their proper
+# state for this instance of Nagios.  This option is useful
+# if you have distributed or failover monitoring setup.  In
+# these cases your other Nagios servers probably have a different
+# "view" of the network, with regards to the parent/child relationship
+# of hosts.  If a distributed monitoring server thinks a host
+# is DOWN, it may actually be UNREACHABLE from the point of
+# this Nagios instance.  Enabling this option will tell Nagios
+# to translate any DOWN or UNREACHABLE host states it receives
+# passively into the correct state from the view of this server.
+# Values: 1 = perform translation, 0 = do not translate (default)
+
+translate_passive_host_checks=0
+
+
+
+# PASSIVE HOST CHECKS ARE SOFT OPTION
+# This determines whether or not Nagios will treat passive host
+# checks as being HARD or SOFT.  By default, a passive host check
+# result will put a host into a HARD state type.  This can be changed
+# by enabling this option.
+# Values: 0 = passive checks are HARD, 1 = passive checks are SOFT
+
+passive_host_checks_are_soft=0
+
+
+
+# ORPHANED HOST/SERVICE CHECK OPTIONS
+# These options determine whether or not Nagios will periodically 
+# check for orphaned host service checks.  Since service checks are
+# not rescheduled until the results of their previous execution 
+# instance are processed, there exists a possibility that some
+# checks may never get rescheduled.  A similar situation exists for
+# host checks, although the exact scheduling details differ a bit
+# from service checks.  Orphaned checks seem to be a rare
+# problem and should not happen under normal circumstances.
+# If you have problems with service checks never getting
+# rescheduled, make sure you have orphaned service checks enabled.
+# Values: 1 = enable checks, 0 = disable checks
+
+check_for_orphaned_services=1
+check_for_orphaned_hosts=1
+
+
+
+# SERVICE FRESHNESS CHECK OPTION
+# This option determines whether or not Nagios will periodically
+# check the "freshness" of service results.  Enabling this option
+# is useful for ensuring passive checks are received in a timely
+# manner.
+# Values: 1 = enabled freshness checking, 0 = disable freshness checking
+
+check_service_freshness=1
+
+
+
+# SERVICE FRESHNESS CHECK INTERVAL
+# This setting determines how often (in seconds) Nagios will
+# check the "freshness" of service check results.  If you have
+# disabled service freshness checking, this option has no effect.
+
+service_freshness_check_interval=60
+
+
+
+# SERVICE CHECK TIMEOUT STATE
+# This setting determines the state Nagios will report when a
+# service check times out - that is does not respond within
+# service_check_timeout seconds.  This can be useful if a
+# machine is running at too high a load and you do not want
+# to consider a failed service check to be critical (the default).
+# Valid settings are:
+# c - Critical (default)
+# u - Unknown
+# w - Warning
+# o - OK
+
+service_check_timeout_state=c
+
+
+
+# HOST FRESHNESS CHECK OPTION
+# This option determines whether or not Nagios will periodically
+# check the "freshness" of host results.  Enabling this option
+# is useful for ensuring passive checks are received in a timely
+# manner.
+# Values: 1 = enabled freshness checking, 0 = disable freshness checking
+
+check_host_freshness=0
+
+
+
+# HOST FRESHNESS CHECK INTERVAL
+# This setting determines how often (in seconds) Nagios will
+# check the "freshness" of host check results.  If you have
+# disabled host freshness checking, this option has no effect.
+
+host_freshness_check_interval=60
+
+
+
+
+# ADDITIONAL FRESHNESS THRESHOLD LATENCY
+# This setting determines the number of seconds that Nagios
+# will add to any host and service freshness thresholds that
+# it calculates (those not explicitly specified by the user).
+
+additional_freshness_latency=15
+
+
+
+
+# FLAP DETECTION OPTION
+# This option determines whether or not Nagios will try
+# and detect hosts and services that are "flapping".  
+# Flapping occurs when a host or service changes between
+# states too frequently.  When Nagios detects that a 
+# host or service is flapping, it will temporarily suppress
+# notifications for that host/service until it stops
+# flapping.  Flap detection is very experimental, so read
+# the HTML documentation before enabling this feature!
+# Values: 1 = enable flap detection
+#         0 = disable flap detection (default)
+
+enable_flap_detection=1
+
+
+
+# FLAP DETECTION THRESHOLDS FOR HOSTS AND SERVICES
+# Read the HTML documentation on flap detection for
+# an explanation of what this option does.  This option
+# has no effect if flap detection is disabled.
+
+low_service_flap_threshold=5.0
+high_service_flap_threshold=20.0
+low_host_flap_threshold=5.0
+high_host_flap_threshold=20.0
+
+
+
+# DATE FORMAT OPTION
+# This option determines how short dates are displayed. Valid options
+# include:
+#      us              (MM-DD-YYYY HH:MM:SS)
+#      euro            (DD-MM-YYYY HH:MM:SS)
+#      iso8601         (YYYY-MM-DD HH:MM:SS)
+#      strict-iso8601  (YYYY-MM-DDTHH:MM:SS)
+#
+
+date_format=iso8601
+
+
+
+
+# TIMEZONE OFFSET
+# This option is used to override the default timezone that this
+# instance of Nagios runs in.  If not specified, Nagios will use
+# the system configured timezone.
+#
+# NOTE: In order to display the correct timezone in the CGIs, you
+# will also need to alter the Apache directives for the CGI path 
+# to include your timezone.  Example:
+#
+#   <Directory "/usr/local/nagios/sbin/">
+#      SetEnv TZ "Australia/Brisbane"
+#      ...
+#   </Directory>
+
+#use_timezone=US/Mountain
+#use_timezone=Australia/Brisbane
+
+
+
+
+# P1.PL FILE LOCATION
+# This value determines where the p1.pl perl script (used by the
+# embedded Perl interpreter) is located.  If you didn't compile
+# Nagios with embedded Perl support, this option has no effect.
+
+p1_file=/usr/lib/nagios3/p1.pl
+
+
+
+# EMBEDDED PERL INTERPRETER OPTION
+# This option determines whether or not the embedded Perl interpreter
+# will be enabled during runtime.  This option has no effect if Nagios
+# has not been compiled with support for embedded Perl.
+# Values: 0 = disable interpreter, 1 = enable interpreter
+
+enable_embedded_perl=1
+
+
+
+# EMBEDDED PERL USAGE OPTION
+# This option determines whether or not Nagios will process Perl plugins
+# and scripts with the embedded Perl interpreter if the plugins/scripts
+# do not explicitly indicate whether or not it is okay to do so. Read
+# the HTML documentation on the embedded Perl interpreter for more 
+# information on how this option works.
+
+use_embedded_perl_implicitly=1
+
+
+
+# ILLEGAL OBJECT NAME CHARACTERS
+# This option allows you to specify illegal characters that cannot
+# be used in host names, service descriptions, or names of other
+# object types.
+
+illegal_object_name_chars=`~!$%^&*|'"<>?,()=
+
+
+
+# ILLEGAL MACRO OUTPUT CHARACTERS
+# This option allows you to specify illegal characters that are
+# stripped from macros before being used in notifications, event
+# handlers, etc.  This DOES NOT affect macros used in service or
+# host check commands.
+# The following macros are stripped of the characters you specify:
+#      $HOSTOUTPUT$
+#      $HOSTPERFDATA$
+#      $HOSTACKAUTHOR$
+#      $HOSTACKCOMMENT$
+#      $SERVICEOUTPUT$
+#      $SERVICEPERFDATA$
+#      $SERVICEACKAUTHOR$
+#      $SERVICEACKCOMMENT$
+
+illegal_macro_output_chars=`~$&|'"<>
+
+
+
+# REGULAR EXPRESSION MATCHING
+# This option controls whether or not regular expression matching
+# takes place in the object config files.  Regular expression
+# matching is used to match host, hostgroup, service, and service
+# group names/descriptions in some fields of various object types.
+# Values: 1 = enable regexp matching, 0 = disable regexp matching
+
+use_regexp_matching=<%= node['nagios']['use_regexp_matching'] %>
+
+
+
+# "TRUE" REGULAR EXPRESSION MATCHING
+# This option controls whether or not "true" regular expression 
+# matching takes place in the object config files.  This option
+# only has an effect if regular expression matching is enabled
+# (see above).  If this option is DISABLED, regular expression
+# matching only occurs if a string contains wildcard characters
+# (* and ?).  If the option is ENABLED, regexp matching occurs
+# all the time (which can be annoying).
+# Values: 1 = enable true matching, 0 = disable true matching
+
+use_true_regexp_matching=0
+
+
+
+# ADMINISTRATOR EMAIL/PAGER ADDRESSES
+# The email and pager address of a global administrator (likely you).
+# Nagios never uses these values itself, but you can access them by
+# using the $ADMINEMAIL$ and $ADMINPAGER$ macros in your notification
+# commands.
+
+admin_email=root@localhost
+admin_pager=pageroot@localhost
+
+
+
+# DAEMON CORE DUMP OPTION
+# This option determines whether or not Nagios is allowed to create
+# a core dump when it runs as a daemon.  Note that it is generally
+# considered bad form to allow this, but it may be useful for
+# debugging purposes.  Enabling this option doesn't guarantee that
+# a core file will be produced, but that's just life...
+# Values: 1 - Allow core dumps
+#         0 - Do not allow core dumps (default)
+
+daemon_dumps_core=0
+
+
+
+# LARGE INSTALLATION TWEAKS OPTION
+# This option determines whether or not Nagios will take some shortcuts
+# which can save on memory and CPU usage in large Nagios installations.
+# Read the documentation for more information on the benefits/tradeoffs
+# of enabling this option.
+# Values: 1 - Enabled tweaks
+#         0 - Disable tweaks (default)
+
+use_large_installation_tweaks=0
+
+
+
+# ENABLE ENVIRONMENT MACROS
+# This option determines whether or not Nagios will make all standard
+# macros available as environment variables when host/service checks
+# and system commands (event handlers, notifications, etc.) are
+# executed.  Enabling this option can cause performance issues in 
+# large installations, as it will consume a bit more memory and (more
+# importantly) consume more CPU.
+# Values: 1 - Enable environment variable macros (default)
+#         0 - Disable environment variable macros
+
+enable_environment_macros=1
+
+
+
+# CHILD PROCESS MEMORY OPTION
+# This option determines whether or not Nagios will free memory in
+# child processes (processed used to execute system commands and host/
+# service checks).  If you specify a value here, it will override
+# program defaults.
+# Value: 1 - Free memory in child processes
+#        0 - Do not free memory in child processes
+
+#free_child_process_memory=1
+
+
+
+# CHILD PROCESS FORKING BEHAVIOR
+# This option determines how Nagios will fork child processes
+# (used to execute system commands and host/service checks).  Normally
+# child processes are fork()ed twice, which provides a very high level
+# of isolation from problems.  Fork()ing once is probably enough and will
+# save a great deal on CPU usage (in large installs), so you might
+# want to consider using this.  If you specify a value here, it will
+# program defaults.
+# Value: 1 - Child processes fork() twice
+#        0 - Child processes fork() just once
+
+#child_processes_fork_twice=1
+
+
+
+# DEBUG LEVEL
+# This option determines how much (if any) debugging information will
+# be written to the debug file.  OR values together to log multiple
+# types of information.
+# Values: 
+#          -1 = Everything
+#          0 = Nothing
+#         1 = Functions
+#          2 = Configuration
+#          4 = Process information
+#         8 = Scheduled events
+#          16 = Host/service checks
+#          32 = Notifications
+#          64 = Event broker
+#          128 = External commands
+#          256 = Commands
+#          512 = Scheduled downtime
+#          1024 = Comments
+#          2048 = Macros
+
+debug_level=0
+
+
+
+# DEBUG VERBOSITY
+# This option determines how verbose the debug log out will be.
+# Values: 0 = Brief output
+#         1 = More detailed
+#         2 = Very detailed
+
+debug_verbosity=1
+
+
+
+# DEBUG FILE
+# This option determines where Nagios should write debugging information.
+
+debug_file=/var/log/nagios3/nagios.debug
+
+
+
+# MAX DEBUG FILE SIZE
+# This option determines the maximum size (in bytes) of the debug file.  If
+# the file grows larger than this size, it will be renamed with a .old
+# extension.  If a file already exists with a .old extension it will
+# automatically be deleted.  This helps ensure your disk space usage doesn't
+# get out of control when debugging Nagios.
+
+max_debug_file_size=1000000
+
+
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/checkcommands.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/checkcommands.cfg
new file mode 100644 (file)
index 0000000..d9b6fe9
--- /dev/null
@@ -0,0 +1,25 @@
+# $Id$
+
+<% if node['nagios']['check_ganglia_metric']['enabled'] then -%>
+define command {
+       command_name    check_ganglia_metric
+<%
+case node[:platform_family]
+  when 'debian'
+-%>
+       command_line    /usr/local/bin/check_ganglia_metric.py --gmetad_host=<%= node['nagios']['check_ganglia_metric']['gmetad_host'] %> --cache_path=/var/lib/nagios3/.check_ganglia_metric.cache --metric_host=$HOSTADDRESS$ --metric_name=$ARG1$ --warning=$ARG2$ --critical=$ARG3$
+<%
+  when 'rhel'
+-%>
+       command_line    /usr/bin/check_ganglia_metric.py --gmetad_host=<%= node['nagios']['check_ganglia_metric']['gmetad_host'] %> --cache_path=/var/log/nagios/.check_ganglia_metric.cache --metric_host=$HOSTADDRESS$ --metric_name=$ARG1$ --warning=$ARG2$ --critical=$ARG3$
+<% end -%>
+}
+<% end -%>
+<% node['nagios']['objects']['commands'].each do |command| -%>
+define command {
+  <% command.each do |key, value| -%>
+       <%= key %>      <%= value %>
+  <% end -%>
+}
+
+<% end -%>
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/contacts.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/contacts.cfg
new file mode 100644 (file)
index 0000000..d31e85c
--- /dev/null
@@ -0,0 +1,20 @@
+# $Id$
+
+<%
+{
+  'contact'      => node['nagios']['objects']['contacts'],
+  'contactgroup' => node['nagios']['objects']['contactgroups']
+}.each do |type_name, objects|
+  objects.each do |object|
+-%>
+define <%= type_name %> {
+  <% object.each do |key, value| -%>
+       <%= key %>      <%= value %>
+  <% end -%>
+}
+
+<%
+  end
+end
+-%>
+
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/hosts.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/hosts.cfg
new file mode 100644 (file)
index 0000000..a6f8b35
--- /dev/null
@@ -0,0 +1,22 @@
+# $Id$
+
+<%
+{
+  'host'           => node['nagios']['objects']['hosts'],
+  'hostgroup'      => node['nagios']['objects']['hostgroups'],
+  'hostdependency' => node['nagios']['objects']['hostdependencies'],
+  'hostescalation' => node['nagios']['objects']['hostescalations'],
+  'hostextinfo'    => node['nagios']['objects']['hostextinfos']
+}.each do |type_name, objects|
+  objects.each do |object|
+-%>
+define <%= type_name %> {
+  <% object.each do |key, value| -%>
+       <%= key %>      <%= value %>
+  <% end -%>
+}
+
+<%
+  end
+end
+-%>
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/services.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/services.cfg
new file mode 100644 (file)
index 0000000..7018504
--- /dev/null
@@ -0,0 +1,111 @@
+# $Id$
+
+# Service templates
+<% if node['nagios']['check_ganglia_metric']['enabled'] then -%>
+## Ganglia
+define service {
+       name            generic-ganglia-service
+       use             generic-service
+       service_description     Ganglia Metric
+       is_volatile             0
+       check_period            24x7
+       max_check_attempts      3
+       normal_check_interval   5
+       retry_check_interval    1
+       contact_groups          <%= node['nagios']['objects']['default_contact_groups'] %>
+       notification_interval   240
+       notification_period     24x7
+       notification_options    w,u,c,r
+       #check_command           check_ganglia_metric!metricName!warning!critical
+       register                0
+}
+
+<%
+ganglia_cache_file = node.value_for_platform_family(
+  'debian' => '/var/lib/nagios3/.check_ganglia_metric.cache',
+  'rhel'   => '/var/log/nagios/.check_ganglia_metric.cache'
+)
+-%>
+define service {
+       name            generic-check_ganglia_cache-service
+       use             generic-ganglia-service
+       service_description     Cache for check_ganglia_metric
+       max_check_attempts      1
+       normal_check_interval   1
+       retry_check_interval    1
+       check_command           check_file_age!<%= ganglia_cache_file %>!90!120
+       host_name               localhost
+       register                0
+}
+
+define service {
+       name            generic-ganglia_heartbeat-service
+       use             generic-ganglia-service
+       service_description     Ganglia gmetad Heartbeat
+       max_check_attempts      3
+       normal_check_interval   1
+       retry_check_interval    1
+       check_command           check_ganglia_metric!load_fifteen!10.0!20.0
+       register                0
+}
+
+define service {
+       name            generic-load_one-service
+       use             generic-ganglia-service
+       service_description     CPU Load 1 Min via Ganglia
+       check_command           check_ganglia_metric!load_one!5.0!10.0
+       register                0
+}
+
+define service {
+       name            generic-load_five-service
+       use             generic-ganglia-service
+       service_description     CPU Load 5 Min via Ganglia
+       check_command           check_ganglia_metric!load_five!4.0!6.0
+       register                0
+}
+
+define service {
+       name            generic-load_fifteen-service
+       use             generic-ganglia-service
+       service_description     CPU Load 15 Min via Ganglia
+       check_command           check_ganglia_metric!load_fifteen!3.0!4.0
+       register                0
+}
+
+define service {
+       name            generic-part_max_used-service
+       use             generic-ganglia-service
+       service_description     Maximum Disk Space Used via Ganglia
+       check_command           check_ganglia_metric!part_max_used!80!90
+       register                0
+}
+
+define service {
+       name            generic-proc_total-service
+       use             generic-ganglia-service
+       service_description     Total Processes via Ganglia
+       check_command           check_ganglia_metric!proc_total!250!400
+       register                0
+}
+<% end -%>
+<%
+{
+  'service'           => node['nagios']['objects']['services'],
+  'servicegroup'      => node['nagios']['objects']['servicegroups'],
+  'servicedependency' => node['nagios']['objects']['servicedependencies'],
+  'serviceescalation' => node['nagios']['objects']['serviceescalations'],
+  'serviceextinfo'    => node['nagios']['objects']['serviceextinfos']
+}.each do |type_name, objects|
+  objects.each do |object|
+-%>
+define <%= type_name %> {
+  <% object.each do |key, value| -%>
+       <%= key %>      <%= value %>
+  <% end -%>
+}
+
+<%
+  end
+end
+-%>
diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios3/site/timeperiods.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios3/site/timeperiods.cfg
new file mode 100644 (file)
index 0000000..0e5d22f
--- /dev/null
@@ -0,0 +1,18 @@
+# $Id$
+
+<%
+{
+  'timeperiod' => node['nagios']['objects']['timeperiods']
+}.each do |type_name, objects|
+  objects.each do |object|
+-%>
+define <%= type_name %> {
+  <% object.each do |key, value| -%>
+       <%= key %>      <%= value %>
+  <% end -%>
+}
+
+<%
+  end
+end
+-%>
diff --git a/cookbooks/nagios-grid/templates/default/usr/lib/nagios/plugins/check_logs.pl b/cookbooks/nagios-grid/templates/default/usr/lib/nagios/plugins/check_logs.pl
new file mode 100755 (executable)
index 0000000..ec6c896
--- /dev/null
@@ -0,0 +1,189 @@
+#!/usr/bin/perl -w
+#
+# Log file regular expression detector for Nagios.
+# Written by Serge Sergeev (serge at ocslab.com)
+# Based on check_log2.pl written by Aaron Bostick (abostick@mydoconline.com)
+# Last modified: 06-07-2005
+#
+# Usage: check_logs -c <configuration_file> 
+# For usage detiles: check_logs --help 
+#
+# Description:
+# This plugin will scan arbitrary text files looking for regular expression 
+# matches.  
+BEGIN {
+    if ($0 =~ s/^(.*?)[\/\\]([^\/\\]+)$//) {
+        $prog_dir = $1;
+        $prog_name = $2;
+       unshift(@INC,$prog_dir);
+    }
+}
+require 5.004;
+use vars qw($opt_c $opt_v $opt_h $opt_l $opt_s $opt_p $opt_n $prog_dir $prog_name);
+use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
+use Getopt::Long;
+use strict;
+
+sub print_usage ();
+sub print_version ();
+sub print_help ();
+
+my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks);
+my $conf_file = '';
+my %res;
+my $plugin_revision = '$Revision: 1.1 $ ';
+our $seek_file_template;
+our @log_files;
+
+print_help() if ! GetOptions ( 
+       "l|logfile=s"      => \$opt_l,
+       "s|seekfile=s"     => \$opt_s,
+       "p|pattern=s"      => \$opt_p,
+       "n|negpattern:s"   => \$opt_n,
+       "c|conf=s"         => \$opt_c,
+       "v|version"        => \$opt_v,
+       "h|help"           => \$opt_h 
+);
+
+($opt_v) && print_version ();
+($opt_h) && print_help ();
+usage("Other options not allowed if -c <configuration file> is used\n") if ( $opt_c && ($opt_l || $opt_s || $opt_p || $opt_n ));
+usage("Specify at least -l <log_file> -s <seek_file>  -p <pattern> options if you don't use -c <configuration file>\n") if ( !( ($opt_l && $opt_s && $opt_p ) || $opt_c ) );
+if ( $opt_c ) {
+       eval('require "' . $opt_c . '"') or usage("Error: can not load configuration file.\n");} else {
+       @log_files = (  { 
+               'file_name'             => $opt_l,
+               'reg_exp'                       => $opt_p,
+               'neg_reg_exp'   => $opt_n,
+       }       );
+       $seek_file_template = $opt_s;
+}      
+########################## main_loop ############################
+foreach my $cnf ( @log_files ) {
+    my @seek_pos;
+    $cnf->{'file_name'} =~ m/^(.*?)[\/\\]([^\/\\]+)$/;
+    my $fbasename = $2;
+    my $seek_file = $seek_file_template;
+    $seek_file =~ s/\$log_file/$fbasename/;
+    $seek_file .= $cnf->{'seek_file_suffix'} if defined($cnf->{'seek_file_suffix'});
+    next unless ( -r $cnf->{'file_name'} );
+    # Open log file
+    open LOG_FILE, $cnf->{'file_name'} || die "Unable to open log file $cnf->{'file_name'}: $!";
+    # Try to open log seek file.  If open fails, we seek from beginning of
+    # file by default.
+    if (open(SEEK_FILE, $seek_file)) {
+        chomp(@seek_pos = <SEEK_FILE>);
+        close(SEEK_FILE);
+        #  If file is empty, no need to seek...
+        if ($seek_pos[0] != 0) {
+            # Compare seek position to actual file size.  If file size is smaller
+            # then we just start from beginning i.e. file was rotated, etc.
+            ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat(LOG_FILE);
+            if ($seek_pos[0] <= $size) {
+                seek(LOG_FILE, $seek_pos[0], 0);
+            }
+        }
+    }
+    # Loop through every line of log file and check for pattern matches.
+    # Count the number of pattern matches and remember the full line of 
+    # the most recent match.
+    my $lc = 0;
+    my $add_lines = '';
+    my $pattern_line = '';
+    my $pattern_count = 0;
+         $cnf->{'lines'} = 1 if  ! defined( $cnf->{'lines'} );
+    while (<LOG_FILE>) {
+                       chomp ;
+                       s/\x0d//m;
+                       if ($lc !=0 && $lc < $cnf->{'lines'} ){
+                               if ( $cnf->{'new_line_reg_exp'} ) {
+                                       if ( $_ !~ $cnf->{'new_line_reg_exp'} ) {
+                                               $add_lines = $lc==1?$_:$add_lines . $_ ;
+            $lc++; 
+                                       } else {
+                                               $lc = $cnf->{'lines'};
+                                       }
+                               } else {        
+               $add_lines = $lc==1?$_:$add_lines . $_ ;
+                                       $lc++; 
+                               }
+                       }
+                       if ($cnf->{'neg_reg_exp'}) {
+                               if ((/$cnf->{'reg_exp'}/) && !(/$cnf->{'neg_reg_exp'}/)) {
+                                       $pattern_count += 1;
+                                       $pattern_line = $_;
+                               }
+                       } elsif (/$cnf->{'reg_exp'}/) {
+                               $pattern_count += 1;
+                               $pattern_line = $_;
+                               $lc=1;
+                       }
+    }
+    # Overwrite log seek file and print the byte position we have seeked to.
+    open(SEEK_FILE, "> $seek_file") || die "Unable to open seek count file $seek_file: $!";
+    print SEEK_FILE tell(LOG_FILE);
+    close(SEEK_FILE);
+    close(LOG_FILE);
+    $res{$fbasename}->{'message'} = $pattern_line . $add_lines;
+    $res{$fbasename}->{'count'} = $pattern_count;
+}
+my $exit_code = $ERRORS{'OK'};
+foreach my $i ( sort keys %res ) {
+  if ( $res{$i}->{'count'} ) {
+   print "$i => ($res{$i}->{'count'}): $res{$i}->{'message'}; ";
+   $exit_code = $ERRORS{'WARNING'}; }
+  else {
+   print "$i => OK; ";
+  }
+}
+print "\n";
+exit $exit_code;
+#
+sub print_usage () {
+    print "Usage: $prog_name ( -c <configuration file> | -l <log_file> -s <log_seek_file> -p <pattern> [-n <negpattern>] )\n";
+    print "Usage: $prog_name [ -v | --version ]\n";
+    print "Usage: $prog_name [ -h | --help ]\n";
+}
+sub print_version () {
+    print_revision($prog_name, $plugin_revision);
+    exit $ERRORS{'OK'};
+}
+sub print_help () {
+    print_revision($prog_name, $plugin_revision);
+    print "\n";
+    print "Scan arbitrary n log files for regular expression matches.\n";
+    print "\n";
+    print_usage();
+    print "\n";
+    print "-c, --conf=<confile>\n";
+    print "    The configuration file(see syntax below)\n";
+    print "-l, --logfile=<logfile>\n";
+    print "    The log file to be scanned\n";
+    print "-s, --seekfile=<seekfile>\n";
+    print "    The temporary file to store the seek position of the last scan\n";
+    print "-p, --pattern=<pattern>\n";
+    print "    The regular expression to scan for in the log file\n";
+    print "-n, --negpattern=<negpattern>\n";
+    print "    The regular expression to skip in the log file\n";
+    print "The configuration file syntax\n";
+    print <<EOC;
+# Required file name template to store position of the end of file last check
+\$seek_file_template='/var/lib/nagios/\$log_file.check_log.seek';
+
+# Required log files array
+\@log_files = ( 
+   {'file_name' => '/var/log/messages',    #required file name
+    'reg_exp' =>'check pass; user unknown',#required reg_exp
+    'lines' => 2,                         #optional number of output lines  after match
+#    'new_line_reg_exp' => '^',                   #optional new line regex to stop output lines
+     'seek_file_suffix' => '2'                    #optional seek file suffix
+   },
+   {'file_name' => '/var/log/secure',    #required file name
+    'reg_exp' =>'Failed password for',   #required reg_exp
+   },
+);
+EOC
+    print "\n";
+    support();
+    exit $ERRORS{'OK'};
+}
diff --git a/cookbooks/nagios-grid/templates/default/usr/lib/nagios/plugins/check_smart.pl b/cookbooks/nagios-grid/templates/default/usr/lib/nagios/plugins/check_smart.pl
new file mode 100755 (executable)
index 0000000..971a57a
--- /dev/null
@@ -0,0 +1,446 @@
+#!/usr/bin/perl -w
+# Check SMART status of ATA/SCSI disks, returning any usable metrics as perfdata.
+# For usage information, run ./check_smart -h
+#
+# This script was created under contract for the US Government and is therefore Public Domain
+#
+# Changes and Modifications
+# =========================
+# Feb 3, 2009: Kurt Yoder - initial version of script (rev 1.0)
+# Jul 8, 2013: Claudio Kuenzler - support hardware raids like megaraid (rev 2.0)
+# Jul 9, 2013: Claudio Kuenzler - update help output (rev 2.1)
+# Oct 11, 2013: Claudio Kuenzler - making the plugin work on FreeBSD (rev 3.0)
+# Oct 11, 2013: Claudio Kuenzler - allowing -i sat (SATA on FreeBSD) (rev 3.1)
+# Nov 4, 2013: Claudio Kuenzler - works now with CCISS on FreeBSD (rev 3.2)
+# Nov 4, 2013: Claudio Kuenzler - elements in grown defect list causes warning (rev 3.3)
+# Nov 6, 2013: Claudio Kuenzler - add threshold option "bad" (-b) (rev 4.0)
+# Nov 7, 2013: Claudio Kuenzler - modified help (rev 4.0)
+# Nov 7, 2013: Claudio Kuenzler - bugfix in threshold logic (rev 4.1)
+# Mar 19, 2014: Claudio Kuenzler - bugfix in defect list perfdata (rev 4.2)
+# Apr 22, 2014: Jerome Lauret - implemented -g to do a global lookup (rev 5.0)
+# Apr 25, 2014: Claudio Kuenzler - cleanup, merge Jeromes code, perfdata output fix (rev 5.1)
+# May 5, 2014: Caspar Smit - Fixed output bug in global check / issue #3 (rev 5.2)
+# Feb 4, 2015: Caspar Smit and cguadall - Allow detection of more than 26 devices / issue #5 (rev 5.3)
+# Feb 5, 2015: Bastian de Groot - Different ATA vs. SCSI lookup (rev 5.4)
+# Feb 11, 2015: Josh Behrends - Allow script to run outside of nagios plugins dir / wiki url update (rev 5.5)
+# Feb 11, 2015: Claudio Kuenzler - Allow script to run outside of nagios plugins dir for FreeBSD too (rev 5.5)
+# Mar 12, 2015: Claudio Kuenzler - Change syntax of -g parameter (regex is now awaited from input) (rev 5.6)
+
+use strict;
+use Getopt::Long;
+
+use File::Basename qw(basename);
+my $basename = basename($0);
+
+my $revision = '$Revision: 5.6 $';
+
+use FindBin;
+use lib $FindBin::Bin;
+BEGIN {
+ push @INC,'/usr/lib/nagios/plugins','/usr/lib64/nagios/plugins','/usr/local/libexec/nagios';
+}
+use utils qw(%ERRORS &print_revision &support &usage);
+
+$ENV{'PATH'}='/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin';
+$ENV{'BASH_ENV'}='';
+$ENV{'ENV'}='';
+
+use vars qw($opt_b $opt_d $opt_g $opt_debug $opt_h $opt_i $opt_v);
+Getopt::Long::Configure('bundling');
+GetOptions(
+                          "debug"       => \$opt_debug,
+        "b=i" => \$opt_b, "bad=i"       => \$opt_b,
+        "d=s" => \$opt_d, "device=s"    => \$opt_d,
+        "g=s" => \$opt_g, "global=s"    => \$opt_g,
+        "h"   => \$opt_h, "help"        => \$opt_h,
+        "i=s" => \$opt_i, "interface=s" => \$opt_i,
+        "v"   => \$opt_v, "version"     => \$opt_v,
+);
+
+if ($opt_v) {
+        print_revision($basename,$revision);
+        exit $ERRORS{'OK'};
+}
+
+if ($opt_h) {
+        print_help();
+        exit $ERRORS{'OK'};
+}
+
+my ($device, $interface) = qw//;
+if ($opt_d || $opt_g ) {
+        unless($opt_i){
+                print "must specify an interface for $opt_d using -i/--interface!\n\n";
+                print_help();
+                exit $ERRORS{'UNKNOWN'};
+        }
+
+        # list of devices for a loop
+        my(@dev);
+
+        if ( $opt_d ){
+            # normal mode - push opt_d on the list of devices
+            push(@dev,$opt_d);
+        } else {
+            # glob all devices - try '?' first 
+            @dev =glob($opt_g);
+        }
+
+        foreach my $opt_dl (@dev){
+            warn "Found $opt_dl\n" if $opt_debug;
+            if (-b $opt_dl || -c $opt_dl){
+                $device .= $opt_dl.":";
+
+            } else {
+                warn "$opt_dl is not a valid block/character special device!\n\n" if $opt_debug;
+            }
+        }
+
+        if ( ! defined($device) ){
+            print "Could not find any valid block/character special device for ".
+                  ($opt_d?"device $opt_d ":"pattern $opt_g")." !\n\n";
+            exit $ERRORS{'UNKNOWN'};
+        }
+
+        # Allow all device types currently supported by smartctl
+        # See http://www.smartmontools.org/wiki/Supported_RAID-Controllers
+        if ($opt_i =~ m/(ata|scsi|3ware|areca|hpt|cciss|megaraid|sat)/) {
+                $interface = $opt_i;
+        } else {
+                print "invalid interface $opt_i for $opt_d!\n\n";
+                print_help();
+                exit $ERRORS{'UNKNOWN'};
+        }
+}
+
+
+if ($device eq "") {
+    print "must specify a device!\n\n";
+    print_help();
+    exit $ERRORS{'UNKNOWN'};
+}
+
+
+my $smart_command = 'sudo smartctl';
+my $exit_status = 'OK';
+my $exit_status_local = 'OK';
+my $status_string = '';
+my $perf_string = '';
+my $Terminator = ' --- ';
+
+
+foreach $device ( split(":",$device) ){
+    my @error_messages = qw//;
+    my($status_string_local)='';
+    my($tag,$label);
+    $exit_status_local = 'OK';
+
+    if ($opt_g){
+        # we had a pattern based on $opt_g
+        $tag   = $device;
+        $tag   =~ s/$opt_g//;
+        $label = "[$device] - ";
+    } else {
+        # we had a device specified using $opt_d (traditional)
+        $label = "";
+        $tag   = $device;
+    }
+
+
+    warn "###########################################################\n" if $opt_debug;
+    warn "(debug) CHECK 1: getting overall SMART health status for $tag \n" if $opt_debug;
+    warn "###########################################################\n\n\n" if $opt_debug;
+
+    my $full_command = "$smart_command -d $interface -H $device";
+    warn "(debug) executing:\n$full_command\n\n" if $opt_debug;
+
+    my @output = `$full_command`;
+    warn "(debug) output:\n@output\n\n" if $opt_debug;
+
+    my $output_mode = "";
+    # parse ata output, looking for "health status: passed"
+    my $found_status = 0;
+    my $line_str_ata = 'SMART overall-health self-assessment test result: '; # ATA SMART line
+    my $ok_str_ata = 'PASSED'; # ATA SMART OK string
+
+    my $line_str_scsi = 'SMART Health Status: '; # SCSI and CCISS SMART line
+    my $ok_str_scsi = 'OK'; #SCSI and CCISS SMART OK string
+
+    foreach my $line (@output){
+        if($line =~ /$line_str_scsi(.+)/){
+            $found_status = 1;
+            $output_mode = "scsi";
+            warn "(debug) parsing line:\n$line\n\n" if $opt_debug;
+            if ($1 eq $ok_str_scsi) {
+                warn "(debug) found string '$ok_str_scsi'; status OK\n\n" if $opt_debug;
+            }
+            else {
+                warn "(debug) no '$ok_str_scsi' status; failing\n\n" if $opt_debug;
+                push(@error_messages, "Health status: $1");
+                escalate_status('CRITICAL');
+            }
+        }
+        if($line =~ /$line_str_ata(.+)/){
+            $found_status = 1;
+            $output_mode = "ata";
+            warn "(debug) parsing line:\n$line\n\n" if $opt_debug;
+            if ($1 eq $ok_str_ata) {
+                warn "(debug) found string '$ok_str_ata'; status OK\n\n" if $opt_debug;
+            }
+            else {
+                warn "(debug) no '$ok_str_ata' status; failing\n\n" if $opt_debug;
+                push(@error_messages, "Health status: $1");
+                escalate_status('CRITICAL');
+            }
+        }
+    }
+
+    unless ($found_status) {
+        push(@error_messages, 'No health status line found');
+        escalate_status('UNKNOWN');
+    }
+
+
+    warn "###########################################################\n" if $opt_debug;
+    warn "(debug) CHECK 2: getting silent SMART health check\n" if $opt_debug;
+    warn "###########################################################\n\n\n" if $opt_debug;
+
+    $full_command = "$smart_command -d $interface -q silent -A $device";
+    warn "(debug) executing:\n$full_command\n\n" if $opt_debug;
+
+    system($full_command);
+    my $return_code = $?;
+    warn "(debug) exit code:\n$return_code\n\n" if $opt_debug;
+
+    if ($return_code & 0x01) {
+        push(@error_messages, 'Commandline parse failure');
+        escalate_status('UNKNOWN');
+    }
+    if ($return_code & 0x02) {
+        push(@error_messages, 'Device could not be opened');
+        escalate_status('UNKNOWN');
+    }
+    if ($return_code & 0x04) {
+        push(@error_messages, 'Checksum failure');
+        escalate_status('WARNING');
+    }
+    if ($return_code & 0x08) {
+        push(@error_messages, 'Disk is failing');
+        escalate_status('CRITICAL');
+    }
+    if ($return_code & 0x10) {
+        push(@error_messages, 'Disk is in prefail');
+        escalate_status('WARNING');
+    }
+    if ($return_code & 0x20) {
+        push(@error_messages, 'Disk may be close to failure');
+        escalate_status('WARNING');
+    }
+    if ($return_code & 0x40) {
+        push(@error_messages, 'Error log contains errors');
+        escalate_status('WARNING');
+    }
+    if ($return_code & 0x80) {
+        push(@error_messages, 'Self-test log contains errors');
+        escalate_status('WARNING');
+    }
+    if ($return_code && !$exit_status_local) {
+        push(@error_messages, 'Unknown return code');
+        escalate_status('CRITICAL');
+    }
+
+    if ($return_code) {
+        warn "(debug) non-zero exit code, generating error condition\n\n" if $opt_debug;
+    } else {
+        warn "(debug) zero exit code, status OK\n\n" if $opt_debug;
+    }
+
+
+    warn "###########################################################\n" if $opt_debug;
+    warn "(debug) CHECK 3: getting detailed statistics\n" if $opt_debug;
+    warn "(debug) information contains a few more potential trouble spots\n" if $opt_debug;
+    warn "(debug) plus, we can also use the information for perfdata/graphing\n" if $opt_debug;
+    warn "###########################################################\n\n\n" if $opt_debug;
+
+    $full_command = "$smart_command -d $interface -A $device";
+    warn "(debug) executing:\n$full_command\n\n" if $opt_debug;
+    @output = `$full_command`;
+    warn "(debug) output:\n@output\n\n" if $opt_debug;
+    my @perfdata = qw//;
+
+    # separate metric-gathering and output analysis for ATA vs SCSI SMART output
+    # Yeah - but megaraid is the same output as ata
+    if ($output_mode =~ "ata") {
+        foreach my $line(@output){
+            # get lines that look like this:
+            #    9 Power_On_Minutes        0x0032   241   241   000    Old_age   Always       -       113h+12m
+            next unless $line =~ /^\s*\d+\s(\S+)\s+(?:\S+\s+){6}(\S+)\s+(\d+)/;
+            my ($attribute_name, $when_failed, $raw_value) = ($1, $2, $3);
+            if ($when_failed ne '-'){
+                push(@error_messages, "Attribute $attribute_name failed at $when_failed");
+                escalate_status('WARNING');
+                warn "(debug) parsed SMART attribute $attribute_name with error condition:\n$when_failed\n\n" if $opt_debug;
+            }
+            # some attributes produce questionable data; no need to graph them
+            if (grep {$_ eq $attribute_name} ('Unknown_Attribute', 'Power_On_Minutes') ){
+                next;
+            }
+            push (@perfdata, "$attribute_name=$raw_value") if $opt_d;
+
+            # do some manual checks
+            if ( ($attribute_name eq 'Current_Pending_Sector') && $raw_value ) {
+                if ($opt_b) {
+                    if (($raw_value > 0) && ($raw_value >= $opt_b)) {
+                        push(@error_messages, "$raw_value Sectors pending re-allocation");
+                        escalate_status('WARNING');
+                        warn "(debug) Current_Pending_Sector is non-zero ($raw_value)\n\n" if $opt_debug;
+                    }
+                    elsif (($raw_value > 0) && ($raw_value < $opt_b)) {
+                        push(@error_messages, "$raw_value Sectors pending re-allocation (but less than threshold $opt_b)");
+                        warn "(debug) Current_Pending_Sector is non-zero ($raw_value) but less than $opt_b\n\n" if $opt_debug;
+                    }
+                } else {
+                    push(@error_messages, "Sectors pending re-allocation");
+                    escalate_status('WARNING');
+                    warn "(debug) Current_Pending_Sector is non-zero ($raw_value)\n\n" if $opt_debug;
+                }
+            }
+        }
+
+    } else {
+        my ($current_temperature, $max_temperature, $current_start_stop, $max_start_stop) = qw//;
+        foreach my $line(@output){
+            if ($line =~ /Current Drive Temperature:\s+(\d+)/){
+                $current_temperature = $1;
+            }
+            elsif ($line =~ /Drive Trip Temperature:\s+(\d+)/){
+                $max_temperature = $1;
+            }
+            elsif ($line =~ /Current start stop count:\s+(\d+)/){
+                $current_start_stop = $1;
+            }
+            elsif ($line =~ /Recommended maximum start stop count:\s+(\d+)/){
+                $max_start_stop = $1;
+            }
+            elsif ($line =~ /Elements in grown defect list:\s+(\d+)/){
+                my $defectlist = $1;
+                # check for elements in grown defect list
+                if ($opt_b) {
+                    push (@perfdata, "defect_list=$defectlist;;$opt_b") if $opt_d;
+                    if (($defectlist > 0) && ($defectlist >= $opt_b)) {
+                        push(@error_messages, "$defectlist Elements in grown defect list (threshold $opt_b)");
+                        escalate_status('WARNING');
+                        warn "(debug) Elements in grown defect list is non-zero ($defectlist)\n\n" if $opt_debug;
+                    }
+                    elsif (($defectlist > 0) && ($defectlist < $opt_b)) {
+                        push(@error_messages, "Note: $defectlist Elements in grown defect list");
+                        warn "(debug) Elements in grown defect list is non-zero ($defectlist) but less than $opt_b\n\n" if $opt_debug;
+                    }
+                }
+                else {
+                    if ($defectlist > 0) {
+                        push (@perfdata, "defect_list=$defectlist") if $opt_d;
+                        push(@error_messages, "$defectlist Elements in grown defect list");
+                        escalate_status('WARNING');
+                        warn "(debug) Elements in grown defect list is non-zero ($defectlist)\n\n" if $opt_debug;
+                    }
+                }
+            }
+            elsif ($line =~ /Blocks sent to initiator =\s+(\d+)/){
+                push (@perfdata, "sent_blocks=$1") if $opt_d;
+            }
+        }
+        if($current_temperature){
+            if($max_temperature){
+                push (@perfdata, "temperature=$current_temperature;;$max_temperature") if $opt_d;
+                if($current_temperature > $max_temperature){
+                    warn "(debug) Disk temperature is greater than max ($current_temperature > $max_temperature)\n\n" if $opt_debug;
+                    push(@error_messages, 'Disk temperature is higher than maximum');
+                    escalate_status('CRITICAL');
+                }
+            }
+            else{
+                push (@perfdata, "temperature=$current_temperature") if $opt_d;
+            }
+        }
+        if($current_start_stop){
+            if($max_start_stop){
+                push (@perfdata, "start_stop=$current_start_stop;$max_start_stop") if $opt_d;
+                if($current_start_stop > $max_start_stop){
+                    warn "(debug) Disk start_stop is greater than max ($current_start_stop > $max_start_stop)\n\n" if $opt_debug;
+                    push(@error_messages, 'Disk start_stop is higher than maximum');
+                    escalate_status('WARNING');
+                }
+            }
+            else{
+                push (@perfdata, "start_stop=$current_start_stop") if $opt_d;
+            }
+        }
+    }
+    warn "(debug) gathered perfdata:\n@perfdata\n\n" if $opt_debug;
+    $perf_string = join(' ', @perfdata);
+    
+    warn "###########################################################\n" if $opt_debug;
+    warn "(debug) LOCAL STATUS: $exit_status_local, FINAL STATUS: $exit_status\n" if $opt_debug;
+    warn "###########################################################\n\n\n" if $opt_debug;
+    
+    if($exit_status_local ne 'OK'){
+      if ($opt_g) {
+        $status_string_local = $label.join(', ', @error_messages);
+        $status_string .= $status_string_local.$Terminator;
+      }
+      else {
+        $status_string = join(', ', @error_messages);
+      }
+    } 
+    else {
+      if ($opt_g) {
+        $status_string_local = $label."Device is clean";
+        $status_string .= $status_string_local.$Terminator;
+      }
+      else {
+        $status_string = "no SMART errors detected. ".join(', ', @error_messages);
+      }
+    }
+
+}
+
+    warn "(debug) final status/output: $exit_status\n" if $opt_debug;
+
+$status_string =~ s/$Terminator$//;
+print "$exit_status: $status_string|$perf_string\n";
+exit $ERRORS{$exit_status};
+
+
+sub print_help {
+        print_revision($basename,$revision);
+        print "\nUsage: $basename {-d=<block device>|-g=<block device regex>} -i=(ata|scsi|3ware,N|areca,N|hpt,L/M/N|cciss,N|megaraid,N) [-b N] [--debug]\n\n";
+        print "At least one of the below. -d supersedes -g\n";
+        print "  -d/--device: a physical block device to be SMART monitored, eg /dev/sda\n";
+        print "  -g/--global: a regular expression name of physical devices to be SMART monitored\n";
+        print "               Example: '/dev/sd[a-z]' will search for all /dev/sda until /dev/sdz devices and report errors globally.\n";
+        print "Note that -g only works with a fixed interface input (e.g. scsi, ata), not with special interface ids like cciss,1\n";
+        print "\n";
+        print "Other options\n";
+        print "  -i/--interface: device's interface type\n";
+        print "  (See http://www.smartmontools.org/wiki/Supported_RAID-Controllers for interface convention)\n";
+        print "  -b/--bad: Threshold value (integer) when to warn for N bad entries\n";
+        print "  -h/--help: this help\n";
+        print "  --debug: show debugging information\n";
+        print "  -v/--version: Version number\n";
+}
+
+# escalate an exit status IFF it's more severe than the previous exit status
+sub escalate_status {
+        my $requested_status = shift;
+        # no test for 'CRITICAL'; automatically escalates upwards
+        if ($requested_status eq 'WARNING') {
+                return if ($exit_status|$exit_status_local) eq 'CRITICAL';
+        }
+        if ($requested_status eq 'UNKNOWN') {
+                return if ($exit_status|$exit_status_local) eq 'WARNING';
+                return if ($exit_status|$exit_status_local) eq 'CRITICAL';
+        }
+        $exit_status = $requested_status;
+        $exit_status_local = $requested_status;
+}