summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xplugins/check_gluster_syslog.py9
-rwxr-xr-xplugins/check_volume_status.py2
-rw-r--r--tests/test_check_volume_status.py11
3 files changed, 13 insertions, 9 deletions
diff --git a/plugins/check_gluster_syslog.py b/plugins/check_gluster_syslog.py
index e71647a..d83e302 100755
--- a/plugins/check_gluster_syslog.py
+++ b/plugins/check_gluster_syslog.py
@@ -37,13 +37,6 @@ def findVolName(pattern):
return pattern[pattern.find('-') + 1:pattern.rfind('-')]
-def getStatusCode(alertlevel):
- if alertlevel == 'ALERT':
- return utils.PluginStatusCode.CRITICAL
- else:
- return utils.PluginStatusCode.WARNING
-
-
def processQuotaMsg(msg, alertlevel):
quotapat = re.compile(r'\b\d*-[a-zA-Z0-9_-]*-quota\b')
matches = quotapat.search(msg)
@@ -55,7 +48,7 @@ def processQuotaMsg(msg, alertlevel):
serviceName = nscautils.vol_service_name(volname, "Quota")
nscautils.send_to_nsca_subproc(nscautils.getNagiosClusterName(),
serviceName,
- getStatusCode(alertlevel),
+ utils.PluginStatusCode.WARNING,
alertMsg)
diff --git a/plugins/check_volume_status.py b/plugins/check_volume_status.py
index 04f3738..ce2b4de 100755
--- a/plugins/check_volume_status.py
+++ b/plugins/check_volume_status.py
@@ -55,7 +55,7 @@ def getVolumeQuotaStatus(args):
return utils.PluginStatusCode.UNKNOWN, out
returnMsg = "QUOTA:"
- if qstatus.get("hard_ex_dirs") is not None:
+ if qstatus.get("hard_ex_dirs"):
hard_limit_ex = ', '.join(qstatus['hard_ex_dirs'])
returnMsg += ("hard limit exceeded on %s; " % hard_limit_ex)
if qstatus.get('soft_ex_dirs'):
diff --git a/tests/test_check_volume_status.py b/tests/test_check_volume_status.py
index ad43587..f916174 100644
--- a/tests/test_check_volume_status.py
+++ b/tests/test_check_volume_status.py
@@ -68,6 +68,11 @@ class TestCheckVolumeStatus(TestCaseBase):
.getVolumeQuotaStatus(args))
assert exitStatusCode == utils.PluginStatusCode.OK
self.assertEqual("QUOTA: OK", exitStatusMsg)
+ mock_volumeQuotaStatus.return_value = _getQuotaStatusSoftLimit()
+ exitStatusCode, exitStatusMsg = (check_volume_status
+ .getVolumeQuotaStatus(args))
+ assert exitStatusCode == utils.PluginStatusCode.WARNING
+ self.assertEqual("QUOTA:soft limit exceeded on dir3", exitStatusMsg)
@mock.patch('glusternagios.glustercli.volumeGeoRepStatus')
def test_checkVolumeGeoRepStatus(self, mock_GeoRepStatus):
@@ -115,6 +120,12 @@ def _getQuotaStatusHardLimit():
'soft_ex_dirs': ['dir3']}
+def _getQuotaStatusSoftLimit():
+ return {'status': 'SOFT_LIMIT_EXCEEDED',
+ 'hard_ex_dirs': [],
+ 'soft_ex_dirs': ['dir3']}
+
+
def _getQuotaStatusOk():
return {'status': 'OK',
'hard_ex_dirs': [],