• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

Grid環境構築用のChefリポジトリです。


Commit MetaInfo

Revision3177eff536468b1404355a4f6f22a8e0ff196a6b (tree)
Time2018-10-07 18:57:03
Authorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

adds workaround for check_disk_smb command failure.

Change Summary

Incremental Difference

--- a/cookbooks/nagios-grid/CHANGELOG.md
+++ b/cookbooks/nagios-grid/CHANGELOG.md
@@ -1,6 +1,12 @@
11 nagios-grid CHANGELOG
22 =====================
33
4+0.1.5
5+-----
6+- bug fix.
7+- adds helper libraries.
8+- adds workaround for `check_disk_smb` command failure.
9+
410 0.1.4
511 -----
612 - adds workaround for `check_all_disks` command failure.
--- /dev/null
+++ b/cookbooks/nagios-grid/libraries/helper.rb
@@ -0,0 +1,31 @@
1+#
2+# Cookbook Name:: nagios-grid
3+# Library:: Helper
4+#
5+# Copyright 2018, whitestar
6+#
7+# Licensed under the Apache License, Version 2.0 (the "License");
8+# you may not use this file except in compliance with the License.
9+# You may obtain a copy of the License at
10+#
11+# http://www.apache.org/licenses/LICENSE-2.0
12+#
13+# Unless required by applicable law or agreed to in writing, software
14+# distributed under the License is distributed on an "AS IS" BASIS,
15+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+# See the License for the specific language governing permissions and
17+# limitations under the License.
18+#
19+
20+# extend Array
21+class Array
22+ def dns_suffix(domain = 'example.com')
23+ map {|host|
24+ "#{host}.#{domain}"
25+ }
26+ end
27+
28+ def examples
29+ dns_suffix
30+ end
31+end
--- a/cookbooks/nagios-grid/recipes/nagios-base.rb
+++ b/cookbooks/nagios-grid/recipes/nagios-base.rb
@@ -20,6 +20,8 @@
2020 platform = node['platform']
2121 platform_version = node['platform_version']
2222
23+autoreload = node['nagios']['autoreload']
24+
2325 root_cfg_dir = nil
2426 base_cfg_dir = nil
2527 site_cfg_dir = nil
@@ -98,7 +100,7 @@ nagios_pkgs.each {|pkg|
98100 }
99101
100102 nagios_action = if node['nagios']['autostart']
101- [:enable]
103+ [:enable] # do not start
102104 else
103105 [:disable]
104106 end
@@ -117,7 +119,8 @@ end
117119 owner 'root'
118120 group 'root'
119121 mode '0644'
120- notifies :reload, "service[#{nagios_service}]" if node['nagios']['autoreload']
122+ # Note: if the service is not runnnig, `:reload` is no effective and does not fail.
123+ notifies :restart, "service[#{nagios_service}]", :delayed if autoreload
121124 end
122125 }
123126
@@ -138,7 +141,7 @@ end
138141 owner 'root'
139142 group 'root'
140143 mode '0644'
141- notifies :reload, "service[#{nagios_service}]" if node['nagios']['autoreload']
144+ notifies :restart, "service[#{nagios_service}]", :delayed if autoreload
142145 end
143146 }
144147
@@ -160,7 +163,7 @@ end
160163 owner 'root'
161164 group 'root'
162165 mode '0644'
163- notifies :reload, "service[#{nagios_service}]" if node['nagios']['autoreload']
166+ notifies :restart, "service[#{nagios_service}]", :delayed if autoreload
164167 end
165168 }
166169
@@ -174,7 +177,7 @@ template httpd_nagios_conf do
174177 owner 'root'
175178 group 'root'
176179 mode '0644'
177- notifies :restart, "service[#{httpd_service}]"
180+ notifies :restart, "service[#{httpd_service}]", :delayed
178181 end
179182
180183 if node['nagios']['check_external_commands'] == '1'
@@ -213,7 +216,7 @@ dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
213216 EOC
214217 not_if "dpkg-statoverride --list | grep '#{override_nagios3_rw}'"
215218 not_if "dpkg-statoverride --list | grep '#{override_nagios3}'"
216- notifies :restart, "service[#{nagios_service}]" if node['nagios']['autoreload']
219+ notifies :restart, "service[#{nagios_service}]", :delayed if autoreload
217220 end
218221 when 'rhel'
219222 bash 'modify_permissions_for_check_external_commands' do
@@ -224,7 +227,7 @@ dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
224227 EOC
225228 not_if "ls -dl /var/spool/nagios/cmd | grep 'drwx--s---' | grep 'nagios apache'"
226229 not_if "ls -dl /var/spool/nagios | grep 'drwxr-x--x'"
227- notifies :restart, "service[#{nagios_service}]" if node['nagios']['autoreload']
230+ notifies :restart, "service[#{nagios_service}]", :delayed if autoreload
228231 end
229232 end
230233 end
@@ -263,5 +266,17 @@ file '/etc/nagios3/conf.d/localhost_nagios2.cfg' do
263266 conf.send(:editor).lines.join('')
264267 }
265268 only_if { File.exist?(path) }
266- notifies :reload, "service[#{nagios_service}]" if node['nagios']['autoreload']
269+ notifies :restart, "service[#{nagios_service}]", :delayed if autoreload
270+end
271+
272+# https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/embeddedperl.html
273+file '/usr/lib/nagios/plugins/check_disk_smb' do
274+ content lazy {
275+ cmd = Chef::Util::FileEdit.new(File.exist?(path) ? path : '/dev/null')
276+ cmd.search_file_delete_line(/^# nagios: -epn$/)
277+ cmd.insert_line_after_match(/^#!.*$/, "# nagios: -epn\n")
278+ cmd.send(:editor).lines.join('')
279+ }
280+ only_if { File.exist?(path) }
281+ notifies :restart, "service[#{nagios_service}]", :delayed if autoreload
267282 end
--- a/cookbooks/nagios-grid/templates/default/etc/nagios3/base/checkcommands-generic.cfg
+++ b/cookbooks/nagios-grid/templates/default/etc/nagios3/base/checkcommands-generic.cfg
@@ -8,6 +8,11 @@ define command {
88 }
99
1010 define command {
11+ command_name check_disk_smb_alt
12+ command_line $USER1$/check_disk_smb -H $HOSTADDRESS$ -s '$ARG1$'
13+}
14+
15+define command {
1116 command_name check_file_age
1217 command_line $USER1$/check_file_age -f $ARG1$ -w $ARG2$ -c $ARG3$
1318 }
--- a/cookbooks/nagios-grid/version
+++ b/cookbooks/nagios-grid/version
@@ -1 +1 @@
1-0.1.4
1+0.1.5
Show on old repository browser