summaryrefslogtreecommitdiffstats
path: root/plugins/check_gluster_syslog.py
diff options
context:
space:
mode:
authorSahina Bose <sabose@redhat.com>2014-05-02 16:49:16 +0530
committerSahina Bose <sabose@redhat.com>2014-05-05 02:38:50 -0700
commit4d66729bfae280e3765f11b34c34617e499ab25e (patch)
tree93160454593090200c04533357ab7d6a333f7175 /plugins/check_gluster_syslog.py
parentec287fcc84f8bebb52ccaad63f894689fb79862d (diff)
plugins: Plugin to handle server quorum
Plugin to handle log messages related to server quorum Message is parsed for msgid as the msgid is not correctly populated now Fixed pep8 errors in nscautils and added tests Also changed the service name to remove "Status" -it now reads Volume Quota, for instance Change-Id: I339ed16b3806f853ae3555a998974c47157c95ad Signed-off-by: Sahina Bose <sabose@redhat.com> Reviewed-on: http://review.gluster.org/7648 Reviewed-by: Shubhendu Tripathi <shtripat@redhat.com> Reviewed-by: Ramesh N <rnachimu@redhat.com> Reviewed-by: Kanagaraj M <kmayilsa@redhat.com>
Diffstat (limited to 'plugins/check_gluster_syslog.py')
-rwxr-xr-xplugins/check_gluster_syslog.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/plugins/check_gluster_syslog.py b/plugins/check_gluster_syslog.py
index 62464dd..e71647a 100755
--- a/plugins/check_gluster_syslog.py
+++ b/plugins/check_gluster_syslog.py
@@ -22,6 +22,7 @@
import re
import sys
import select
+import logging
import nscautils
from glusternagios import utils
@@ -58,14 +59,44 @@ def processQuotaMsg(msg, alertlevel):
alertMsg)
+def processQuorumMsg(msgid, msg, level):
+ logger = logging.getLogger("processQuorumMsg")
+ pluginstatus = None
+ #if msgid == 106002:
+ if "[MSGID: 106002]" in msg or "[MSGID: 106001]" in msg:
+ # [MSGID: 106002] Server quorum lost for volume dist.
+ # Stopping local bricks.
+ # [MSGID: 106001] Server quorum not met. Rejecting operation.
+ pluginstatus = utils.PluginStatusCode.CRITICAL
+ #elif msgid == 106003:
+ elif "[MSGID: 106003]" in msg:
+ # [MSGID: 106003] Server quorum regained for volume dist.
+ # Starting local bricks.
+ pluginstatus = utils.PluginStatusCode.OK
+
+ if pluginstatus >= 0:
+ serviceName = "Cluster - Quorum"
+ alertMsg = "QUORUM:" + msg[msg.rfind(':') + 1:]
+ ret = nscautils.send_to_nsca_subproc(nscautils.getNagiosClusterName(),
+ serviceName,
+ pluginstatus,
+ alertMsg)
+ logger.debug(" nsca ret code for alertMsg %s - %s" % (alertMsg, ret))
+
+
def processMsg(msg):
'Check if msg is indeed from gluster app'
custom_logvars = msg[:msg.find(' ')]
level = custom_logvars.split('/')[2]
+ msgid = custom_logvars.split('/')[0]
+ # if msgid in ([106001,106002,106003]):
+ # msgid is not populated correctly, so for now use below
+ if "[MSGID: 10600" in msg:
+ return processQuorumMsg(msgid, msg, level)
# For gluster messages, need to check the source of message
logsource = msg[msg.rfind('['):msg.rfind(']')]
if logsource.find('quota') > -1:
- processQuotaMsg(msg, level)
+ return processQuotaMsg(msg, level)
def onReceive(msgs):
@@ -94,6 +125,8 @@ two-way conversations with rsyslog. Do NOT change this!
See also: https://github.com/rsyslog/rsyslog/issues/22
"""
if __name__ == '__main__':
+ logging.basicConfig()
+ logger = logging.getLogger(__name__)
keepRunning = 1
while keepRunning == 1:
while keepRunning and sys.stdin in \