diff options
author | Sahina Bose <sabose@redhat.com> | 2014-04-30 21:40:23 +0530 |
---|---|---|
committer | Sahina Bose <sabose@redhat.com> | 2014-05-04 21:55:27 -0700 |
commit | ec287fcc84f8bebb52ccaad63f894689fb79862d (patch) | |
tree | bf61f33a87f73d61c6c9192cd949476c20cad134 /plugins | |
parent | 1bf8bbea994adbe10ff134bd75f569eccbebc42a (diff) |
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 <sabose@redhat.com>
Reviewed-on: http://review.gluster.org/7639
Reviewed-by: Timothy Asir <tim.gluster@gmail.com>
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/check_gluster_syslog.py | 8 | ||||
-rw-r--r-- | plugins/nscautils.py.in | 24 |
2 files changed, 28 insertions, 4 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) |