Subversion Repositories camp_sysinfo_client_3

Rev

Rev 87 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 rodolico 1
#!/usr/bin/env perl
2
use warnings;
26 rodolico 3
use strict;  
2 rodolico 4
 
37 rodolico 5
# Description: Get packages installed via rpm (RedHat)
20 rodolico 6
 
37 rodolico 7
our $VERSION = '1.2';
8
 
20 rodolico 9
# Redhat software module for sysinfo client
10
# Author: R. W. Rodolico
11
# Date:   2016-04-08
2 rodolico 12
# gets information on software on systems with rpm on them (Redhat)
13
 
251 rodolico 14
# find our location and use it for searching for libraries
2 rodolico 15
BEGIN {
251 rodolico 16
   use FindBin;
17
   use File::Spec;
18
   use lib File::Spec->catdir($FindBin::Bin);
19
   eval( 'use library;' ); die "Could not find library.pm in the code directory\n" if $@;
20
   eval( 'use Data::Dumper;' );
2 rodolico 21
}
22
 
251 rodolico 23
# check for valid OS. 
24
exit 1 unless &checkOS( { 'linux' => undef } );
2 rodolico 25
 
251 rodolico 26
# check for required commands, return 2 if they don't exist. Enter an full list of all commands required. If one doesn't exist
27
# script returns a 2
28
foreach my $command ( 'rpm' ) {
29
   exit 2 unless &validCommandOnSystem( $command );
30
}
2 rodolico 31
 
32
 
33
my $CATEGORY = 'software';
34
 
251 rodolico 35
my @packageList = split( "\n", qx( rpm -qa --qf "%{NAME}\\t%{VERSION}\\t%{DISTRIBUTION}\\n" ) );
2 rodolico 36
chomp @packageList;
28 rodolico 37
for ( my $i = 0; $i < @packageList; $i++ ) {
2 rodolico 38
   my ($package, $version, $distribution)  = split( "\t", $packageList[$i]);
39
   print "$CATEGORY\t$package\tversion\t$version\n";
7 rodolico 40
#   print "$CATEGORY\t$package\tdescription\t" . join(" ", @description) . "\n";
2 rodolico 41
}