diff --git a/ZenPacks.community.Gentoo/COPYRIGHT.txt b/ZenPacks.community.Gentoo/COPYRIGHT.txt new file mode 100644 index 0000000..ae6a568 --- /dev/null +++ b/ZenPacks.community.Gentoo/COPYRIGHT.txt @@ -0,0 +1,16 @@ +All files in this directory and below are: + +Copyright (c) 2009 Zenoss, Inc. All rights reserved. + +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. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/ZenPacks.community.Gentoo/MANIFEST.in b/ZenPacks.community.Gentoo/MANIFEST.in new file mode 100644 index 0000000..e91e1bf --- /dev/null +++ b/ZenPacks.community.Gentoo/MANIFEST.in @@ -0,0 +1 @@ +graft ZenPacks diff --git a/ZenPacks.community.Gentoo/ZenPacks/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/__init__.py new file mode 100644 index 0000000..de40ea7 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/__init__.py new file mode 100644 index 0000000..e076bec --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/__init__.py @@ -0,0 +1,62 @@ + +import Globals +import os.path +import logging +from Products.ZenModel.ZenPack import ZenPackBase + +log = logging.getLogger('zen.GentooMonitor') + +skinsDir = os.path.join(os.path.dirname(__file__), 'skins') +from Products.CMFCore.DirectoryView import registerDirectory +if os.path.isdir(skinsDir): + registerDirectory(skinsDir, globals()) + +def findGentoo(dmd): + return dmd.findChild('Devices/Server/SSH/Linux/Gentoo') + +class ZenPack(ZenPackBase): + + def install(self, app): + """ + Set the collector plugins for Server/SSH/Linux/Gentoo. + """ + try: + gentoo = findGentoo(app.dmd) + except Exception, e: + import traceback + log.debug(traceback.format_exc()) + raise Exception('Device class Server/SSH/Linux/Gentoo does not exist. ' + 'Cannot install Gentoo ZenPack.') + ZenPackBase.install(self, app) + + plugins=[] + for plugin in gentoo.zCollectorPlugins: + if plugin != "zenoss.cmd.uname_a": + plugins.append(plugin) + else: + plugins.append('zenoss.cmd.linux.gentoo_uname_a') + + plugins.append('zenoss.cmd.linux.eix') + + gentoo.setZenProperty( 'zCollectorPlugins', plugins ) + + gentoo.register_devtype('Gentoo Server', 'SSH') + + def remove(self, app, leaveObjects=False): + """ + Remove the collector plugins. + """ + ZenPackBase.remove(self, app, leaveObjects) + gentoo = findGentoo(app.dmd) + if not leaveObjects: + newlist=[] + for plugin in gentoo.zCollectorPlugins: + if plugin == "zenoss.cmd.linux.eix": + pass + elif plugin == "zenoss.cmd.linux.gentoo_uname_a": + newlist.append("zenoss.cmd.uname_a") + else: + newlist.append(plugin) + + + gentoo.zCollectorPlugins = newlist diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/datasources/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/datasources/__init__.py new file mode 100644 index 0000000..651585a --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/datasources/__init__.py @@ -0,0 +1,2 @@ +# __init__.py + diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/lib/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/lib/__init__.py new file mode 100644 index 0000000..143f486 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/lib/__init__.py @@ -0,0 +1 @@ +# __init__.py diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/migrate/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/migrate/__init__.py new file mode 100644 index 0000000..143f486 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/migrate/__init__.py @@ -0,0 +1 @@ +# __init__.py diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/eix.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/eix.py new file mode 100644 index 0000000..e7b1952 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/eix.py @@ -0,0 +1,36 @@ +""" +Modeling plugin that parses the contents of eix to gather +information about the software installed on a gentoo linux box. +""" +import re +from Products.DataCollector.plugins.CollectorPlugin import CommandPlugin +from Products.DataCollector.plugins.DataMaps import MultiArgs + +class eix(CommandPlugin): + """ + eix - get software list on gentoo machines + """ + + command = "/usr/bin/eix -c -I -n" + compname = "os" + relname = "software" + modname = "Products.ZenModel.Software" + + #[I] xfce-extra/xfce4-mixer (4.4.3@03/31/09): Volume control application using gstreamer + linePattern = re.compile(r"\[I\] (.*) \((.*)@([0-9]+)/([0-9]+)/([0-9]+)\): (.*)") + + def process(self, device, results, log): + log.info('Collecting Software Installed information for device %s' % device.id) + rm = self.relMap() + + for result in results.split('\n'): + m = self.linePattern.match(result) + if m: + om = self.objectMap() + om.setProductKey = MultiArgs("%s-%s" % (m.group(1),m.group(2)),"Gentoo") + om.id = self.prepId(om.setProductKey) + om.setInstallDate = "%s/%s/%s" % (str(2000+int(m.group(5))),m.group(3),m.group(4)) + om.setDescription = m.group(6) + rm.append(om) + return rm + #[I] xfce-extra/xfce4-mixer (4.4.3@03/31/09): Volume control application using gstreamer diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/gentoo_uname_a.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/gentoo_uname_a.py new file mode 100644 index 0000000..d329cd0 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/gentoo_uname_a.py @@ -0,0 +1,39 @@ +########################################################################### +# +# This program is part of Zenoss Core, an open source monitoring platform. +# Copyright (C) 2009, 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__ = """uname -a +Determine snmpSysName and setOSProductKey from the result of the uname -a +command. +""" + +from Products.DataCollector.plugins.CollectorPlugin import CommandPlugin +from Products.DataCollector.plugins.DataMaps import MultiArgs + +class gentoo_uname_a(CommandPlugin): + + maptype = "DeviceMap" + compname = "" + command = 'uname -a' + + def process(self, device, results, log): + """Collect command-line information from this device""" + log.info("Processing the uname -a info for device %s" % device.id) + om = self.objectMap() + om.snmpDescr = results.strip() + om.setHWProductKey, om.snmpSysName, kernelRelease = results.split()[:3] + om.setOSProductKey = " ".join([om.setHWProductKey, kernelRelease]) + om.setOSProductKey = MultiArgs(om.setOSProductKey,"Gentoo") + log.debug("snmpSysName=%s, setOSProductKey=%s" % ( + om.snmpSysName, om.setOSProductKey)) + return om + diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/objects/objects.xml b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/objects/objects.xml new file mode 100644 index 0000000..5908b64 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/objects/objects.xml @@ -0,0 +1,3 @@ + + + diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/parsers/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/parsers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/parsers/linux/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/parsers/linux/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/skins/ZenPacks.community.Gentoo/placeholder.txt b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/skins/ZenPacks.community.Gentoo/placeholder.txt new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/__init__.py new file mode 100644 index 0000000..f8927bd --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/__init__.py @@ -0,0 +1,12 @@ +# ########################################################################## +# +# This program is part of Zenoss Core, an open source monitoring platform. +# Copyright (C) 2008, 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/ +# +# ########################################################################## diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/eix b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/eix new file mode 100644 index 0000000..3a961d3 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/eix @@ -0,0 +1,10 @@ +/usr/bin/eix -c -I -n +[I] app-admin/sudo (1.7.0@03/30/09): Allows users or groups to run commands as other users +[I] app-admin/syslog-ng (2.1.4@06/06/09): syslog replacement with advanced filtering features +[I] app-arch/bzip2 (1.0.5-r1@03/31/09): A high-quality data compressor used extensively by Gentoo Linux +[I] app-arch/cpio (2.9-r2@03/31/09): A file archival tool which can also read and write tar files +[I] app-arch/gzip (1.3.12-r1@03/31/09): Standard GNU compressor +[I] app-arch/lzma-utils (4.32.7@03/30/09): LZMA interface made easy +[I] app-arch/tar (1.20@03/31/09): Use this to make tarballs :) +[I] app-editors/mousepad (0.2.14@03/30/09): Text editor +Found 9 matches diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/eix.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/eix.py new file mode 100644 index 0000000..57fec19 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/eix.py @@ -0,0 +1,9 @@ +{ "eix": + { + '(_app-admin_sudo-1.7.0_, _Gentoo_)':dict( + setProductKey=('app-admin/sudo-1.7.0', 'Gentoo'), + setDescription="Allows users or groups to run commands as other users", + setInstallDate="2009/03/30", + ), + } +} diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/uname b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/uname new file mode 100644 index 0000000..1c5902b --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/uname @@ -0,0 +1,2 @@ +uname -a +Linux gentoovmware 2.6.29-gentoo-r5 #1 SMP Sun Jun 7 01:18:09 EDT 2009 i686 Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz GenuineIntel GNU/Linux diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/uname.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/uname.py new file mode 100644 index 0000000..e4ea2f6 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/uname.py @@ -0,0 +1,9 @@ +{"gentoo_uname_a": + dict( + snmpDescr = 'Linux gentoovmware 2.6.29-gentoo-r5 #1 SMP Sun Jun 7 01:18:09 EDT 2009 i686 Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz GenuineIntel GNU/Linux', + setHWProductKey = 'Linux', + snmpSysName = 'gentoovmware', + setOSProductKey = ('Linux 2.6.29-gentoo-r5', 'Gentoo') + ), +} + diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/testPlugins.py b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/testPlugins.py new file mode 100644 index 0000000..a9b1d47 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/testPlugins.py @@ -0,0 +1,28 @@ +import os + +from Products.DataCollector.tests.BasePluginsTestCase \ + import BasePluginsTestCase + +from ZenPacks.community.Gentoo.modeler.plugins.zenoss.cmd.linux.eix \ + import eix + +from ZenPacks.community.Gentoo.modeler.plugins.zenoss.cmd.linux.gentoo_uname_a \ + import gentoo_uname_a + +class GentooLinuxPluginsTestCase(BasePluginsTestCase): + + def runTest(self): + """ + Test all of the plugins that have test data files in the data + directory. + """ + Plugins = [gentoo_uname_a,eix] + datadir = "%s/plugindata/linux" % (os.path.dirname(__file__)) + self._testDataFiles(datadir, Plugins) + +def test_suite(): + from unittest import TestSuite, makeSuite + suite = TestSuite() + suite.addTest(makeSuite(GentooLinuxPluginsTestCase)) + return suite + diff --git a/ZenPacks.community.Gentoo/ZenPacks/community/__init__.py b/ZenPacks.community.Gentoo/ZenPacks/community/__init__.py new file mode 100644 index 0000000..de40ea7 --- /dev/null +++ b/ZenPacks.community.Gentoo/ZenPacks/community/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/ZenPacks.community.Gentoo/setup.py b/ZenPacks.community.Gentoo/setup.py new file mode 100644 index 0000000..b080016 --- /dev/null +++ b/ZenPacks.community.Gentoo/setup.py @@ -0,0 +1,69 @@ +################################ +# These variables are overwritten by Zenoss when the ZenPack is exported +# or saved. Do not modify them directly here. +# NB: PACKAGES is deprecated +NAME = "ZenPacks.community.Gentoo" +VERSION = "1.0" +AUTHOR = "Eric Edgar" +LICENSE = "" +NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.community'] +PACKAGES = ['ZenPacks', 'ZenPacks.community', 'ZenPacks.community.Gentoo'] +INSTALL_REQUIRES = ['ZenPacks.community.LinuxMonitorAddOn>=1.0'] +COMPAT_ZENOSS_VERS = ">=2.4" +PREV_ZENPACK_NAME = "" +# STOP_REPLACEMENTS +################################ +# Zenoss will not overwrite any changes you make below here. + +from setuptools import setup, find_packages + +setup( + # This ZenPack metadata should usually be edited with the Zenoss + # ZenPack edit page. Whenever the edit page is submitted it will + # overwrite the values below (the ones it knows about) with new values. + name = NAME, + version = VERSION, + author = AUTHOR, + license = LICENSE, + + # This is the version spec which indicates what versions of Zenoss + # this ZenPack is compatible with + compatZenossVers = COMPAT_ZENOSS_VERS, + + # previousZenPackName is a facility for telling Zenoss that the name + # of this ZenPack has changed. If no ZenPack with the current name is + # installed then a zenpack of this name if installed will be upgraded. + prevZenPackName = PREV_ZENPACK_NAME, + + # Indicate to setuptools which namespace packages the zenpack + # participates in + namespace_packages = NAMESPACE_PACKAGES, + + # Tell setuptools what packages this zenpack provides. + packages = find_packages(), + + # Tell setuptools to figure out for itself which files to include + # in the binary egg when it is built. + include_package_data = True, + + # The MANIFEST.in file is the recommended way of including additional files + # in your ZenPack. package_data is another. + #package_data = {} + + # Indicate dependencies on other python modules or ZenPacks. This line + # is modified by zenoss when the ZenPack edit page is submitted. Zenoss + # tries to put add/delete the names it manages at the beginning of this + # list, so any manual additions should be added to the end. Things will + # go poorly if this line is broken into multiple lines or modified to + # dramatically. + install_requires = INSTALL_REQUIRES, + + # Every ZenPack egg must define exactly one zenoss.zenpacks entry point + # of this form. + entry_points = { + 'zenoss.zenpacks': '%s = %s' % (NAME, NAME), + }, + + # All ZenPack eggs must be installed in unzipped form. + zip_safe = False, +)