Skip to content

Instantly share code, notes, and snippets.

@komeda-shinji
Last active August 29, 2015 14:21
Show Gist options
  • Save komeda-shinji/7021c2b90c9451045cdc to your computer and use it in GitHub Desktop.
Save komeda-shinji/7021c2b90c9451045cdc to your computer and use it in GitHub Desktop.
Products/DataCollector/plugins/zenoss/cmd/linux/rpm.py
#
__doc__ = """
zenoss.cmd.linux.rpm finds various software packages installed on a device.
Invoke rpm command via SSH session.
"""
from Products.DataCollector.plugins.CollectorPlugin \
import LinuxCommandPlugin, SoftwareCommandPlugin
from Products.ZenUtils.Utils import prepId
from Products.DataCollector.plugins.DataMaps import MultiArgs
def parseResults(results):
swdicts = []
for line in results.splitlines():
name = line.lstrip()
if name:
id = self.prepId(name)
vendor = 'Unknown'
sw = {'id': id, 'setProductKey': MultiArgs(name, prepId(vendor))}
swdicts.append(sw)
return swdicts
class rpm(LinuxCommandPlugin, SoftwareCommandPlugin):
maptype = "SoftwareMap"
modname = "Products.ZenModel.Software"
relname = "software"
compname = "os"
command = '[ -x /bin/rpm ] && /bin/rpm -qa'
def __init__(self):
SoftwareCommandPlugin.__init__(self, parseResults)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment