Wednesday, August 1, 2012

Collect Software Report for AIX

I had a need for a customer to report what software is installed and to report when it was installed. This included the AIX software sources, efixes and anything installed via RPM. I was able to throw this together in a few minutes which fit the bill.

#!/usr/bin/sh
 
HOSTNAME=`hostname`
DATE=`date +%m%d%Y`
LOGDIR=$HOME/log
REPORTNAME="SOFTWARE_AUDIT_$DATE"
 
MAILTO="someone@domain.com"
 
FULLLOG=$LOGDIR/$REPORTNAME
 
LOG()
{
        echo "$*" >> $FULLLOG 2>&1
}
 
 
if [[ ! -d $LOGDIR ]] then
        mkdir -p $LOGDIR
fi
 
 
LOG "#######################################"
LOG "# List AIX LPP Software "
LOG "#######################################"
lslpp -L | lslpp -h >> $FULLLOG 2>&1
 
 
LOG "\n\n\n "
LOG "######################################"
LOG "# List of EFIX"
LOG "######################################"
emgr -l >> $FULLLOG 2>&1
 
LOG "\n\n\n"
LOG "#####################################"
LOG "# List of RPM Software"
LOG "#####################################"
 
rpm -qa --qf '%{installtime:date} Installed: %{name} %{version} \n' |awk '{print $5, $2, $3, $1, $4, $6, $7, $8}'| head -10 | sort >> $FULLLOG 2>&1
 
mail -s "Software Audit Report for $DATE" $MAILTO < $FULLLOG

No comments:

Post a Comment