OSDN Git Service

adds NRPE no ssl support. nagios-grid-0.1.6
authorwhitestar <whitestar@users.osdn.me>
Mon, 8 Oct 2018 06:06:11 +0000 (15:06 +0900)
committerwhitestar <whitestar@users.osdn.me>
Mon, 8 Oct 2018 06:06:11 +0000 (15:06 +0900)
cookbooks/nagios-grid/CHANGELOG.md
cookbooks/nagios-grid/attributes/default.rb
cookbooks/nagios-grid/recipes/nagios-base.rb
cookbooks/nagios-grid/recipes/nagios-nrpe-server.rb
cookbooks/nagios-grid/templates/default/etc/default/nagios-nrpe-server [new file with mode: 0644]
cookbooks/nagios-grid/templates/default/etc/nagios/nrpe_local.cfg
cookbooks/nagios-grid/templates/default/etc/nagios3/base/checkcommands-generic.cfg
cookbooks/nagios-grid/version

index 1b5786d..449c76a 100644 (file)
@@ -1,6 +1,11 @@
 nagios-grid CHANGELOG
 =====================
 
+0.1.6
+-----
+- adds NRPE no ssl support.
+- adds `/etc/default/nagios-nrpe-server` template.
+
 0.1.5
 -----
 - bug fix.
index b24ae6a..5986457 100644 (file)
@@ -100,6 +100,16 @@ default['nagios']['check_ganglia_metric']['enabled'] = false
 default['nagios']['check_ganglia_metric']['gmetad_host'] = 'localhost'
 
 # NRPE
+## command
+default['nagios']['check_nrpe']['nossl'] = false
+## server
+default['nagios']['nrpe']['default'] = {
+  # expanded in the `/etc/default/nagios-nrpe-server`
+  #'NRPE_OPTS' => '"-n"',          # new env. var. e.g. Ubuntu 18.04
+  #'DAEMON_OPTS' => '"--no-ssl"',  # old env. var. e.g. Debian 8
+  #'NICENESS' = '5',
+  #'INETD' = '0',
+}
 default['nagios']['nrpe']['allowed_hosts'] = '127.0.0.1'
 default['nagios']['nrpe']['with_smartmontools'] = false
 default['nagios']['nrpe']['check_mem.pl'] = {
@@ -107,6 +117,10 @@ default['nagios']['nrpe']['check_mem.pl'] = {
   'crit' => '90',
   'extra_opts' => '-u',  # -u|f, -C
 }
+default['nagios']['nrpe']['check_load'] = {
+  'warn' => '15,10,5',
+  'crit' => '30,25,20',
+}
 default['nagios']['nrpe']['check_total_procs'] = {
   'warn' => '100',
   'crit' => '200',
index c2e7873..5f86176 100644 (file)
@@ -35,6 +35,7 @@ when 'debian'
   nagios_pkgs = [
     # Note: PHP is not php5 but php7.0 in Ubuntu 16.04 or later
     'nagios-plugins',
+    'nagios-nrpe-plugin',
     'nagios-images',
   ]
 
@@ -62,6 +63,8 @@ when 'debian'
   httpd_service = 'apache2'
   httpd_nagios_conf = "#{root_cfg_dir}/apache2.conf"
 when 'rhel'
+  include_recipe 'yum-epel'
+
   root_cfg_dir = '/etc/nagios'
   nagios_pkgs = [
     'nagios',
@@ -69,12 +72,11 @@ when 'rhel'
   ]
 
   nagios_pkgs += \
-    %w(load users ping ssh ntp http disk swap procs file_age).map {|item|
+    %w(load users ping ssh nrpe ntp http disk swap procs file_age).map {|item|
       "nagios-plugins-#{item}"
     }
 
   if node['nagios']['with_pnp4nagios']
-    include_recipe 'yum-epel'
     nagios_pkgs += [
       'pnp4nagios',
     ]
index 6476669..cbf690d 100644 (file)
@@ -17,6 +17,7 @@
 # limitations under the License.
 #
 
+platform_family = node['platform_family']
 platform = node['platform']
 platform_version = node['platform_version']
 
@@ -26,6 +27,8 @@ pkgs = [
   'nagios-plugins-contrib',  # for check_memory
 ]
 
+# https://packages.debian.org/search?keywords=libnagios-plugin-perl
+# https://packages.ubuntu.com/search?keywords=libnagios-plugin-perl
 if (platform == 'debian' && platform_version < '9.0') \
   || (platform == 'ubuntu' && platform_version < '17.04')
   pkgs += ['libnagios-plugin-perl']  # for check_memory
@@ -60,6 +63,15 @@ template '/etc/nagios/nrpe_local.cfg' do
   notifies :reload, 'service[nagios-nrpe-server]'
 end
 
+template '/etc/default/nagios-nrpe-server' do
+  source  'etc/default/nagios-nrpe-server'
+  owner 'root'
+  group 'root'
+  mode '0644'
+  notifies :reload, 'service[nagios-nrpe-server]'
+  only_if { platform_family == 'debian' }
+end
+
 [
   'check_logs.pl',
   'check_mem.pl',
diff --git a/cookbooks/nagios-grid/templates/default/etc/default/nagios-nrpe-server b/cookbooks/nagios-grid/templates/default/etc/default/nagios-nrpe-server
new file mode 100644 (file)
index 0000000..b63ee32
--- /dev/null
@@ -0,0 +1,29 @@
+# defaults file for nagios-nrpe-server
+# (this file is a /bin/sh compatible fragment)
+
+# Note: New env. var. e.g. Ubuntu 18.04
+# NRPE_OPTS are any extra cmdline parameters you'd like to pass along to the
+# nrpe daemon.
+#
+# The -n option disables SSL support.
+#NRPE_OPTS="-n"
+
+# Note: Old env. var. e.g. Debian 8
+# DAEMON_OPTS are any extra cmdline parameters you'd like to
+#             pass along to the nrpe daemon
+#DAEMON_OPTS="--no-ssl"
+
+# NICENESS is if you want to run the server at a different nice() priority.
+# (only used by the init script)
+#NICENESS=5
+
+# INETD is if you want to run the server via inetd (default=0, run as daemon).
+# (only used by the init script)
+#INETD=0
+<%
+node['nagios']['nrpe']['default'].each {|key, value|
+-%>
+<%= key %>=<%= value %>
+<%
+}
+-%>
index ec1ef2d..bfaff90 100644 (file)
@@ -1,11 +1,15 @@
 # This file was generated by Chef.
+<%
+conf = node['nagios']['nrpe']
+-%>
 
-allowed_hosts=<%= node['nagios']['nrpe']['allowed_hosts'] %>
+allowed_hosts=<%= conf['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_load]=/usr/lib/nagios/plugins/check_load -r -w <%= conf['check_load']['warn'] %> -c <%= conf['check_load']['crit'] %>
+command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w <%= conf['check_total_procs']['warn'] %> -c <%= conf['check_total_procs']['crit'] %>
 command[check_memory]=/usr/lib/nagios/plugins/check_memory
 <%
-mem = node['nagios']['nrpe']['check_mem.pl']
+mem = conf['check_mem.pl']
 -%>
 command[check_mem]=/usr/lib/nagios/plugins/check_mem.pl <%= mem['extra_opts'] %> -w <%= mem['warn'] %> -c <%= mem['crit'] %>
 
@@ -14,7 +18,7 @@ command[check_apt]=/usr/lib/nagios/plugins/check_apt
 # Disk
 <%
 (0..3).each {|num|
-  target = node['nagios']['nrpe']["check_disk#{num}"]
+  target = conf["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'] %>
 <%
@@ -22,7 +26,7 @@ command[check_disk<%= num %>]=/usr/lib/nagios/plugins/check_disk -w <%= target['
 -%>
 <%
 (0..3).each {|num|
-  target = node['nagios']['nrpe']["check_smart#{num}"]
+  target = conf["check_smart#{num}"]
 -%>
 command[check_smart<%= num %>]=sudo /usr/lib/nagios/plugins/check_ide_smart -n -d <%= target['device'] %>
 <%
@@ -32,9 +36,9 @@ command[check_smart_devs]=sudo /usr/lib/nagios/plugins/check_smart.pl -g '/dev/s
 
 # DNS lookup
 <%
-dig = node['nagios']['nrpe']['check_dig']
-dig_in = node['nagios']['nrpe']['check_dig_in']
-dig_ex = node['nagios']['nrpe']['check_dig_ex']
+dig = conf['check_dig']
+dig_in = conf['check_dig_in']
+dig_ex = conf['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'] %>
index 12acc1c..dca6749 100644 (file)
@@ -1,4 +1,9 @@
 # This file was generated by Chef.
+<%
+nrpe_opts = []
+nrpe_opts.push('-n') if node['nagios']['check_nrpe']['nossl']
+nrpe_opts = nrpe_opts.join(' ')
+-%>
 
 define command {
        command_name    check_all_disks_alt
@@ -77,72 +82,72 @@ define command {
 # NRPE
 define command {
        command_name    check_remote_apt
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_apt
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_apt
 }
 
 define command {
        command_name    check_remote_apc_status
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_apc_status
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_apc_time
 }
 
 define command {
        command_name    check_remote_dig
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_dig
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_dig
 }
 
 define command {
        command_name    check_remote_dig_in
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_dig_in
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_dig_ex
 }
 
 define command {
        command_name    check_remote_logs
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_logs
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_logs
 }
 
 define command {
        command_name    check_remote_command
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c $ARG1$
 }
 
 define command {
        command_name    check_remote_users
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_users
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_users
 }
 
 define command {
        command_name    check_remote_load
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_load
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_load
 }
 
 define command {
        command_name    check_remote_memory
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_memory
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_memory
 }
 
 define command {
        command_name    check_remote_mem
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_mem
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_mem
 }
 
 <%
@@ -150,7 +155,7 @@ define command {
 -%>
 define command {
        command_name    check_remote_disk<%= num %>
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_disk<%= num %>
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_disk<%= num %>
 }
 
 <%
@@ -161,7 +166,7 @@ define command {
 -%>
 define command {
        command_name    check_remote_smart<%= num %>
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_smart<%= num %>
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_smart<%= num %>
 }
 
 <%
@@ -169,66 +174,66 @@ define command {
 -%>
 define command {
        command_name    check_remote_smart_devs
-       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_smart_devs
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -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
+       command_line    $USER1$/check_nrpe <%= nrpe_opts %> -H $HOSTADDRESS$ -c check_xen_domU1
 }