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@287 db08cffe-75b9-45d1-af1a-46ad9ef135f6
- Loading branch information
Matt Ray
committed
Jul 20, 2009
1 parent
725c5bd
commit 3356567
Showing
24 changed files
with
290 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__) |
60 changes: 60 additions & 0 deletions
60
ZenPacks.community.Fedora/ZenPacks/community/Fedora/__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,60 @@ | ||
import Globals | ||
import os.path | ||
import logging | ||
from Products.ZenModel.ZenPack import ZenPackBase | ||
|
||
log = logging.getLogger('zen.FedoraMonitor') | ||
|
||
skinsDir = os.path.join(os.path.dirname(__file__), 'skins') | ||
from Products.CMFCore.DirectoryView import registerDirectory | ||
if os.path.isdir(skinsDir): | ||
registerDirectory(skinsDir, globals()) | ||
|
||
def findFedora(dmd): | ||
return dmd.findChild('Devices/Server/SSH/Linux/Fedora') | ||
|
||
class ZenPack(ZenPackBase): | ||
|
||
def install(self, app): | ||
""" | ||
Set the collector plugins for Server/SSH/Linux/Fedora | ||
""" | ||
try: | ||
fedora = findFedora(app.dmd) | ||
except Exception, e: | ||
import traceback | ||
log.debug(traceback.format_exc()) | ||
raise Exception('Device class Server/SSH/Linux/Fedora does not exist. ' | ||
'Cannot install Fedora ZenPack.') | ||
ZenPackBase.install(self, app) | ||
|
||
plugins=[] | ||
for plugin in fedora.zCollectorPlugins: | ||
if plugin != "zenoss.cmd.uname_a": | ||
plugins.append(plugin) | ||
else: | ||
plugins.append('zenoss.cmd.linux.fedora_uname_a') | ||
|
||
plugins.append('zenoss.cmd.linux.fedora_rpm') | ||
|
||
fedora.setZenProperty( 'zCollectorPlugins', plugins ) | ||
|
||
fedora.register_devtype('Fedora Server', 'SSH') | ||
|
||
def remove(self, app, leaveObjects=False): | ||
""" | ||
Remove the collector plugins. | ||
""" | ||
ZenPackBase.remove(self, app, leaveObjects) | ||
fedora = findFedora(app.dmd) | ||
if not leaveObjects: | ||
newlist=[] | ||
for plugin in fedora.zCollectorPlugins: | ||
if plugin == "zenoss.cmd.linux.eix": | ||
pass | ||
elif plugin == "zenoss.cmd.linux.fedora_uname_a": | ||
newlist.append("zenoss.cmd.uname_a") | ||
else: | ||
newlist.append(plugin) | ||
|
||
fedora.zCollectorPlugins = newlist |
2 changes: 2 additions & 0 deletions
2
ZenPacks.community.Fedora/ZenPacks/community/Fedora/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.Fedora/ZenPacks/community/Fedora/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.Fedora/ZenPacks/community/Fedora/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.
33 changes: 33 additions & 0 deletions
33
...community.Fedora/ZenPacks/community/Fedora/modeler/plugins/zenoss/cmd/linux/fedora_rpm.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,33 @@ | ||
""" | ||
Modeling plugin that parses the contents of eix to gather | ||
information about the software installed on a gentoo linux box. | ||
""" | ||
import re | ||
import time | ||
from Products.DataCollector.plugins.CollectorPlugin import CommandPlugin | ||
from Products.DataCollector.plugins.DataMaps import MultiArgs | ||
|
||
class fedora_rpm(CommandPlugin): | ||
""" | ||
rpm - get software list | ||
""" | ||
|
||
command = r'rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}|%{INSTALLTIME}|%{SUMMARY}\n" && echo __COMMAND__ && cat /etc/fedora-release |head -1' | ||
compname = "os" | ||
relname = "software" | ||
modname = "Products.ZenModel.Software" | ||
|
||
|
||
def process(self, device, results, log): | ||
log.info('Collecting Software Installed information for device %s' % device.id) | ||
rm = self.relMap() | ||
rpm, fedoratype = results.split('\n__COMMAND__\n') | ||
fedoratype=fedoratype.strip('\n') | ||
for result in rpm.split('\n'): | ||
om = self.objectMap() | ||
om.setProductKey, om.setInstallDate, om.setDescription = result.split('|')[:3] | ||
om.setInstallDate= "%s/%s/%s" % time.gmtime(float(om.setInstallDate))[:3] | ||
om.setProductKey = MultiArgs(str(om.setProductKey), str(fedoratype)) | ||
om.id = self.prepId(om.setProductKey) | ||
rm.append(om) | ||
return rm |
40 changes: 40 additions & 0 deletions
40
...unity.Fedora/ZenPacks/community/Fedora/modeler/plugins/zenoss/cmd/linux/fedora_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,40 @@ | ||
########################################################################### | ||
# | ||
# 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 fedora_uname_a(CommandPlugin): | ||
|
||
maptype = "DeviceMap" | ||
compname = "" | ||
command = 'uname -a && echo __COMMAND__ && cat /etc/fedora-release |head -1' | ||
|
||
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) | ||
uname, fedoratype = results.split('__COMMAND__\n') | ||
fedoratype=fedoratype.strip('\n') | ||
om = self.objectMap() | ||
om.snmpDescr = uname.strip() | ||
om.setHWProductKey, om.snmpSysName, kernelRelease = uname.split()[:3] | ||
om.setOSProductKey = " ".join([om.setHWProductKey, kernelRelease]) | ||
om.setOSProductKey = MultiArgs(om.setOSProductKey,fedoratype) | ||
log.debug("snmpSysName=%s, setOSProductKey=%s" % ( | ||
om.snmpSysName, om.setOSProductKey)) | ||
return om |
Empty file.
12 changes: 12 additions & 0 deletions
12
ZenPacks.community.Fedora/ZenPacks/community/Fedora/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.
4 changes: 4 additions & 0 deletions
4
...acks.community.Fedora/ZenPacks/community/Fedora/tests/plugindata/linux/server1/fedora_rpm
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,4 @@ | ||
rpm -qa --qf "%{NAME}-%{VERSION}-%{RELEASE}|%{INSTALLTIME}|%{SUMMARY}\n" && echo __COMMAND__ && cat /etc/fedora-release |head -1 | ||
perl-5.10.0-62.17.1|1244573329|The Perl interpreter | ||
__COMMAND__ | ||
Fedora release 11 (Leonidas) |
9 changes: 9 additions & 0 deletions
9
...s.community.Fedora/ZenPacks/community/Fedora/tests/plugindata/linux/server1/fedora_rpm.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 @@ | ||
{ "fedora_rpm": | ||
{ | ||
'(_perl-5.10.0-62.17.1_, _Fedora release 11 (Leonidas)_)':dict( | ||
setProductKey=('perl-5.10.0-62.17.1', 'Fedora release 11 (Leonidas)'), | ||
setDescription="The Perl interpreter", | ||
setInstallDate="2009/6/9", | ||
), | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
ZenPacks.community.Fedora/ZenPacks/community/Fedora/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,4 @@ | ||
uname -a && echo __COMMAND__ && cat /etc/fedora-release |head -1 | ||
Linux kubuntu 2.6.29.5-191.fc11.x86_64 #1 SMP Tue Jun 16 23:23:21 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux | ||
__COMMAND__ | ||
Fedora release 11 (Leonidas) |
8 changes: 8 additions & 0 deletions
8
ZenPacks.community.Fedora/ZenPacks/community/Fedora/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,8 @@ | ||
{"fedora_uname_a": | ||
dict( | ||
snmpDescr = 'Linux kubuntu 2.6.29.5-191.fc11.x86_64 #1 SMP Tue Jun 16 23:23:21 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux', | ||
setHWProductKey = 'Linux', | ||
snmpSysName = 'kubuntu', | ||
setOSProductKey = ('Linux 2.6.29.5-191.fc11.x86_64', 'Fedora release 11 (Leonidas)') | ||
), | ||
} |
28 changes: 28 additions & 0 deletions
28
ZenPacks.community.Fedora/ZenPacks/community/Fedora/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.Fedora.modeler.plugins.zenoss.cmd.linux.fedora_rpm \ | ||
import fedora_rpm | ||
|
||
from ZenPacks.community.Fedora.modeler.plugins.zenoss.cmd.linux.fedora_uname_a \ | ||
import fedora_uname_a | ||
|
||
class FedoraLinuxPluginsTestCase(BasePluginsTestCase): | ||
|
||
def runTest(self): | ||
""" | ||
Test all of the plugins that have test data files in the data | ||
directory. | ||
""" | ||
Plugins = [fedora_uname_a,fedora_rpm] | ||
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(FedoraLinuxPluginsTestCase)) | ||
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.Fedora" | ||
VERSION = "1.0" | ||
AUTHOR = "Eric Edgar" | ||
LICENSE = "" | ||
NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.community'] | ||
PACKAGES = ['ZenPacks', 'ZenPacks.community', 'ZenPacks.community.Fedora'] | ||
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, | ||
) |