Hello,
I have created and post here a script last summer to clean channels for
old non-installed packages. You can find it attached, but as I didn't
use it since, be careful ;)

You have to modify lines 33 to 36 to comply with your spacewalk
configuration.

regards.

Nicolas PRADELLES
Ingénieur Systèmes & Réseaux
Direction des Systèmes d'Information
T: +33 1 53 98 30 83
F: +33 1 53 98 48 98
email: [email protected]

Le 05/03/2013 08:58, Nielsen, Dennis Appelon a écrit :
> Hi Thomas
> I ran the spacewalk-data-fsck -v -r all night, but nothing got delete, I'm 
> still able to find old Fedora 16 packets when I look for them, and the total 
> disk-space there is free is not changed after the run...
>
> Any suggestions to clean-out old repo's would be appreciated...
>
> Regards
>
> Dennis Appelon Nielsen | GNU/Linux Consultant | CGI Denmark
> Margrethepladsen 4, 8000 Aarhus C | Danmark
> M: +45 29 48 11 18
> [email protected] | www.cgi.com | www.cgi.dk
> RHCSA, RHCT – 605009853527704
>
> CONFIDENTIALITY NOTICE: Proprietary/Confidential Information belonging to CGI 
> Group Inc. and its affiliates may be contained in this message. If you are 
> not a recipient indicated or intended in this message (or responsible for 
> delivery of this message to such person), or you think for any reason that 
> this message may have been addressed to you in error, you may not use or copy 
> or deliver this message to anyone else. In such case, you should destroy this 
> message and are asked to notify the sender by reply e-mail.
>
> ________________________________________
> From: [email protected] [[email protected]] 
> on behalf of Nielsen, Dennis Appelon [[email protected]]
> Sent: Monday, March 04, 2013 13:52
> To: [email protected]
> Subject: Re: [Spacewalk-list] Disk usage by Spacewalk repo's is growing and 
> never shrinking
>
> Hi Michael
> Thanks for you reply... I'm running the spacewalk-data-fsck -v -r in a screen 
> as I type.
>
> I also have a problem with " java.lang.OutOfMemoryError: Java heap space"
>
> Where can I increase the memory ?
>
> Snip from log
>
> INFO   | jvm 3    | 2013/03/04 12:47:46 | 2013-03-04 12:47:46,058 [Thread-67] 
> INFO  com.redhat.rhn.taskomatic.task.repomd.RepositoryWriter - Generating new 
> repository metadata for channel 'fedora18-x86_64-updates'(sha256) 18334 
> packages, 139 errata
> INFO   | jvm 3    | 2013/03/04 12:54:16 | Exception in thread "Thread-67" 
> java.lang.OutOfMemoryError: Java heap space
>
> -----//
>
>
> Best regards
> Dennis Appelon Nielsen | GNU/Linux Consultant | CGI Denmark
> Margrethepladsen 4, 8000 Aarhus C | Danmark
> M: +45 29 48 11 18
> [email protected] | www.cgi.com | www.cgi.dk
> RHCSA, RHCT – 605009853527704
>
> CONFIDENTIALITY NOTICE: Proprietary/Confidential Information belonging to CGI 
> Group Inc. and its affiliates may be contained in this message. If you are 
> not a recipient indicated or intended in this message (or responsible for 
> delivery of this message to such person), or you think for any reason that 
> this message may have been addressed to you in error, you may not use or copy 
> or deliver this message to anyone else. In such case, you should destroy this 
> message and are asked to notify the sender by reply e-mail.
>
> ________________________________________
> From: [email protected] [[email protected]] 
> on behalf of Michael Mraka [[email protected]]
> Sent: Monday, March 04, 2013 13:39
> To: [email protected]
> Subject: Re: [Spacewalk-list] Disk usage by Spacewalk repo's is growing and 
> never shrinking
>
> Nielsen, Dennis Appelon wrote:
> % Hi All
> % I need some help, I run a spacewalk server, and have had a lot of problems 
> trying to monitor and update Oracle Linux 5.
> %
> % I have made many channels and repo's and delete a ton of them to, but 
> deleting the repo from web, don't give any freespace in the /var filesystem.
> %
> % If I look around I can see that there are data from long gone repo's and 
> channels, how can I regain my diskspace ?
>
> spacewalk-data-fsck
>
> It might help you to find and delete rpm packages on disk which
> are no longer referenced from database.
>
> Regards,
>
> --
> Michael Mráka
> Satellite Engineering, Red Hat
>
> _______________________________________________
> Spacewalk-list mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/spacewalk-list
>
>
> _______________________________________________
> Spacewalk-list mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/spacewalk-list
>
>
> _______________________________________________
> Spacewalk-list mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/spacewalk-list



This message may contain confidential or privileged information and is
intended only for the personal and confidential use of the designated
recipient(s) named above. If you are not one of the intended recipients
of this message you are hereby notified that any review, dissemination,
distribution or copying is strictly prohibited.
This communication is for information purposes only and should not be
regarded as an official statement of Eutelsat S.A. or any of its
subsidiaries. E-mail transmission cannot be guaranteed to be secure or
error-free. Therefore, Eutelsat S.A. does not claim that this information
is complete or accurate and it should not be treated as such.

#!/usr/bin/python
# Script that uses RHN API to cleanup obsolete packages
# on Spacewalk server.
# Copyright (C) 2012  Nicolas PRADELLES
#
# Author: Nicolas PRADELLES ([email protected])
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#
# Version Information:
# 0.2 - 2012-08-27 - Script rewritten in Python to access Spacewalk XML RPC API
# 0.1 - 2012-04-17 - First Release


import xmlrpclib
import string
import os

# CONFIG
## URL of Spacewalk XML RPC server
SATELLITE_URL = "http://SPACEWALK-SRV/rpc/api";
## User with Org Admin role (required to delete package in Spacewalk)
SATELLITE_LOGIN = "XXXX"
SATELLITE_PASSWORD = "YYYY"

# Open connection to XML RPC server
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)

# extract spacewalk channels
list = client.channel.listAllChannels(key)

all_del_pkg = 0

# For each channel
for channel in list:
  print "################\n" + channel.get('label')

  # extract all packages in channel
  all_array = client.channel.software.listAllPackages(key, channel.get('label'))
  # extract latest packages in channel
  lst_array = client.channel.software.listLatestPackages(key, channel.get('label'))


  # Extract useful datas to find obsolete packages
  all_pkg = ()
  lst_pkg = ()

  # create a unique string to define a package, exemple:  java-1.6.0-sun-jdbc%1.6.0.31%1jpp.1.el6_2%58920
  for pkg in all_array:
    all_pkg = all_pkg + (pkg.get('name') + '%' + pkg.get('version') + '%' + pkg.get('release') + '%' + str(pkg.get('id')),)

  for pkg in lst_array:
    lst_pkg = lst_pkg + (pkg.get('name') + '%' + pkg.get('version') + '%' + pkg.get('release') + '%' + str(pkg.get('id')),)


  # diff the two lists to find obsolete packages
  old_pkg = set(all_pkg) - set(lst_pkg)

  del_pkg = 0

  # if we have found obsolete packages
  if len(old_pkg) > 0:
    for pkg in old_pkg:
      pkg_params = string.split(pkg, '%')
      # check if the old package is installed on a managed client
      systems = client.system.listSystemsWithPackage(key, pkg_params[0], pkg_params[1], pkg_params[2])

      # if this package is not installed on a managed client
      if len(systems) == 0:
        # delete the package
        print pkg_params[0] + '-' + pkg_params[1]
        client.packages.removePackage(key, int(pkg_params[3]))
        del_pkg += 1

  all_del_pkg += del_pkg
  print "all: " + str(len(all_pkg)) + ", latest: " + str(len(lst_pkg)) + ", old: " + str(len(old_pkg)) + ", deleted: " + str(del_pkg)


# Delete rpm files on disk
if all_del_pkg > 0:
  print "################\n\n\nClean RPM files\n"
  os.system('spacewalk-data-fsck -r -S -C -O')

# disconnect
client.auth.logout(key)

<<attachment: npradelles.vcf>>

_______________________________________________
Spacewalk-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-list

Reply via email to