From ec287fcc84f8bebb52ccaad63f894689fb79862d Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Wed, 30 Apr 2014 21:40:23 +0530 Subject: plugins: Changed nsca method for syslog monitoring Changed the syslog monitoring plugin to use subprocess to send the nsca command There was an issue with using the utils method when being called from rsyslog service Change-Id: Ia4dea2b0f942ce815f123ece1fba8fd1f18fc6be Signed-off-by: Sahina Bose Reviewed-on: http://review.gluster.org/7639 Reviewed-by: Timothy Asir --- plugins/nscautils.py.in | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'plugins/nscautils.py.in') 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) -- cgit