diff options
author | Nishanth Thomas <nthomas@redhat.com> | 2014-04-09 10:09:02 +0530 |
---|---|---|
committer | Bala.FA <barumuga@redhat.com> | 2014-04-28 16:20:46 +0530 |
commit | 5628129026c62699025f3ba13b16f442b267aa0f (patch) | |
tree | 8d40e022ed3cddc489771acbaba50ef710d62fe0 /glusternagios | |
parent | fdcfd605a72fb3c13ddade5dfed4275c929afff5 (diff) |
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 <nthomas@redhat.com>
Diffstat (limited to 'glusternagios')
-rw-r--r-- | glusternagios/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
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 |