From: whitestar Date: Fri, 18 Jun 2021 06:03:08 +0000 (+0900) Subject: add Nagios4 support. X-Git-Tag: nagios-grid-0.2.0~2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5a5ea22284ea5295f8729f9041c3cedf1e736f51;p=metasearch%2Fgrid-chef-repo.git add Nagios4 support. --- diff --git a/cookbooks/nagios-grid/CHANGELOG.md b/cookbooks/nagios-grid/CHANGELOG.md index 59cda9e..436ae7c 100644 --- a/cookbooks/nagios-grid/CHANGELOG.md +++ b/cookbooks/nagios-grid/CHANGELOG.md @@ -1,6 +1,10 @@ nagios-grid CHANGELOG ===================== +0.2.0 +----- +- add Nagios4 support. + 0.1.7 ----- - bug fix. diff --git a/cookbooks/nagios-grid/attributes/default.rb b/cookbooks/nagios-grid/attributes/default.rb index 5986457..8bcaf7a 100644 --- a/cookbooks/nagios-grid/attributes/default.rb +++ b/cookbooks/nagios-grid/attributes/default.rb @@ -47,6 +47,8 @@ default['nagios']['cgi'] = { ## >= 2.3 default['nagios']['web']['Require'] = [ 'all granted', + # Nagios4 default + #'ip ::1/128 fc00::/7 fe80::/10 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.168.0.0/16', ] ## < 2.3 default['nagios']['web']['Order'] = 'Allow,Deny' # e.g. 'Deny,Allow' diff --git a/cookbooks/nagios-grid/recipes/nagios-base.rb b/cookbooks/nagios-grid/recipes/nagios-base.rb index 5f86176..b3f5b4b 100644 --- a/cookbooks/nagios-grid/recipes/nagios-base.rb +++ b/cookbooks/nagios-grid/recipes/nagios-base.rb @@ -28,13 +28,20 @@ site_cfg_dir = nil nagios_pkgs = nil nagios_service = nil httpd_service = nil +tpl_ctx = 'nagios3' case node['platform_family'] when 'debian' root_cfg_dir = '/etc/nagios3' + nagios_service = 'nagios3' + if platform == 'ubuntu' && platform_version >= '20.04' + root_cfg_dir = '/etc/nagios4' + nagios_service = 'nagios4' + end + nagios_pkgs = [ # Note: PHP is not php5 but php7.0 in Ubuntu 16.04 or later - 'nagios-plugins', + 'nagios-plugins', # virtual package -> monitoring-plugins (>= Ubuntu 20.04) 'nagios-nrpe-plugin', 'nagios-images', ] @@ -59,7 +66,6 @@ when 'debian' nagios_pkgs.push('libapache2-mod-auth-kerb') end - nagios_service = 'nagios3' httpd_service = 'apache2' httpd_nagios_conf = "#{root_cfg_dir}/apache2.conf" when 'rhel' @@ -139,7 +145,7 @@ end 'services-generic.cfg', ].each {|tpl| template "#{base_cfg_dir}/#{tpl}" do - source "etc/nagios3/base/#{tpl}" + source "etc/#{tpl_ctx}/base/#{tpl}" owner 'root' group 'root' mode '0644' @@ -161,7 +167,7 @@ end 'checkcommands.cfg', ].each {|cfg_file| template "#{site_cfg_dir}/#{cfg_file}" do - source "etc/nagios3/site/#{cfg_file}" + source "etc/#{tpl_ctx}/site/#{cfg_file}" owner 'root' group 'root' mode '0644' diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios4/apache2.conf b/cookbooks/nagios-grid/templates/default/etc/nagios4/apache2.conf index f46e372..faefbb5 100644 --- a/cookbooks/nagios-grid/templates/default/etc/nagios4/apache2.conf +++ b/cookbooks/nagios-grid/templates/default/etc/nagios4/apache2.conf @@ -32,17 +32,54 @@ Alias /nagios4 /usr/share/nagios4/htdocs # can configure which people get to see a particular service from # within the nagios configuration. # - Require ip ::1/128 fc00::/7 fe80::/10 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.168.0.0/16 - - AuthDigestDomain "Nagios4" - AuthDigestProvider file - AuthUserFile "/etc/nagios4/htdigest.users" - AuthGroupFile "/etc/group" - AuthName "Nagios4" - AuthType Digest - Require all granted - #Require valid-user - + + 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 -%> + + + = 2.3> + #Require ip ::1/128 fc00::/7 fe80::/10 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.168.0.0/16 +<% node['nagios']['web']['Require'].each do |condition| -%> + Require <%= condition %> +<% end -%> + + +<% +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 -%> + # Note: requires a2enmod auth_digest authz_groupfile + # + # AuthDigestDomain "Nagios4" + # AuthDigestProvider file + # AuthUserFile "/etc/nagios4/htdigest.users" + # AuthGroupFile "/etc/group" + # AuthName "Nagios4" + # AuthType Digest + # Require all granted + # #Require valid-user + # diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios4/cgi.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios4/cgi.cfg index 2718441..7c5a7a1 100644 --- a/cookbooks/nagios-grid/templates/default/etc/nagios4/cgi.cfg +++ b/cookbooks/nagios-grid/templates/default/etc/nagios4/cgi.cfg @@ -112,7 +112,7 @@ use_ssl_authentication=0 # not use authorization. You may use an asterisk (*) to # authorize any user who has authenticated to the web server. -authorized_for_system_information=nagiosadmin +authorized_for_system_information=<%= node['nagios']['cgi']['authorized_for_system_information'] %> @@ -124,7 +124,7 @@ authorized_for_system_information=nagiosadmin # an asterisk (*) to authorize any user who has authenticated # to the web server. -authorized_for_configuration_information=nagiosadmin +authorized_for_configuration_information=<%= node['nagios']['cgi']['authorized_for_configuration_information'] %> @@ -137,7 +137,7 @@ authorized_for_configuration_information=nagiosadmin # You may use an asterisk (*) to authorize any user who has # authenticated to the web server. -authorized_for_system_commands=nagiosadmin +authorized_for_system_commands=<%= node['nagios']['cgi']['authorized_for_system_commands'] %> @@ -149,8 +149,8 @@ authorized_for_system_commands=nagiosadmin # 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=nagiosadmin -authorized_for_all_hosts=nagiosadmin +authorized_for_all_services=<%= node['nagios']['cgi']['authorized_for_all_services'] %> +authorized_for_all_hosts=<%= node['nagios']['cgi']['authorized_for_all_hosts'] %> @@ -163,8 +163,8 @@ authorized_for_all_hosts=nagiosadmin # authorization). You may use an asterisk (*) to authorize any # user who has authenticated to the web server. -authorized_for_all_service_commands=nagiosadmin -authorized_for_all_host_commands=nagiosadmin +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'] %> @@ -288,7 +288,7 @@ refresh_rate=90 # within the UI after the initial page load. Setting this to 0 # will show all results. -result_limit=100 +result_limit=<%= node['nagios']['cgi']['result_limit'] %> diff --git a/cookbooks/nagios-grid/templates/default/etc/nagios4/nagios.cfg b/cookbooks/nagios-grid/templates/default/etc/nagios4/nagios.cfg index 9a39871..badd18d 100644 --- a/cookbooks/nagios-grid/templates/default/etc/nagios4/nagios.cfg +++ b/cookbooks/nagios-grid/templates/default/etc/nagios4/nagios.cfg @@ -63,7 +63,8 @@ cfg_file=/etc/nagios4/objects/localhost.cfg #cfg_dir=/etc/nagios4/printers #cfg_dir=/etc/nagios4/switches #cfg_dir=/etc/nagios4/routers - +cfg_dir=/etc/nagios4/<%= node['nagios']['base_cfg_dir'] %> +cfg_dir=/etc/nagios4/<%= node['nagios']['site_cfg_dir'] %> @@ -150,7 +151,7 @@ nagios_group=nagios # you will have to enable this. # Values: 0 = disable commands, 1 = enable commands -check_external_commands=1 +check_external_commands=<%= node['nagios']['check_external_commands'] %> @@ -818,8 +819,13 @@ enable_event_handlers=1 # performance data. # Values: 1 = process performance data, 0 = do not process performance data -process_performance_data=0 - +<% +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 @@ -831,7 +837,18 @@ process_performance_data=0 # 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 -%> + @@ -1163,7 +1180,7 @@ illegal_macro_output_chars=`~$&|'"<> # group names/descriptions in some fields of various object types. # Values: 1 = enable regexp matching, 0 = disable regexp matching -use_regexp_matching=0 +use_regexp_matching=<%= node['nagios']['use_regexp_matching'] %> diff --git a/cookbooks/nagios-grid/version b/cookbooks/nagios-grid/version index 1180819..0ea3a94 100644 --- a/cookbooks/nagios-grid/version +++ b/cookbooks/nagios-grid/version @@ -1 +1 @@ -0.1.7 +0.2.0