diff options
author | Sahina Bose <sabose@redhat.com> | 2014-06-05 13:11:22 +0530 |
---|---|---|
committer | Sahina Bose <sabose@redhat.com> | 2014-06-06 02:55:16 -0700 |
commit | 94ce627a6a2eb58d172d8af51b7eced6bae4c18f (patch) | |
tree | a891f4d0d5e0ef0e9901b27f10c5f7f209124390 | |
parent | 13948635feb101ea64d1e19e9af89e96badb34e6 (diff) |
nagios-common: Georep cli session wise parsing corrected
Geo-rep status cli command does not uniquely identify
sessions per node line output. It prefixes the slave
node with slave volume name. And when the slave volume
has multiple nodes, the session status cannot be aggregated
based on this.
This patch strips out the slave node ip to uniquely identify
the session. This will not work when a volume has geo-rep
sessions created for multiple slave volumes - all with the
same name
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1101223
Change-Id: Ie6e12c1b3af4752c5ef14f0c7fe8db579013d19e
Signed-off-by: Sahina Bose <sabose@redhat.com>
Reviewed-on: http://review.gluster.org/7988
Reviewed-by: Shubhendu Tripathi <shtripat@redhat.com>
Reviewed-by: Kanagaraj M <kmayilsa@redhat.com>
-rwxr-xr-x | glusternagios/glustercli.py | 16 | ||||
-rw-r--r-- | tests/test_glustercli.py | 24 |
2 files changed, 26 insertions, 14 deletions
diff --git a/glusternagios/glustercli.py b/glusternagios/glustercli.py index 7aa0bd4..d752173 100755 --- a/glusternagios/glustercli.py +++ b/glusternagios/glustercli.py @@ -506,7 +506,7 @@ def _parseVolumeGeoRepStatus(volumeName, out): nodeline = line.split() node = nodeline[0] brick = nodeline[2] - slave = nodeline[3] + slave = nodeline[3][nodeline[3].find('::') + 2:] if slaves.get(slave) is None: slaves[slave] = {'nodecount': 0, 'faulty': 0, @@ -514,7 +514,8 @@ def _parseVolumeGeoRepStatus(volumeName, out): 'stopped': 0, 'passive': 0, 'detail': '', - 'status': GeoRepStatus.OK + 'status': GeoRepStatus.OK, + 'name': nodeline[3] } slaves[slave]['nodecount'] += 1 if GeoRepStatus.FAULTY in line.upper(): @@ -537,11 +538,17 @@ def _parseVolumeGeoRepStatus(volumeName, out): brick, tempstatus)) volumes = volumeInfo(volumeName) - replicaCount = volumes[volumeName]["brickCount"] + brickCount = volumes[volumeName]["brickCount"] if "REPLICATE" in volumes[volumeName]["volumeType"]: replicaCount = volumes[volumeName]["replicaCount"] + else: + replicaCount = brickCount for slave, count_dict in slaves.iteritems(): + if count_dict['nodecount'] > brickCount: + # There are multiple slave volumes with same name, the output + # may be wrong + slaves[slave]['detail'] += "NOTE:Multiple slave session aggregated" if count_dict['faulty'] > 0: # georep cli status does not give the node name in the same way as # gluster volume info - there's no way to compare and get the @@ -573,7 +580,8 @@ def volumeGeoRepStatus(volumeName, remoteServer=None): 'stopped': COUNT, 'passive':COUNT, 'detail': detailed message, - 'status': GEOREPSTATUS}} + 'status': GEOREPSTATUS, + 'name': SLAVESESSIONNAME}} ]} """ command = _getGlusterVolCmd() + ["geo-replication", volumeName, "status"] diff --git a/tests/test_glustercli.py b/tests/test_glustercli.py index e10a11f..5c71f34 100644 --- a/tests/test_glustercli.py +++ b/tests/test_glustercli.py @@ -1151,7 +1151,7 @@ class GlusterCliTests(TestCaseBase): } } expectedOut = {'test-vol': - {'slaves': {'10.70.43.68::slave-vol': + {'slaves': {'slave-vol': {'faulty': 2, 'nodecount': 2, 'notstarted': 0, @@ -1161,7 +1161,8 @@ class GlusterCliTests(TestCaseBase): '/bricks/b3 - FAULTY;' 'rhs3-2.novalocal:' '/bricks/b3 - FAULTY;', - 'status': gcli.GeoRepStatus.FAULTY} + 'status': gcli.GeoRepStatus.FAULTY, + 'name': '10.70.43.68::slave-vol'} }}} status = gcli.volumeGeoRepStatus("test-vol") print(status) @@ -1186,7 +1187,7 @@ class GlusterCliTests(TestCaseBase): } expectedOut = {'test-vol': {'slaves': - {'10.70.43.68::slave-vol': + {'slave-vol': {'faulty': 1, 'nodecount': 2, 'notstarted': 0, @@ -1196,8 +1197,9 @@ class GlusterCliTests(TestCaseBase): '- PASSIVE;' 'rhs3-2.novalocal:/bricks/b3 ' '- FAULTY;', - 'status': gcli.GeoRepStatus.FAULTY}, - '10.70.43.68::slave-vol2': + 'status': gcli.GeoRepStatus.FAULTY, + 'name': '10.70.43.68::slave-vol'}, + 'slave-vol2': {'faulty': 0, 'nodecount': 2, 'notstarted': 2, @@ -1207,7 +1209,8 @@ class GlusterCliTests(TestCaseBase): '- NOT_STARTED;' 'rhs3-2.novalocal:/bricks/b3 ' '- NOT_STARTED;', - 'status': gcli.GeoRepStatus.NOT_STARTED} + 'status': gcli.GeoRepStatus.NOT_STARTED, + 'name': '10.70.43.68::slave-vol2'} }}} status = gcli.volumeGeoRepStatus("test-vol") print(status) @@ -1217,7 +1220,7 @@ class GlusterCliTests(TestCaseBase): None) expectedOut = {'test-vol': {'slaves': - {'10.70.43.68::slave-vol': + {'slave-vol': {'faulty': 0, 'nodecount': 2, 'notstarted': 1, @@ -1228,7 +1231,8 @@ class GlusterCliTests(TestCaseBase): 'rhs3-2.novalocal:' '/bricks/b3 ' '- NOT_STARTED;', - 'status': gcli.GeoRepStatus.NOT_STARTED + 'status': gcli.GeoRepStatus.NOT_STARTED, + 'name': '10.70.43.68::slave-vol' }}}} status = gcli.volumeGeoRepStatus("test-vol") print(status) @@ -1293,13 +1297,13 @@ class GlusterCliTests(TestCaseBase): "10.70.43.68::slave-vol Passive " "N/A N/A", "rhs3-2.novalocal rep /bricks/b3 " - "10.70.43.68::slave-vol faulty " + "10.70.43.69::slave-vol faulty " "N/A N/A ", "rhs3.novalocal rep /bricks/b3 " "10.70.43.68::slave-vol2 Not Started " "N/A N/A", "rhs3-2.novalocal rep /bricks/b3 " - "10.70.43.68::slave-vol2 Not Started " + "10.70.43.69::slave-vol2 Not Started " "N/A N/A "] def __getGlusterGeoRepStatusResult3(self): |