Packages/Errata installed via Satellite - Reporting

Latest response

For the purposes of reporting, I was wanting to include the total number of patches/errata pushed within a specific time period. Does anyone know where I might find that functionality within Satellite? Does it exist?

I have played with spacewalk-report a bit, but can't get the granularity I am needing.

Thanks.

Responses

I don't know how to do that in satellite, but at the command line you can run:

rpm -qa --last > /tmp/foo

And remove the entries outside your time period.

Thanks, but was hoping for something sourced from Satellite. Not wanting to touch each box to collect the data...then have to put it into some kind of readable format.

You may have to use the API to collect this data in the format that you want. As you mentioned you have looked at spacewalk-report I am assuming you are using Satellite 5.

In Satellite 5, each system has a number of events associated with it. You can query these via the API and report on them.

Notes/Caveats: This script pulls information using the system.listSystemEvents method. Package installations using the yum command locally (or directly calling RPM) would not be captured in this output. This will only capture package installations initiated directly via Satellite's UI (or API). This sounds like it would be OK for your usage, but I have to state it up front :)

Basically, what the script does is "given a system ID & number of days to look retroactively, show the events that are either errata or package installs'

Python Example follows (download as listSystemEvents.py)

#!/usr/bin/env python

import getpass
import sys
import xmlrpclib
from datetime import date
from optparse import OptionParser

today = date.today()

parser = OptionParser()
parser.add_option("-l", "--login", dest="login", help="Login user for satellite", metavar="LOGIN")
parser.add_option("-p", "--password", dest="password", help="Password for specified user on satellite", metavar="PASSWORD")
parser.add_option("-s", "--server", dest="serverfqdn", help="FQDN of satellite server - omit https://", metavar="SERVERFQDN")
parser.add_option("-i", "--id", dest="systemid", type=int, help="System ID of the server", metavar="SYSTEMID")
parser.add_option("-d", "--days", dest="daysback", type=int, help="Number of days ago", metavar="DAYSBACK")
(options, args) = parser.parse_args()

if not (options.login and options.serverfqdn):
    print "Must specify login, password and server options.  See usage:"
    parser.print_help()
    print "\nExample usage: ./listSystemEvents.py -l admin -p password -s satellite.example.com -i 1000000 -d 24"
    sys.exit(1)
else:
    login = options.login
    password = options.password
    serverfqdn = options.serverfqdn
    systemid = options.systemid
    daysback = options.daysback

if not password:
    password = getpass.getpass("%s's password:" % login)

SATELLITE_URL = "https://%s/rpc/api" % serverfqdn
SATELLITE_LOGIN = login
SATELLITE_PASSWORD = password

client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)

events = client.system.listSystemEvents(key, systemid)
for event in events:
    if event['action_type'] == "Errata Update" or event['action_type'] == "Package Install":
        rhndate = str(event['completed_date'])
        working_rhn_date = date(int(rhndate[0:4]), int(rhndate[4:6]), int(rhndate[6:8]))
        days_ago = abs(today - working_rhn_date)
        if days_ago.days < daysback:
            print "Time : " + str(event['completed_date'])
            print "Action Type : " + event['action_type']
            print "Name : " + event['name']
            if event.has_key('additional_info'):
                print "Detail: "
                for info in event['additional_info']:
                    print "        " + info['detail']
                    print

client.auth.logout(key)
sys.exit(0)

Example output

./listSystemEvents.py  -l admin -p 'supersecret' -s satellite.domain.com -i 1000010100 -d 180  

    Time : 20121008T13:27:28  
    Action Type : Package Install  
    Name : Package Install  
    Detail:   
            bind-libs-9.8.2-0.10.rc1.el6_3.4:32  
            bind-utils-9.8.2-0.10.rc1.el6_3.4:32  
            dracut-004-284.el6_3.1  
            dracut-kernel-004-284.el6_3.1  
            gnome-keyring-2.28.2-8.el6_3  
            strace-4.5.19-1.11.el6_3.2  
            systemtap-runtime-1.7-5.el6_3.1  
            tzdata-2012f-1.el6  
            tzdata-java-2012f-1.el6  

    Time : 20120928T01:35:38  
    Action Type : Package Install  
    Name : Package Install  
    Detail:   
            rhev-agent-2.3.16-4.el6_3  

You can easily adapt his script to query multiple systems, or to reformat the data however you'd like. Hope this helps.

  • Rich
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.