1
2
3
4
5
6
7
8
9
10
11 __doc__ = """CiscoShowHardware
12
13 Parses the show hardware command and returns CPU type and total memeory
14
15 $Id: CiscoShowHardware.py,v 1.3 2003/12/16 21:50:40 edahl Exp $"""
16
17 __version__ = '$Revision: 1.3 $'[11:-2]
18
19 import re
20
21 from CommandParser import CommandParser
22
24
25 command = 'show hardware'
26
29
30
31 - def parse(self, device, results, log):
32 cpumem = re.compile("\((.+)\) processor .* ([\d\/K]+) bytes").search
33 om = self.newObjectMap()
34 for line in results.split('\n'):
35 m = cpumem(line)
36 if m:
37 om['cpuType'] = m.group(1)
38 mems = m.group(2)
39 if mems.find('/') > -1:
40 mems = mems.split('/')
41 else:
42 mems = (mems,)
43 tmem = 0.0
44 for mem in mems:
45 if mem[-1] == 'K': mem = float(mem[:-1])
46 tmem += mem
47 tmem /= 1024.0
48 om['totalMemory'] = round(tmem)
49 return om
50
51
53 return "Get the CPUType and Total Memory from the show hardware command"
54