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

# Source Code for Module Products.DataCollector.CommandParsers.CiscoShowHardware

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     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
    23 -class CiscoShowHardware(CommandParser):
    24
    25      command = 'show hardware'
    26
    27 -    def condition(self, device, log):
    28          return device.hw.getManufacturerName() == "Cisco"
    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
    52 -    def description(self):
    53          return "Get the CPUType and Total Memory from the show hardware command"
    54