summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xplugins/check_gluster_syslog.py8
-rw-r--r--plugins/nscautils.py.in24
-rw-r--r--tests/test_check_gluster_syslog.py2
3 files changed, 29 insertions, 5 deletions
diff --git a/plugins/check_gluster_syslog.py b/plugins/check_gluster_syslog.py
index 277f32f..62464dd 100755
--- a/plugins/check_gluster_syslog.py
+++ b/plugins/check_gluster_syslog.py
@@ -52,10 +52,10 @@ def processQuotaMsg(msg, alertlevel):
alertMsg = "QUOTA: " + msg[msg.rfind(matches.group()) +
len(matches.group()) + 1:]
serviceName = nscautils.vol_service_name(volname, "Quota")
- nscautils.send_to_nsca(nscautils.getNagiosClusterName(),
- serviceName,
- getStatusCode(alertlevel),
- alertMsg)
+ nscautils.send_to_nsca_subproc(nscautils.getNagiosClusterName(),
+ serviceName,
+ getStatusCode(alertlevel),
+ alertMsg)
def processMsg(msg):
diff --git a/plugins/nscautils.py.in b/plugins/nscautils.py.in
index 51df927..cf5f58b 100644
--- a/plugins/nscautils.py.in
+++ b/plugins/nscautils.py.in
@@ -17,6 +17,7 @@
#
import ConfigParser
+import subprocess
from glusternagios import utils
@@ -61,5 +62,28 @@ def send_to_nsca(hostName, serviceName, exitStatus, resultString):
return ret
+def send_to_nsca_subproc(hostName, serviceName, exitStatus, resultString):
+ cmddata = '%s\t%s\t%s\t%s\n' % (hostName,
+ serviceName,
+ exitStatus,
+ resultString)
+ nagiosIP = getNagiosServerIP()
+ p = subprocess.Popen(
+ args=(
+ __NSCA_CMD_PATH.cmd,
+ '-c', __NSCA_CONF_PATH,
+ '-H', nagiosIP,
+ ),
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ close_fds=True,
+ )
+
+ stdout, stderr = p.communicate(input=cmddata)
+ rc = p.returncode
+ return rc
+
+
def vol_service_name(volName, statusType=None):
return "Volume Status %s - %s" % (statusType, volName)
diff --git a/tests/test_check_gluster_syslog.py b/tests/test_check_gluster_syslog.py
index a6dce45..c8c5d6a 100644
--- a/tests/test_check_gluster_syslog.py
+++ b/tests/test_check_gluster_syslog.py
@@ -29,7 +29,7 @@ class TestGlusterSyslog(TestCaseBase):
# Method to test volume perf data when no matching host method
@mock.patch('plugins.nscautils.getNagiosClusterName')
- @mock.patch('plugins.nscautils.send_to_nsca')
+ @mock.patch('plugins.nscautils.send_to_nsca_subproc')
def test_checkProcessMsg(self, mock_send_to_nsca,
mock_getNagiosClusterName):
mock_getNagiosClusterName.return_value = "test-cluster"