From 5628129026c62699025f3ba13b16f442b267aa0f Mon Sep 17 00:00:00 2001 From: Nishanth Thomas Date: Wed, 9 Apr 2014 10:09:02 +0530 Subject: SNMP Notifications:utility funtion to read SNMP managers Also added the the commands for sending SNMP traps Addressed the review comments Change-Id: I5612aaa241eb05d606a98d604be4f70486a141b0 Signed-off-by: Nishanth Thomas --- glusternagios/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/glusternagios/utils.py b/glusternagios/utils.py index d329877..414c00f 100644 --- a/glusternagios/utils.py +++ b/glusternagios/utils.py @@ -107,6 +107,7 @@ sudoCmdPath = CommandPath("sudo", ) hostnameCmdPath = CommandPath("hostname", "/bin/hostname", ) glusterCmdPath = CommandPath("gluster", "/usr/sbin/gluster") +trapCmdPath = CommandPath("snmptrap", "/usr/bin/snmptrap") # Buffsize is 1K because I tested it on some use cases and 1K was fastest. If # you find this number to be a bottleneck in any way you are welcome to change # it @@ -512,3 +513,16 @@ def parseXml(xmldoc, searchStr): root = ET.fromstring(xmldoc) statusStr = root.findall(searchStr) return statusStr + + +def getsnmpmanagers(path): + listofmanagers = [] + with open(path, "r+") as mangerconfig: + for line in mangerconfig.readlines(): + if line.startswith("#"): + continue + config = line.split() + if len(config) == 2: + listofmanagers.\ + append({'host': config[0], 'community': config[1]}) + return listofmanagers -- cgit