cpu.py

place in: Products/DataCollector/plugins/zenoss/cmd/linux/
Then restart Zenoss


Code:

###########################################################################
#
# This program is an addendum to Zenoss Core, an open source monitoring 
platform.
# Copyright (C) 2009, Ross R. Duncan
#
# 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 on Zenoss please visit: http://www.zenoss.com/oss/
#
###########################################################################

from Products.DataCollector.plugins.CollectorPlugin import CommandPlugin
from Products.DataCollector.plugins.DataMaps import ObjectMap

MULTIPLIER = {
    'kB' : 1024,
    'MB' : 1024 * 1024,
    'b' : 1
}


class cpu(CommandPlugin):
    """
    maps /proc/cpuinfo to the cpu fields
    """
    #maptype = "FileSystemMap"
    maptype = ""
    command = 'cat /proc/cpuinfo'
    compname = "hw"
    relname = "cpus"
    modname = "Products.ZenModel.CPU"


    def condition(self, device, log):
        return device.os.uname == 'Linux'


    def process(self, device, results, log):
        """parse command output from this device"""
        log.info('processing processor resources %s' % device.id)
        maps = []
        rm = self.relMap()

        config = {}
        for row in results.split('\n'):
            if len(row.strip()) == 0: continue

            values = row.split(':')
            if len(values) < 2: continue
            name, value = values[0:2]

            name = name.strip()
            value = value.strip()

            if name == 'processor': config['socket'] = int(value)
            if name == 'cpu MHz': config['clockspeed'] = 
int(round(float(value)))
            if name == 'cache size': config['cacheSizeL1'] = int(value.split(" 
")[0])
            if name == 'model name':
                config['description'] = value

        om = self.objectMap(config)
        om.setProductKey = config['description']
        om.id = '0'
        rm.append(om)
        maps.append(rm)
        return maps







-------------------- m2f --------------------

Read this topic online here:
http://forums.zenoss.com/viewtopic.php?p=31016#31016

-------------------- m2f --------------------



_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to