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 CommandParser import CommandParser
25
27
28 command = 'show hardware'
29
32
33
34 - def parse(self, device, results, log):
35 cpumem = re.compile("\((.+)\) processor .* ([\d\/K]+) bytes").search
36 om = self.newObjectMap()
37 for line in results.split('\n'):
38 m = cpumem(line)
39 if m:
40 om['cpuType'] = m.group(1)
41 mems = m.group(2)
42 if mems.find('/') > -1:
43 mems = mems.split('/')
44 else:
45 mems = (mems,)
46 tmem = 0.0
47 for mem in mems:
48 if mem[-1] == 'K': mem = float(mem[:-1])
49 tmem += mem
50 tmem /= 1024.0
51 om['totalMemory'] = round(tmem)
52 return om
53
54
56 return "Get the CPUType and Total Memory from the show hardware command"
57