summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRamesh Nachimuthu <rnachimu@redhat.com>2014-05-01 12:37:54 +0530
committerSahina Bose <sabose@redhat.com>2014-05-02 02:23:55 -0700
commitd0327fab7fbaf2c6f30e807fb8c90dfe5fa9db5c (patch)
treefb9d155b0a7221e3ce26bce92f825d1cb255033b /plugins
parente222d3e0c4209d59f079d15484138bea9d859378 (diff)
autoconf: discover volume list and info separately
NRPE doesn't support transfering large junk of data as a result. Hence we have to discover the volume details one by one. Added two NRPE commands 'discover_volume_list' and 'discover_volume_info'. 'discover_volume_list' returns the list of volume names with volume type. 'discover_volume_info' returns the bricks details of a given volume. Change-Id: I753be5e407fe14988f23ca77007b3a585537b360 Signed-off-by: Ramesh Nachimuthu <rnachimu@redhat.com> Reviewed-on: http://review.gluster.org/7630 Reviewed-by: Kanagaraj M <kmayilsa@redhat.com> Reviewed-by: Sahina Bose <sabose@redhat.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am2
-rwxr-xr-xplugins/discover_volumes.py83
-rwxr-xr-xplugins/discoverlogicalcomponents.py50
3 files changed, 84 insertions, 51 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 700072a..de6bf41 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -17,7 +17,7 @@ dist_glusternagiosplugins_PYTHON = \
check_proc_status.py \
cpu.py \
discoverpeers.py \
- discoverlogicalcomponents.py \
+ discover_volumes.py \
discoverhostparams.py \
configure_gluster_node.py \
__init__.py \
diff --git a/plugins/discover_volumes.py b/plugins/discover_volumes.py
new file mode 100755
index 0000000..f917d40
--- /dev/null
+++ b/plugins/discover_volumes.py
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+# discover_volumes.py -- nagios plugin for discovering
+#logical gluster components
+# 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 json
+import sys
+import argparse
+
+from glusternagios import utils
+from glusternagios import glustercli
+
+
+def discoverVolumes(volumeName, list):
+ """
+ This method helps to discover volumes list and volume info
+ Parameters
+ ----------
+ list: Flag used for getting volume info. If the flag is 'True' then the
+ method will return only list of volume names with volume Type and doesn't
+ include the brick details. . If list is 'False' then returns the volume
+ details with brick information.
+
+ volumeName: Fetch information only for the given volume.
+ Note: glustercli.volumeInfo(volName) command accept a volumeName. But if
+ the volume name is not passed then it returns details about all the volumes
+ in the cluster.
+ Returns
+ ---------
+ Returns volume details in the following dictionary format
+ {
+ 'vol-name' : {vol-details}
+ 'vol-name' : {vol-details}
+ 'vol-name' : {vol-details}
+ ...
+ }
+ """
+ resultlist = {}
+ volumes = glustercli.volumeInfo(volumeName)
+ for key, volume in volumes.iteritems():
+ volDict = {}
+ volDict['name'] = key
+ volDict['type'] = volume['volumeType']
+ if not list:
+ volDict['bricks'] = []
+ for brick in volume['bricksInfo']:
+ brickproplist = brick['name'].split(':')
+ volDict['bricks'].append({'brickpath': brickproplist[1],
+ 'hostUuid': brick['hostUuid']})
+ resultlist[key] = volDict
+ resultString = json.dumps(resultlist)
+ return resultString
+
+
+def get_arg_parser():
+ parser = argparse.ArgumentParser(description="Discovery tool for "
+ "Gluster volumes")
+ parser.add_argument('-l', '--list', action='store_true', dest='list',
+ help="Fetch only list of volumes names")
+ parser.add_argument('-v', '--volume', action='store', dest='volume',
+ type=str, help='Volume name')
+ return parser
+
+
+if __name__ == '__main__':
+ args = get_arg_parser().parse_args()
+ resultString = discoverVolumes(args.volume, args.list)
+ print resultString
+ sys.exit(utils.PluginStatusCode.OK)
diff --git a/plugins/discoverlogicalcomponents.py b/plugins/discoverlogicalcomponents.py
deleted file mode 100755
index 0d826ff..0000000
--- a/plugins/discoverlogicalcomponents.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/python
-# discoverlogicalcomponents.py -- nagios plugin for discovering
-#logical gluster components
-# 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 json
-import sys
-
-from glusternagios import utils
-from glusternagios import glustercli
-
-
-def discoverlogicalelements():
- resultlist = {}
- resultlist['volumes'] = []
-
- volumes = glustercli.volumeInfo()
- for volume in volumes.values():
- volDict = {}
- volDict['name'] = volume['volumeName']
- volDict['type'] = volume['volumeType']
- volDict['bricks'] = []
- for brick in volume['bricksInfo']:
- brickproplist = brick['name'].split(':')
- volDict['bricks'].append({'hostip': brickproplist[0],
- 'brickpath': brickproplist[1],
- 'hostUuid': brick['hostUuid']})
- resultlist['volumes'].append(volDict)
-
- resultstring = json.dumps(resultlist)
- print resultstring
- sys.exit(utils.PluginStatusCode.OK)
-
-
-if __name__ == '__main__':
- discoverlogicalelements()