Ticket #2304 (new enhancement)

Opened 14 months ago

Last modified 4 weeks ago

CiscoMap.py (proposed change)

Reported by: zenoss Owned by: cluther
Priority: 3 - Medium Milestone: Blue Crab
Component: ZenModel Version: 2.1.0
Keywords: Cc: pmorton@…, apaneiro@…
Community Patch Attached: Deployed @ Customer:
Installer: Any/All Maintenance Target:
Specific ZenPack: Maintenance Status:
Documentation Note?: Not required Regression:

Description

Following Paul's (pmorton) initial post at
http://community.zenoss.com/forums/viewtopic.php?p=12774#12774

...

Cisco has several OID's to get the s/n and the total mem from depending on the type of equipment.

On the other hand, twistedsnmp seems not to return any value at all when one of the OID's in the GetMap is not part of the tree.

To overcome that, I've used GetTableMap and came up with the following:

###########################################################################
#
# This program is part of Zenoss Core, an open source monitoring platform.
# Copyright (C) 2007, Zenoss Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# For complete information please visit: http://www.zenoss.com/oss/
#
###########################################################################

__doc__="""CiscoMap

CiscoMap maps cisco serialnumber information

$Id: CiscoMap.py,v 1.3 2003/01/15 21:51:54 edahl Exp $"""

__version__ = '$Revision: 1.3 $'[11:-2]

import re

from CollectorPlugin import SnmpPlugin, GetTableMap
from DataMaps import ObjectMap

class CiscoMap(SnmpPlugin):

    maptype = "CiscoDeviceMap"

    # Cisco chassis ID OID's
    # "1.3.6.1.4.1.9.3.6.3.0" chassisId
    # "1.3.6.1.2.1.47.1.1.1.1.11.1" entPhysicalSerialNumber
    # "1.3.6.1.4.1.9.5.1.2.19.0" chassisSerialNumberString
    #
    # Memory OID's
    # ".1.3.6.1.4.1.9.3.6.6.0" processorRam
    # ".1.3.6.1.4.1.9.9.48.1.1.1.6.1" mem5minFree
    # ".1.3.6.1.4.1.9.9.48.1.1.1.5.1" mem5minUsed

    snmpGetTableMaps = (
        GetTableMap('chassisId', '.1.3.6.1.4.1.9.3.6', {'.3' : 'setHWSerialNumber'}),
        GetTableMap('entPhysicalSerialNumber', '.1.3.6.1.2.1.47.1.1.1.1', {'.11' : 'setHWSerialNumber'}),
        GetTableMap('chassisSerialNumberString', '.1.3.6.1.4.1.9.5.1.2', {'.19' : 'setHWSerialNumber'}),
        GetTableMap('processorRam', '.1.3.6.1.4.1.9.3.6', {'.6' : 'totalMemory'}),
        GetTableMap('mem5minFree', '.1.3.6.1.4.1.9.9.48.1.1.1', {'.6' : 'free'}),
        GetTableMap('mem5minUsed', '.1.3.6.1.4.1.9.9.48.1.1.1', {'.5' : 'used'})
        )

    def condition(self, device, log):
        """does device meet the proper conditions for this collector to run"""
        return device.snmpOid.startswith('.1.3.6.1.4.1.9')


    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        maps = []

        chassisId = tabledata.get("chassisId")
        entPhysicalSerialNumber = tabledata.get("entPhysicalSerialNumber")
        chassisSerialNumberString = tabledata.get("chassisSerialNumberString")
        if chassisId:
            log.debug("setting Serial Number from chassisId: %s", chassisId['0']['setHWSerialNumber'])
            maps.append(ObjectMap(chassisId['0']))
        elif entPhysicalSerialNumber:
            log.debug("setting Serial Number from entPhysicalSerialNumber.1: %s", entPhysicalSerialNumber['1']['setHWSerialNumber'])
            maps.append(ObjectMap(entPhysicalSerialNumber['1']))
        elif chassisSerialNumberString:
            log.debug("setting Serial Number from chassisSerialNumberString: %s", chassisSerialNumberString['0']['setHWSerialNumber'])
            maps.append(ObjectMap(chassisSerialNumberString['0']))

        processorRam = tabledata.get("processorRam")
        mem5minFree = tabledata.get("mem5minFree")
        mem5minUsed = tabledata.get("mem5minUsed")
        if processorRam:
            log.debug("setting totalMemory from processorRam: %s", processorRam['0']['totalMemory'])
            maps.append(ObjectMap(processorRam['0'], compname="hw"))
        elif mem5minFree and mem5minUsed:
            totalMemory = mem5minFree['1']['free'] + mem5minUsed['1']['used']
            log.debug("setting totalMemory from mem5minFree + mem5minUsed: %s",totalMemory)
            maps.append(ObjectMap({"totalMemory": totalMemory}, compname="hw"))

        return maps

Change History

Changed 14 months ago by zenoss

  • cc apaneiro@… added

Changed 14 months ago by edahl

  • owner changed from edahl to cluther

chet can you work this one though to inclusion please

Changed 3 months ago by bbibeault

  • documentation set to Not required
  • reviewed set to 0

Changed 4 weeks ago by bbibeault

  • installer set to Any/All
  • milestone set to Blue Crab
Note: See TracTickets for help on using tickets.