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

# Source Code for Module Products.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 CommandParser import CommandParser
    25
    26 -class CiscoShowHardware(CommandParser):
    27
    28      command = 'show hardware'
    29
    30 -    def condition(self, device, log):
    31          return device.hw.getManufacturerName() == "Cisco"
    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
    55 -    def description(self):
    56          return "Get the CPUType and Total Memory from the show hardware command"
    57