1
2
3
4
5
6
7
8
9
10
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
29
30 command = 'show hardware'
31
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
58 return "Get the CPUType and Total Memory from the show hardware command"
59