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 Products.ZenModel.IpAddress import findIpAddress 
25   
26  from CommandParser import CommandParser 
27   
28 -class CiscoDhcpHelperAddress(CommandParser):
29 30 command = 'show run | include helper-address' 31
32 - def condition(self, device, log):
33 return "UBR" in device.getPrimaryPath()
34 35
36 - def parse(self, device, results, log):
37 dhcpips = {} 38 findip = re.compile('(\d+\.\d+\.\d+\.\d+)$').search 39 for line in results.split('\n'): 40 m = findip(line) 41 if m: 42 ip = m.group(1) 43 dhcpips[ip] = 1 44 om = self.newObjectMap() 45 om['setDhcpHelpers'] = dhcpips.keys() 46 return om
47 48
49 - def description(self):
50 return "Collect dhcp helper servers that a UBR uses"
51