Package DataCollector :: Package CommandParsers :: Module CiscoDhcpHelperAddress
[hide private]
[frames] | no frames]

Source Code for Module DataCollector.CommandParsers.CiscoDhcpHelperAddress

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13   
14  __doc__ = """CommandParser 
15   
16  CommandParser parses the output of a command to return a datamap 
17   
18  $Id: CiscoDhcpHelperAddress.py,v 1.3 2003/10/02 19:05:28 edahl Exp $""" 
19   
20  __version__ = '$Revision: 1.3 $'[11:-2] 
21   
22  import re 
23   
24  from CommandParser import CommandParser 
25   
26 -class CiscoDhcpHelperAddress(CommandParser):
27 28 command = 'show run | include helper-address' 29
30 - def condition(self, device, log):
31 return "UBR" in device.getPrimaryPath()
32 33
34 - def parse(self, device, results, log):
35 dhcpips = {} 36 findip = re.compile('(\d+\.\d+\.\d+\.\d+)$').search 37 for line in results.split('\n'): 38 m = findip(line) 39 if m: 40 ip = m.group(1) 41 dhcpips[ip] = 1 42 om = self.newObjectMap() 43 om['setDhcpHelpers'] = dhcpips.keys() 44 return om
45 46
47 - def description(self):
48 return "Collect dhcp helper servers that a UBR uses"
49