diff options
author | Ramesh Nachimuthu <rnachimu@redhat.com> | 2014-04-28 18:55:12 +0530 |
---|---|---|
committer | Sahina Bose <sabose@redhat.com> | 2014-04-29 06:27:11 -0700 |
commit | 63a7839a3d05494960d4ba15e5fef08157c82887 (patch) | |
tree | 0d33ba93737beda4368ec6c6edf74a60d97d3066 /plugins | |
parent | b67af78d5f230cf64faa85812d1c8eb32994ecd4 (diff) |
autoconf: Add NRPE command to configure NSCA
Adding a new NRPE command 'configure_gluster_node' to configure
gluster nodes to send passive check results using NSCA.
Change-Id: I1993eefab112f9fb5ba7764593cebca9923b4aba
Signed-off-by: Ramesh Nachimuthu <rnachimu@redhat.com>
Reviewed-on: http://review.gluster.org/7595
Reviewed-by: Sahina Bose <sabose@redhat.com>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Makefile.am | 1 | ||||
-rwxr-xr-x | plugins/configure_gluster_node.py | 58 |
2 files changed, 59 insertions, 0 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index b1592de..700072a 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -19,6 +19,7 @@ dist_glusternagiosplugins_PYTHON = \ discoverpeers.py \ discoverlogicalcomponents.py \ discoverhostparams.py \ + configure_gluster_node.py \ __init__.py \ memory.py \ network.py \ diff --git a/plugins/configure_gluster_node.py b/plugins/configure_gluster_node.py new file mode 100755 index 0000000..2a6e0e9 --- /dev/null +++ b/plugins/configure_gluster_node.py @@ -0,0 +1,58 @@ +#!/usr/bin/python +# configure_gluster_node.py -- nagios plugin for configuring the node +# Copyright (C) 2014 Red Hat Inc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +import sys +import argparse + +from glusternagios import utils +import nscautils + +__SED_CMD_PATH = utils.CommandPath("sed", "/bin/sed") + + +def configureParam(paramName, value): + sed_pattern = '/%s=.*/c\\%s=%s' % (paramName, paramName, value) + command_sed = [__SED_CMD_PATH.cmd, '-i', + sed_pattern, nscautils.__NAGIOSSERVER_CONF] + utils.execCmd(command_sed) + + +def configureNode(nagiosAddress, clusterName, hostName): + configureParam("nagios_server", nagiosAddress) + configureParam("cluster_name", clusterName) + configureParam("hostname_in_nagios", hostName) + print "Configured the node successfully" + sys.exit(utils.PluginStatusCode.OK) + + +def create_arg_parser(): + parser = argparse.ArgumentParser(description="Gluster Auto Config Tool") + parser.add_argument('-c', '--cluster', action='store', dest='cluster', + type=str, required=True, help='Cluster name') + parser.add_argument('-n', '--nagios', action='store', dest='nagios', + type=str, required=True, help='Nagios Server Address') + parser.add_argument('-H', '--hostname', action='store', dest='hostname', + type=str, required=True, + help='Name of the host in Nagios Configuration') + return parser + + +if __name__ == '__main__': + parser = create_arg_parser() + args = parser.parse_args() + configureNode(args.nagios, args.cluster, args.hostname) |