Automating the download of AIX Health Check

It is fairly easy to automate the download of the latest version of AIX Health Check to your AIX system. Doing so, removes the need for downloading AIX Health Check manually, and also removes the need to transfer the downloaded file onto your AIX systems manually.


What do you need?
  • Install either curl or wget on your AIX system. These tools are not part of a regular AIX installation. You can download the RPM for these tools here:
    AIX Toolbox for Linux Applications
  • Your AIX system needs Internet access, and needs to be able to resolve "aixhealthcheck.com" through DNS.

    For example, test with a simple ping:
    # ping aixhealthcheck.com
  • You need a valid license for AIX Health Check, which provides you a login/email address and a password to access the AIX Health Check download page.

Examples of using curl and wget to download AIX Health Check
Here's an example of how you can use curl to download the latest version of AIX Health Check (assuming your login/email address is "user@email.com" and your password is "mypassword"):
curl -d "emailaddress=user@email.com&password=mypassword" \
   --referer http://www.aixhealthcheck.com \
   http://www.aixhealthcheck.com/downloadauto.php \
   -o ahc_latest.tar
This command will download file ahc_latest.tar in your current folder. Please note that providing the email address, password and referer is required. Without it, the download will fail.

The same download can be accomplished with wget:
wget --post-data 'emailaddress=user@email.com&password=mypassword' \
   --referer=http://www.aixhealthcheck.com \
   --cache=no http://www.aixhealthcheck.com/downloadauto.php \
   -O ahc_latest.tar
Once you have downloaded the ahc_latest.tar file, you will be able to un-tar the file and use AIX Health Check.


Automating download with a script
You can automate downloading AIX Health Check easily with the use of a Korn Shell script. The script that is shown below downloads AIX Health Check with wget, will untar the downloaded file, run AIX Health Check, send an HTML style report through email, and clean up afterwards.
#!/usr/bin/ksh

# VARIABLES
emailaddress="user@email.com"
password="mypassword"
folder="/ahc"

# Test if folder already exists
if [ -d ${folder} ] ; then
        echo "Folder ${folder} already exists. Aborting."
        exit
fi

# Test if wget is executable
if [ ! -x /usr/bin/wget ] ; then
        echo "Wget does not exist or is not executable. Aborting."
        exit
fi

# Create a folder to store AIX Health Check
echo "Creating folder ${folder}..."
mkdir -p ${folder}

# Download the file
echo "Downloading AIX Health Check..."
wget --post-data "emailaddress=$emailaddress&password=$password" \
   --referer=http://www.aixhealthcheck.com \
   --cache=no http://www.aixhealthcheck.com/downloadauto.php \
   -O ${folder}/ahc_latest.tar >/dev/null 2>&1

# Un-tar the downloaded file
if [ -s ${folder}/ahc_latest.tar ] ; then
        cd /ahc
        echo "Un-tar the downloaded file..."
        tar -xvf ${folder}/ahc_latest.tar >/dev/null 2>&1
        cd - >/dev/null 2>&1
        echo "Removing downloaded file..."
        rm ${folder}/ahc_latest.tar

        # Run AIX Health Check
        if [ -x ${folder}/checkall.ksh ] ; then
                echo "Running AIX Health Check..."
		${folder}/checkall.ksh -hdm user@email.com 
                echo "Removing folder ${folder}..."
                rm -rf ${folder}
        else
                echo "Encountered an error with checkall.ksh"
                echo "Removing folder ${folder}..."
                rm -rf ${folder}
                exit
        fi
else
        echo "Error downloading AIX Health Check."
        echo "Removing folder ${folder}..."
        rm -rf ${folder}
        exit
fi
The script above can be used to download AIX Health Check to your AIX system in folder /ahc. Please make sure to provide the correct login/email address and password in the beginning of the script for variables emailaddress and password, and if you wish to specify a different location for storing AIX Health Check, you can change this in the script as well, by updating the folder variable.

The output of the script above, will look like this (assuming you have named the script "run-ahc.ksh"):
# ./run-ahc.ksh
Creating folder /ahc...
Downloading AIX Health Check...
Un-tar the downloaded file...
Removing downloaded file...
Running AIX Health Check...
Removing folder /ahc...