• Red Hat Network Patch Reports

    Posted on June 18th, 2011 Jorge Escala 1 comment

    Here is a little perl script I made to produce CSV formatted reports of missing patches on all your servers registered with Red Hat Network. The script produces a brief report with a count of missing updates per server and a verbose report with a detailed list of all the updates that are missing per server.

    You’ll need to modify the $user and $pass variables with your RHN credentials. I haven’t tested it with Satellite server but it should work fine as long as you put your Satellite server address in the $HOST variable. If you try it, comment below to let me know how it worked!

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    #!/usr/bin/perl
    # rhn-report.pl
    # (c) 2011 Jorge Escala - http://jescala.com/

    use Net::IPAddress;
    use Frontier::Client;

    my $HOST = 'xmlrpc.rhn.redhat.com';
    my $user = 'username';
    my $pass = 'password';

    my $client = new Frontier::Client(url => "http://$HOST/rpc/api");
    my $session = $client->call('auth.login',$user, $pass);

    open (BRIEF_LIST,">MissingUpdatesBrief-RHEL.csv") or die("Cannot open file for writing\n");
    print BRIEF_LIST "Server,Patches Needed\n";
    open (VERBOSE_LIST,">MissingUpdatesVerbose-RHEL.csv") or die("Cannot open file for writing\n");
    print VERBOSE_LIST "Server,Patch Needed\n";

    my $systemlist = $client->call('system.listUserSystems', $session);
    foreach my $system (@$systemlist) {
       my $upgradelist = $client->call('system.listLatestUpgradablePackages', $session, $system->{'id'});
       ($host,$dom) = Net::IPAddress::fqdn($system->{'name'});
       unless($host) {
          $host = $system->{'name'};
       }
       print BRIEF_LIST lc($host).",".@$upgradelist."\n";
       foreach my $upgrade (@$upgradelist) {
          print VERBOSE_LIST lc($host).",".$upgrade->{'name'}." ".$upgrade->{'to_version'}."\n";
       }
    }

    close VERBOSE_LIST;
    close BRIEF_LIST;
    $client->call('auth.logout', $session);
     

    1 responses to “Red Hat Network Patch Reports” RSS icon

    • Worked like a charm! I guess I need to learn the rhn api :)

      Thanks for the hard work!!! It’s greatly appreciated!!

      -Dave

    Leave a reply