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

Source Code for Module DataCollector.CommandParsers.CiscoShowHardware

 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__ = """CiscoShowHardware 
15   
16  Parses the show hardware command and returns CPU type and total memeory 
17   
18  $Id: CiscoShowHardware.py,v 1.3 2003/12/16 21:50:40 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 CiscoShowHardware(CommandParser):
29 30 command = 'show hardware' 31
32 - def condition(self, device, log):
33 return device.hw.getManufacturerName() == "Cisco"
34 35
36 - def parse(self, device, results, log):
37 cpumem = re.compile("\((.+)\) processor .* ([\d\/K]+) bytes").search 38 om = self.newObjectMap() 39 for line in results.split('\n'): 40 m = cpumem(line) 41 if m: 42 om['cpuType'] = m.group(1) 43 mems = m.group(2) 44 if mems.find('/') > -1: 45 mems = mems.split('/') 46 else: 47 mems = (mems,) 48 tmem = 0.0 49 for mem in mems: 50 if mem[-1] == 'K': mem = float(mem[:-1]) 51 tmem += mem 52 tmem /= 1024.0 53 om['totalMemory'] = round(tmem) 54 return om
55 56
57 - def description(self):
58 return "Get the CPUType and Total Memory from the show hardware command"
59