From bd2def940d9bd241a71d6e5f4c5905555743781d Mon Sep 17 00:00:00 2001 From: ndarshan Date: Mon, 2 Jun 2014 14:40:14 +0530 Subject: nagios-server-addons: Fix for dummy config file issue. This patch replaces the configfile node1.cfg(gluster-host) by temp_node1.cfg which is of type linux-server having service PING. And this dummy config file is renamed to temp_node1.cfg.sample during auto-discovery as it is not needed after we configure actual hosts. Also this patch sets the config variable allow_empty_hostgroup_assignment to 1, which is needed for nagios to allow declaration of empty host-group with services. Change-Id: I03cc54975f5ff5857f8d82b66110e049e4195009 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1091236 Signed-off-by: ndarshan Reviewed-on: http://review.gluster.org/7952 Reviewed-by: Kanagaraj M Reviewed-by: Shubhendu Tripathi Reviewed-by: Sahina Bose --- config/Makefile.am | 2 +- config/node1.cfg | 8 -------- config/temp_node1.cfg | 20 ++++++++++++++++++++ nagios-server-addons.spec.in | 1 + plugins/discovery.py | 13 +++++++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) delete mode 100644 config/node1.cfg create mode 100644 config/temp_node1.cfg diff --git a/config/Makefile.am b/config/Makefile.am index 3176aa7..b97ba89 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -12,7 +12,7 @@ glusternagiosconf_DATA = \ glusternagiosdefaultconfdir = $(sysconfdir)/nagios/gluster/default glusternagiosdefaultconf_DATA = \ glustercluster.cfg.sample \ - node1.cfg \ + temp_node1.cfg \ $(NULL) glusternagiosmibsdir = /usr/share/snmp/mibs diff --git a/config/node1.cfg b/config/node1.cfg deleted file mode 100644 index d9669cb..0000000 --- a/config/node1.cfg +++ /dev/null @@ -1,8 +0,0 @@ -define host{ - use gluster-host - host_name node1 - alias web-node01 - address localhost - hostgroups gluster_hosts -} - diff --git a/config/temp_node1.cfg b/config/temp_node1.cfg new file mode 100644 index 0000000..e049885 --- /dev/null +++ b/config/temp_node1.cfg @@ -0,0 +1,20 @@ +##################################################################### +# Configuration for dummy host temp_node1 with service check_ping # +# This dummy host is added to avoid nagios from erroring out before # +# auto-discovery script is run, This file will be renamed by auto- # +# discovery script to remove this configuration. # +##################################################################### + +define host{ + use linux-server + host_name temp_node1 + alias localhost + address 127.0.0.1 +} + +define service{ + use local-service + host_name temp_node1 + service_description PING + check_command check_ping!100.0,20%!500.0,60% +} diff --git a/nagios-server-addons.spec.in b/nagios-server-addons.spec.in index fe96e52..a816e43 100644 --- a/nagios-server-addons.spec.in +++ b/nagios-server-addons.spec.in @@ -156,6 +156,7 @@ cfg_dir=/etc/nagios/gluster service_perfdata_command=process-service-perfdata host_perfdata_command=process-host-perfdata +allow_empty_hostgroup_assignment=1 broker_module=/usr/lib64/check_mk/livestatus.o @nagioslivestatussocketpath@ EOF fi diff --git a/plugins/discovery.py b/plugins/discovery.py index 18dc714..825d8d3 100755 --- a/plugins/discovery.py +++ b/plugins/discovery.py @@ -527,6 +527,19 @@ if __name__ == '__main__': args.nagiosServerIP, args.mode, args.timeout) print "Cluster configurations synced successfully from host %s" % \ (args.hostip) + # Rename the configuration file for dummy host from temp_node1.cfg + # to temp_node1.cfg.sample as this host is not needed after other + # hosts are configured through auto-discovery. + dummy_host_config_file = DEFAULT_AUTO_CONFIG_DIR \ + + '/default/temp_node1.cfg' + try: + if os.path.exists(dummy_host_config_file): + os.rename( + dummy_host_config_file, + dummy_host_config_file + '.sample' + ) + except Exception as e: + pass #If Nagios is running then try to restart. Otherwise don't do #anything. if server_utils.isNagiosRunning(): -- cgit