Thursday, December 27, 2012

Reclaim Underutilized OFFSITE Volumes in TSM

I have a customer that has a reasonable size TSM environment, however the daily change rate is really low. This causes the DRM media that is sent offsite to be utilized at roughly 1-5%. Since the data doesn’t expire quickly they aren’t reclaimed and the volumes tend to sit offsite without being rotated. Using LTO5 media you can imagine that it’s a huge waste of media space.

I put this together to be run periodically either manually or via cron and allow it to run until completion. It will start with the least utilized volumes and work to the ones that are the most utilized. Of course if you use collocation or will never fill a volume to 80% you will need to change the values accordingly.

#!/usr/bin/perl
use strict;
use warnings;
my $login = "/usr/bin/dsmadmc -id=ADMINUSER -password=ADMINPASS";
my @volumes;
sub getVolumeList {
    my @tempVolumes = ();
    @tempVolumes = `$login -dataonly=yes "select volume_name from volumes where access='OFFSITE' and pct_utilized>0 and pct_utilized<80 order by pct_utilized" `;
    foreach (@tempVolumes) {
        chomp;
        push @volumes, substr($_, -9);
    }
}
getVolumeList;
foreach (@volumes) {
    print "$_\n";
    my $result = `$login -noconfirm "move data $_ wait=yes`;
}

Monday, August 6, 2012

Schedule Creation of MKSYSB to NIM Server

I have a customer that has a fair amount of systems they need to protect. Recently we had a corruption that required the re-install of the operating system. While this is an extremely rare event on modern systems, the problem was compounded by the fact they didn’t have a good mksysb backup. We needed to find a system that was similar (Test/Dev), locate the tape drives, move them to the source, take the backup, move the tape to the target and re-install. Not a fun evening and all the trouble could have easily been adverted by having a good backup.
If you have more than four AIX systems I would recommend having a NIM server. This should be your point of administration for everything done in AIX if possible. Also it gives you an environment to script, upgrade and deploy without working on your production systems.
This is a script I wrote to be executed by cron on the NIM server. It does a few things here:
  1. Queries NIM for a list of “standalone” systems
  2. Performs a mksysb backup of each and registers them on the NIM server as a resource
  3. Creates a backup of the volume group that all my NIM data is on. (I know you didn’t put it on rootvg!)
  4. Ejects the tape so it can be brought offsite
  5. Emails the report to the admin
#!/usr/bin/sh
 
DATE=`date +%m%d%Y`
LOGFILE=/tmp/mksysblog_${DATE}
SENDTO="admin@domain.com"
MSGCONTENT=""
 
LOG()
{
    echo "$*" >> $LOGFILE 2>&1
}
 
LOG "------------ MKSYSB LOG FOR ${DATE} ------------------"
TIME=`date`
LOG "Process started at ${TIME}"
 
#for mach in 0; do
for mach in $(lsnim -t standalone | awk '{print $1}'); do
    LOG ""
    LOG ""
    LOG "**************************************************"
    LOG "Starting process for ${mach} "
    LOG "Removing the NIM resources for ${mach}"
 
    nim -o remove ${mach}_mksysb >> $LOGFILE 2>&1
 
    LOG "NIM resources removed for ${mach}"
    LOG ""
    LOG "Starting mksysb backup of ${mach}"
    nim -o define -t mksysb -a server=master -a location=/export/mksysb/${mach}_mksysb -a source=${mach} -a mk_image=yes -a mksysb_flags="-i -m -e -p" -F ${mach}_mksysb >> $LOGFILE 2>&1
    if [ $? != 0 ]
        then
        echo "ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR" > ${MSGCONTENT}
        mail -s "MKSYSB error on ${mach}" "${SENDTO}" < ${MSGCONTENT}
        LOG "  ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR "
        LOG " There was an error of ${mach} "
        echo "" > ${MSGCONTENT}
    fi
    LOG "Completed the mksysb of ${mach}"
done
 
LOG "Starting the SAVEVG of NIM_VG"
/usr/bin/savevg -vmpXf /dev/rmt0 nim_vg >> $LOGFILE 2>&1
if [ $? != 0 ] then
    echo "ERROR on SAVEVG " > ${MSGCONTENT}
    mail -s "ERROR on SAVEVG" ${SENDTO} < ${MSGCONTENT}
    LOG " ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR "
    LOG "There was an error on the NIM server while saving to tape"
    echo "" > ${MSGCONTENT}
fi
LOG "Completed the SAVEVG"
LOG "Rewinding and ejecting the tape"
mt -f /dev/rmt0 rewoffl
LOG "Backup process complete"
 
TIME=`date`
LOG "Completed at ${TIME}"
 
mail -s "MKSYSB Process Log" "${SENDTO}" < ${LOGFILE}




As always use as needed, but please comment if you have them.


Cheers

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