This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://zenpacks.zenoss.org/svn/zenpacks@245 db08cffe-75b9-45d1-af1a-46ad9ef135f6
- Loading branch information
Matt Ray
committed
Jun 15, 2009
1 parent
925f296
commit 849aec7
Showing
29 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
graft ZenPacks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
62 changes: 62 additions & 0 deletions
62
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
2 changes: 2 additions & 0 deletions
2
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/datasources/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# __init__.py | ||
|
1 change: 1 addition & 0 deletions
1
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/lib/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# __init__.py |
1 change: 1 addition & 0 deletions
1
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/migrate/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# __init__.py |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
36 changes: 36 additions & 0 deletions
36
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/eix.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
39 changes: 39 additions & 0 deletions
39
...unity.Gentoo/ZenPacks/community/Gentoo/modeler/plugins/zenoss/cmd/linux/gentoo_uname_a.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
3 changes: 3 additions & 0 deletions
3
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/objects/objects.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0"?> | ||
<objects> | ||
</objects> |
Empty file.
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions
12
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ | ||
# | ||
# ########################################################################## |
Empty file.
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions
10
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/eix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
9 changes: 9 additions & 0 deletions
9
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/eix.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
), | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/uname
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
9 changes: 9 additions & 0 deletions
9
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/plugindata/linux/server1/uname.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
), | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
ZenPacks.community.Gentoo/ZenPacks/community/Gentoo/tests/testPlugins.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) |