summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNishanth Thomas <nthomas@redhat.com>2014-04-02 18:10:40 +0530
committerBala.FA <barumuga@redhat.com>2014-04-29 10:14:33 +0530
commit13928ae0da5afb2d58fa2a268ebc61ee522ba3c4 (patch)
tree32a73c5d4d262649f48520c9f228a336287c27a3
parent3f8ba5ca094e20d01fbd437a35c7f91c2d69b06f (diff)
Added the plugins for discovering the gluster components
Modified the code to address the review comments Change-Id: Iaf18745920ec1177622b5f8a667a2e77f89796da Signed-off-by: Nishanth Thomas <nthomas@redhat.com> Reviewed-on: https://code.engineering.redhat.com/gerrit/22345 Tested-by: Ramesh Nachimuthu <rnachimu@redhat.com> Reviewed-by: Kanagaraj Mayilsamy <kmayilsa@redhat.com>
-rw-r--r--gluster-nagios-addons.spec.in3
-rw-r--r--plugins/Makefile.am3
-rwxr-xr-xplugins/discoverhostparams.py46
-rwxr-xr-xplugins/discoverlogicalcomponents.py71
-rwxr-xr-xplugins/discoverpeers.py47
5 files changed, 170 insertions, 0 deletions
diff --git a/gluster-nagios-addons.spec.in b/gluster-nagios-addons.spec.in
index 1de9f70..22b3aec 100644
--- a/gluster-nagios-addons.spec.in
+++ b/gluster-nagios-addons.spec.in
@@ -131,6 +131,9 @@ command[check_cpu_multicore]=%{_libdir}/nagios/plugins/gluster/cpu.py -w 80 -c 9
command[check_interfaces]=%{_libdir}/nagios/plugins/gluster/network.py -e lo -e ';vdsmdummy;'
command[check_brick_usage]=/usr/lib64/nagios/plugins/gluster/check_disk_and_inode.py -w 80 -c 90 -u MB -n -i \$ARG1\$
command[check_vol_utilization]=sudo /usr/lib64/nagios/plugins/gluster/check_vol_utilization.py \$ARG1\$ -w \$ARG2\$ -c \$ARG3\$
+###Auto Discovery related
+command[discoverpeers]=/usr/lib64/nagios/plugins/gluster/discoverpeers.py
+command[discoverlogicalcomponents]=/usr/lib64/nagios/plugins/gluster/discoverlogicalcomponents.py
EOF
%_init_enable nrpe
%_init_restart crond
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 4c840c1..eb88ee1 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -12,6 +12,9 @@ dist_glusternagiosplugins_PYTHON = \
check_vol_utilization.py \
check_vol_status.py \
cpu.py \
+ discoverpeers.py \
+ discoverlogicalcomponents.py \
+ discoverhostparams.py \
__init__.py \
memory.py \
network.py \
diff --git a/plugins/discoverhostparams.py b/plugins/discoverhostparams.py
new file mode 100755
index 0000000..9722dcf
--- /dev/null
+++ b/plugins/discoverhostparams.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# discoverhostparams.py -- nagios plugin discovering the host parameters
+# 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 commands
+import json
+import sys
+
+from glusternagios import utils
+
+
+def discoverhostparams():
+ command_host_name = utils.hostnameCmdPath.cmd
+ result_dict = {}
+ resultString = ""
+
+ hostname = commands.getoutput(command_host_name)
+ result_dict['hostname'] = hostname
+ resultString = json.dumps(result_dict)
+ print resultString
+ sys.exit(utils.PluginStatusCode.OK)
+
+
+###
+#This plugin discovers all the host specific parameters
+#Currently it gets only the hostname from the node
+#but when we add support for discovering physical
+#components like cpu,network,disk etc, all those will be
+#addded as part of this module
+###
+if __name__ == '__main__':
+ discoverhostparams()
diff --git a/plugins/discoverlogicalcomponents.py b/plugins/discoverlogicalcomponents.py
new file mode 100755
index 0000000..50a259f
--- /dev/null
+++ b/plugins/discoverlogicalcomponents.py
@@ -0,0 +1,71 @@
+#!/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 commands
+import json
+import sys
+
+from glusternagios import utils
+
+
+def discoverbricks(vol_info_out):
+ bricklist = []
+ xmlElemList = utils.parseXml(vol_info_out,
+ "./volInfo/volumes/volume/bricks/brick")
+ for brick in xmlElemList:
+ brickdict = {}
+ brickstr = brick.text
+ brickproplist = brickstr.split(':')
+ brickdict['hostip'] = brickproplist[0]
+ brickdict['brickpath'] = brickproplist[1]
+ bricklist.append(brickdict)
+
+ return bricklist
+
+
+def discovervolumes(vol_info_out):
+ vollist = []
+
+ #Get the volume info
+ xmlElemList = utils.parseXml(vol_info_out, "./volInfo/volumes/volume")
+ for volume in xmlElemList:
+ voldict = {}
+ voldict['name'] = volume.find('name').text
+ voldict['typeStr'] = volume.find('typeStr').text
+ vollist.append(voldict)
+
+ return vollist
+
+
+def discoverlogicalelements():
+ resultlist = {}
+ resultstring = ""
+ command_vol_info = utils.sudoCmdPath.cmd + " " + \
+ utils.glusterCmdPath.cmd + " volume info --xml"
+ vol_info_out = commands.getoutput(command_vol_info)
+ resultlist['volumes'] = discovervolumes(vol_info_out)
+ resultlist['bricks'] = discoverbricks(vol_info_out)
+ #convert to string
+ resultstring = json.dumps(resultlist)
+ print resultstring
+ sys.exit(utils.PluginStatusCode.OK)
+
+
+if __name__ == '__main__':
+ discoverlogicalelements()
diff --git a/plugins/discoverpeers.py b/plugins/discoverpeers.py
new file mode 100755
index 0000000..b4d8a70
--- /dev/null
+++ b/plugins/discoverpeers.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+# discoverpeers.py -- nagios plugin for discovering gluster peers
+# 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 commands
+import sys
+import json
+
+from glusternagios import utils
+
+
+def discoverhosts():
+ xmlElemList = []
+ nrpe_out_list = []
+ resltdict = {}
+ resultstring = ""
+
+ command_peer_status = utils.sudoCmdPath.cmd + " " \
+ + utils.glusterCmdPath.cmd + " peer status --xml"
+ peer_status_out = commands.getoutput(command_peer_status)
+
+ xmlElemList = utils.parseXml(peer_status_out, "./peerStatus/peer")
+ for peer in xmlElemList:
+ if (peer.find('connected').text == "1"):
+ resltdict['hostip'] = peer.find('hostname').text
+ nrpe_out_list.append(resltdict)
+ resultstring = json.dumps(nrpe_out_list)
+ print resultstring
+ sys.exit(utils.PluginStatusCode.OK)
+
+
+if __name__ == '__main__':
+ discoverhosts()