os.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.DataMaps import ObjectMap
import re

from CollectorPlugin import CommandPlugin

class os(CommandPlugin):
    """
    retrieves os using uname -r
    """
    command = 'uname -a'

    descr = re.compile( "^Linux (\S+) (\S+) .*" ).search

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


    def process(self, device, results, log):
        log.info('Collecting OS name for device %s' % device.id)

        value = results.strip()
        if len(value) != 0:
            mos = self.descr( value )
            if mos:
                hostname, os_version = mos.groups()
                os = self.objectMap()
                os.setOSProductKey = os_version
                os.snmpSysName = hostname
        return os







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

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

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



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

Reply via email to